quarta-feira, dezembro 28, 2005

A day at work

In the meantime between christmas and new year, people decided to clean the neighboor room of the lab with products with airborne contaminants..

quinta-feira, dezembro 22, 2005

What is Timertop

Timertop is a set containing a Linux kernel patch and a user space utility. They work together in order to show in a console the profile of kernel timers utilization. Its development was suggested by Tony Lindgren, one of the creators of the dyn-tick patch, which this tool depends.

The kernel patch inserts a hook in the function next_timer_interrupt (@kernel/timer.c) , a very important dyn-tick function. This hook is a function in the kernel/timertop.c file, account_timer, which retrieves the address of the timer function and some related data and accounts it in a list.
Besides inserting new entries on that list, the function counts the amount of times the timer has expired for that particular timer function and/or process.
The timer functions are all functions from kernel space that are programmed to run when some time (measured in timer ticks) expires.
Thus with Timertop kernel patch one can count how many times such a timer function has been called/expired and store this information so that can be used later.
When the userspace requests the reading of the /proc/top_info file system entry, this kernel list is exported to the console.

The Timertop usespace tool gets this former output and displays it in a interactive manner enabling the users to see the timers usage of kernel timers requested by kernel functions that can be requested or not by user space directly. Indeed they can be request by some other kernel part, indirectly from a userpace program or by kernel loaded modules.

Ok, that's nice. But why do I need it?

Besides showing all that timer information interactively on the screen, Timertop serves as a tool to optimize the idle periods of the machine. To explain this we need some understanding of the dyn-tick patch. The latter was developed in order to prevent the machine to wake up from idle state every time a timer tick interrupt occurs, 1000 times per second if you have a 1000HZ value in your kernel. Every time this interrupt occurs it checks if there is timers to run, run it if so, perform some other activities and goes to sleep again. Straightforward to imagine that not all times the processor wakes up there is useful job to do.
But that is very fast and we go to sleep again hastely, one can say.
Indeed but that depends on how deep was the sleepness of the processor in the idle mode. In idle mode one can go to deep powersave states in terms of inactivity of the processors taking more time to wake up due to latencies in the hardware sybsystems, thereby great amounts of transitions should be avoided as much as possible. Furthermore, this strong powersave mode could make your battery lasts more, so the more time you stay there the better.
With dyn-tick patch, the timer interrupt will wake up the processor only when there is job to do, not in vain, in other words only when some kernel timer will expire. Hence, the amount of times your system wake up to handle timer issues is not more dependent from a fixed HZ but from the amount of programmed timers and its expiration periods.
So it'd be a good idea to fine tune this periods and prevent the system to wake up unnecessarily. You can do that if you know which timers are running, their frequencies and their owners.
That's what Timertop is for.

Timertop - Update

08, August, 2005


Here we have a slightly update for timertop script, it now shows the
ticks in Hz (borrowed from Tony's pmstats - let me know if I shouldn't
:-) ) and some cleanups.

The timertop kernel patch is the same, tested for 2.6.13-rc5-dtck-5.patch.

I'm open to suggestions on what to aggregate in that utility.

In my system, a Dell Latitude D600, dyn tick is working ok. IT has 50
ticks in complete desktop environment.


Here is the original post:

Timertop - first release

A little bit delayed, here goes the first Timertop submission to LKML.
It was originally written in perl and there were some bugs.
4 August, 2005

Here we have some support to have more tests on Dynamic Tick.
We have some functions that exports timers information to a proc entry
(/proc/top_info), in a kernel patch and a script that handles this
info and give some output to analyse. We tried to make it less
intrusive as possible.

It is based in suggestions from Tony Lindgren.

It is experimental and should evolve.

Must be applied after 2.6.13-rc5-dtck-3.patch and 2.6.13-rc5.

Usage: with kernel compiled with attached patch: "perl timer_top.pl
5", to have refresh time of 5s.
It was resent one day later with some corrections and optimizations.