Martin
Martin

Reputation: 41

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, Martin

Upvotes: 4

Views: 699

Answers (2)

osgx
osgx

Reputation: 94165

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()

Upvotes: 2

amarillion
amarillion

Reputation: 24907

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 :)

Upvotes: 4

Related Questions