next up previous
Next: 3 Measurement Results Up: 2 Downloads Previous: 2.1 swap-sched

2.2 zlog

At the swap-sched sourceforge project page, you can also find a small toy called ``zlog''. Well, I am not sure if it's still true or not, but a few years ago, calling printk within the scheduler code can cause deadlock. Since I work exclusively with CPU schedulers, I chose to write my own kernel logging mechanism, which is ``zlog''.

To use zlog, patch the kernel with the latest zlog patch and configure the kernel with ``CONFIG_ZLOG'' enabled. ``CONFIG_ZLOG'' is available in ``General Setup'' section.

The zlog patch provides the following logging interface to other parts of the kernel:

  1. ztrace_printf(): can be used the same way as printk, but it can be safely used anywhere, including the schedule() code.
  2. ztrace_write(): yes, you can choose to log in binary format
  3. atomic multiple prints: some times, you want to group multiple prints as a "sentence". i.e., you want to print a ``$\backslash n$'' after multiple call to prints at various places. Printk doesn't provide atomic to multiple printks, which means prints from other thread may mess up your prints. zlog can do this. And this is achieved without preventing others from printing in the middle. Check the details on ``zlog.h''.

Besides having a richer interface, zlog also create a separate logging channel for your debugging purpose. Instead of writing the overloaded ``/var/log/messages'', everything you wrote using ``zlog'' interface is wrote to a user space file: ``/tmp/zlog''. So your debugging information will not be messed up with other kernel print outs.

zlog can be compiled as kernel loadable module. When the zlog module is not loaded, calling to zlog functions will do nothing. This enables the developers to dynamically enable/disable kernel logging simply by load/unload zlog module.

Check the patch for the details. It's a simple patch. The patch was generated based on Linux 2.6.12-rc3. But I think it should work fine with any 2.6 kernel.

I believe relayfs is a much more compresentive soluation than zlog. I am not sure of the details. zlog is simple and just enough to me. :-)


next up previous
Next: 3 Measurement Results Up: 2 Downloads Previous: 2.1 swap-sched