Timing Measurements of Linux kernel routine
I added some additional code to the Linux kernel (the scheduler) and now I would like to know what is the impact of this modification.
For user processes I always used:
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, ...);
Now I am wondering if there is a kernel-equivalent routine that I could use to do something similar.
Many thanks for your assistance,开发者_JAVA百科 Martin
Take a look at ftrace. Latencytop is based on that. There are good articles at lwn (here, here, and here)
Measuring scheduler performance is notoriously hard, so good luck :)
unsigned long long native_sched_clock(void);
from asm/timer.h
for x86
unsigned long long sched_clock(void);
from linux/sched.h
for any arch
They are wrappers around rdtsc
- tick counter reader.
upd.
there is also linux/clocksource.h
timecounter_init - initialize a time counter
timecounter_read - return nanoseconds elapsed since timecounter_init()
精彩评论