|
|
Subscribe / Log in / New account

Clockevents and dyntick

One of the last patch sets to be merged before the 2.6.21 window closed was the clockevents and dyntick work from the real-time tree. These patches have been in the works for some time, and were originally targeted for merging in 2.6.19. In the process, the developers (primarily Ingo Molnar and Thomas Gleixner) discovered one of the fundamental laws of kernel development: if your patches break Andrew Morton's laptop, they are unlikely to make it into the mainline. That little difficulty has now been overcome, with the result that 2.6.21 will include some interesting core changes.

Dealing with clock devices has traditionally been handled in the kernel's architecture-specific code. The result has been a lot of duplicated code between architectures (there are more architectures than common timer devices) and no uniform interface for the core kernel to make use of these devices. John Stultz's generic time of day infrastructure resolved a number of those problems, at least for the timekeeping task, but anybody who wanted to program timer devices in a more general way still ended up dealing with architecture-specific code.

The "clockevents" patch set finishes this job. At its core, clockevents creates a driver API for devices which can deliver interrupts at a specific time in the future. The API tracks the capabilities of each timer (resolution and whether it can do one-shot or periodic interrupts, for example) and provides a simple interface for arming the timer. This API is defined in the core kernel, with only a low-level driver remaining in the architecture-specific code. The end result is that the kernel now has the means to query and use timer capabilities in an architecture-independent manner.

With the clockevents mechanism in place, it becomes possible to support truly high-resolution timers. When such a timer is requested, all that is required is to pick a suitable clockevent device and arm it for the desired time. These devices can deliver interrupts with a high degree of precision, with the result that kernel timers, too, can offer high precision - a feature which is of clear utility to real-time users (among others).

The periodic timer tick is now implemented with a clockevent as well. It does all of the things the old timer-based interrupt did - updating jiffies, accounting CPU time, etc. - but it is run out of the new infrastructure.

All of this is an improvement, but there is still one thing which could be better: there is no real need for a periodic tick in the system. That is especially true when the processor is idle. An idle CPU can save quite a bit of power, but waking that CPU up 100 times (or more) per second will hurt those power savings considerably. With a flexible timer infrastructure, there is no point in turning the CPU back on until it has something to do. So, when the (i386) kernel goes into its idle loop, it checks the next pending timer event. If that event is further away than the next tick, the periodic tick is turned off altogether; instead, the timer is is programmed to fire when the next event comes due. The CPU can then rest unharrassed until that time - unless an interrupt comes in first. Once the processor goes out of the idle state, the periodic tick is restored.

What's in 2.6.21 is, thus, not a full dynamic tick implementation. Eliminating the tick during idle times is a good step forward, but there is value in getting rid of the tick while the system is running as well - especially on virtualized systems which may be sharing a host with quite a few other clients. The dynamic tick documentation file suggests that the developers have this goal in mind:

The implementation leaves room for further development like full tickless systems, where the time slice is controlled by the scheduler, variable frequency profiling, and a complete removal of jiffies in the future.

So expect some interesting work in the future - the removal of jiffies alone has a number of interesting implications. The developers also have support for the x86_64 and ARM architectures, though that support has not been merged for 2.6.21; MIPS and PowerPC support is in the works as well.

Index entries for this article
KernelClockevents
KernelDynamic tick
Kernelhrtimer


to post comments

dyntick in 2.6.6

Posted Feb 22, 2007 11:12 UTC (Thu) by arnd (subscriber, #8866) [Link] (1 responses)

Just as a historic side note, support for disabling the timer tick during
idle was first merged three years ago for the s390 architecture, see
http://lwn.net/Articles/82378/. The first lwn coverage I could find on the
topic is http://lwn.net/2001/0412/bigpage.php3#kernel, another three years
earlier, with a patch against the 2.4.3 kernel.

dyntick in 2.6.6

Posted Feb 24, 2007 6:14 UTC (Sat) by jzbiciak (guest, #5246) [Link]

IBM was pretty big on the tickless kernel idea quite awhile ago, probably due to their emphasis on hypervisors and virtualization. Separately, the ARM branch has been big on it for the embedded space.

It looks like the major difference is that clockevents gives an abstraction layer for the clock. Once all the arches are synced up to that, I wonder if dyntick becomes the default?

Benchmark

Posted Mar 1, 2007 13:56 UTC (Thu) by jmranger (guest, #43784) [Link] (1 responses)

Has anyone seen any benchmarks on this ? I would expect no impact on performance, but I'm wondering how significant the power savings could be.

Benchmark

Posted Apr 26, 2007 14:36 UTC (Thu) by gyrovague (guest, #44928) [Link]

I haven't seen benchmarks on this in particular, but I remember reading a piece a while ago where a guy claimed that his laptop battery lasts TWICE as long with a 100Hz tick than with a 1000Hz tick... So, I'm expecting great things...


Copyright © 2007, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds