by lunarg on April 28th 2007, at 00:46

What is the kernel frequency?

In short: the kernel frequency is the number of interrupts (IRQs) handled by the kernel per second. Like most applications of frequency, it's also expressed at Hz (hertz).

A more sound explanation of interrupts can be found here, but it basically boils down to this: an interrupt is generated each time an event on a piece of hardware (in the most elementary way; this includes your keyboard for instance), and requires the necessary CPU time to handle that event. This is called interrupt handling.

Now, because the kernel directly interacts with all the hardware around, it's vital to have it handle interrupts; actually, it's the kernel that handles interrupts, by using the CPU.

Why do I care?

Very simple: the more times the kernel can handle an interrupt, the more events may be processed. As a result, the more events (thus interrupts) are processed, the more responsiveness the system gets: the system (and kernel) can react faster to events, which is important on let's say the average desktop system.
There's however a big fat warning to it, because handling events (and interrupts) does require CPU time. The more interrupt handling occurs, the less time there is for handling user-space applications. On the other side, the less interrupt handling occurs, there would be more time for user-space applications, but the system would become less responsive. The endgame is getting a good balance, allowing more time for interrupt handling, without losing too much time for user-space applications. For this, we can set the kernel frequency.
Whereas other operating systems usually have it fixed, the linux kernel provides an easy way to change this to your needs.

How to configure?

Best value for which situation?

Well, it's luckily not that difficult. The thumb rule is that usually for desktop systems, the kernel frequency is set higher, because one would require a more responsive systems (in particular for internet, and of course, for gaming). For server systems, the kernel frequency would be a bit lower, because there's more need of much CPU time for those own applications; a responsive system in the way of a desktop is surely not required here.

In the linux kernel, there are currently (at time of writing, 2.6.15) three options available:

  • 100hz: used for high-end servers, where CPU time for userland applications is a must.
    This one's also recommended for SMP and NUMA (multi processor) systems to avoid losing too much time on interrupt handling (MP interaction and overhead).
  • 250hz: a good balanced system, for servers which require a bit more responsiveness, and also still a decent choice for SMP and NUMA (in particular for desktops with SMP).
  • 1000hz: for desktops (and gaming systems), where responsiveness is a must.

The best choices are usually 250hz for average servers, and 1000hz for desktops. One could deviate of course, but these are the recommendations from the kernel developers.

Where to find it in the kernel config?

When using, make menuconfig, you'll find it at Processor types and features. The option says Timer Frequency.

In the config file itself, the option's called: CONFIG_HZ.

« December 2023»
« Most people tend to avoid true conflict. Ironically this breeds more conflict. »