Logging Events next up previous contents
Next: Using Hardware Performance Counters Up: Klogger Schemata Previous: Event Inheritance   Contents


Logging Events

Logging events is performed using a special C macro called klogger. First, we'll need to include the main Klogger header file:

#include <linux/klogger.h>

The syntax for the klogger macro resembles that of printf, with the first argument being the event name, followed by values for each of the event fields as ordered in the event description. The call for our general event template will thus be:

	klogger(EVENTNAME, varname1, varname2, ... , varnameX);

This call is converted by the C preprocessor into an inlined event specific logging function. However, If the kernel is compiled without Klogger support, this call converts into a null expression by the preprocessor.

Sometimes special code is needed (like using temporary variables) for non-trivial logging. Such code should be protected using an ifdef statement checking the existence of the CONFIG_KLOGGER macro, so it can be eliminated if the Klogger is not configured into the kernel.

Returning to our SCHEDOUT example, the call logging the event will simply be:

	klogger(SCHEDOUT, task->pid);
assuming task is a variable of type struct task_struct* pointing to the process that was just preempted off the CPU.


next up previous contents
Next: Using Hardware Performance Counters Up: Klogger Schemata Previous: Event Inheritance   Contents
Yoav Etsion 2007-09-09