Skip to contentSkip to conversation

DEVICE POLLING

DISCUSSION kasp 3 participants 5 messages Feb 2, 2006

lore
Share & tools
lore

kasp

author
#0 lore raw

Hello!

I've read that *BSD like systems support device polling:

------------------------------------------------------------
You can enable DEVICE_POLLING in your kernel. DEVICE_POLLING changes the method through which data gets from your network card to the kernel. Traditionally, each time the network card needs attention (for example when it receives a packet), it generates an interrupt request. The request causes a context switch and a call to an interrupt handler. A context switch is when the CPU and kernel have to switch from user land (the user's programs or daemons), and kernel land (dealing with device drivers, hardware, and other kernel-bound tasks).
The last few years have seen significant improvements in the
efficiency of context switching but it is still an extremely expensive operation. Furthermore, the amount of time the system can have to spend when dealing with an interrupt can be almost limitless. It is completely possible for an interrupt to never free the kernel, leaving your machine unresponsive. Those of us unfortunate enough to be on the wrong side of certain Denial of Service attacks will know about this.

The DEVICE_POLLING option changes this behavior. It causes the kernel to poll the network card itself at certain predefined times: at defined intervals, during idle loops, or on clock interrupts. This allows the kernel to decide when it is most efficient to poll a device for updates and for how long, and ultimately results in a significant increase in performance.

If you want to take advantage of DEVICE_POLLING, you need to compile two options in to your kernel:

* options DEVICE_POLLING
* options HZ=1000

The first line enables DEVICE_POLLING and the second device slows the clock interrupts to 1000 times per second. The need to apply the second, because in the worst case your network card will be polled on clock ticks. If the clock ticks very fast, you would spend a lot of time polling devices which defeats the purpose here.

Finally we need to change one sysctl to actually enable this feature. You can either enable polling at runtime or at boot. If you want to enable it at boot, add this line to the end of your /etc/sysctl.conf:

* kern.polling.enable=1

The DEVICE_POLLING option by default does not work with SMP enabled kernels. When the author of the DEVICE_POLLING code initially commited it he admits he was unsure of the benefits of the feature in a multiple-CPU environment, as only one CPU would be doing the polling. Since that time many administrators have found that there is a significant advantage to DEVICE_POLLING even in SMP enabled kernels and that it works with no problems at all. If you are compiling an SMP
kernel with DEVICE_POLLING, edit the file:
/usr/src/sys/kern/kern_poll.c and remove the following lines:

        #ifdef SMP
        #include "opt_lint.h"
        #ifndef COMPILING_LINT
        #error DEVICE_POLLING is not compatible with SMP
        #endif
        #endif

---------------------------------------------------------------------------

So, are there any feature like that in linux kernel supported?

P.S. http://silverwraith.com/papers/freebsd-tuning.php

Signature · 2 lines
Best regards,
 kasp                          mailto:[email protected]
#1 lore raw

From: kasp <[email protected]>
Date: Thu, 2 Feb 2006 10:45:54 +0200

Quoted 1 line

So, are there any feature like that in linux kernel supported?

Yes, it's called NAPI and it's on by default in many drivers.

But this is ancient history and a better scheme for dealing these issues is coming soon, in the form of Van Jacobson's net channels.

#2 lore raw
In reply to kasp
Quoted 4 lines · kasp

Hello!

I've read that *BSD like systems support device polling:
So, are there any feature like that in linux kernel supported?

The Linux kernel does similar things for high network loads. Some serial hardware also supports that functionality (eg comtrol rocketport).

author
#3 lore raw

Hello Alan,

Quoted 2 lines · you
Quoted 2 lines

I've read that *BSD like systems support device polling:
So, are there any feature like that in linux kernel supported?

AC> The Linux kernel does similar things for high network loads. Some serial AC> hardware also supports that functionality (eg comtrol rocketport).

Should I turn this feature somewhere on, or is it already enabled by default? I'm using Intel PRO/100 network cards if it's important.

Signature · 2 lines
Best regards,
 kasp                            mailto:[email protected]
#4 lore raw
Quoted 2 lines · kasp

Should I turn this feature somewhere on, or is it already enabled by default? I'm using Intel PRO/100 network cards if it's important.

Its the "NAPI" options in the make config stage. Or see the NAPI howto in the kernel source tree