0
votes

I'm trying to measure the lateny between kernel and userspace, by triggering periodic timer every 1 second, and notifying userspace of the event (using ioctl , and wake_up_interruptible.

For this I created a kernel module which is using hrtimer, and userspace test which is waiting for events. the kernel module is using

in kernel: getnstimeofday(),

and to get the time, and the userspace is using:

in userspace: clock_gettime().

But the amazing thing is that I see that the results timing from userspace and kernel is not synchronized !

1st event:

userspace: 8866[sec] 896197992[nsec] ; kernel: 1388251190[sec] 442706727[nsec]

2nd event:

userspace: 8867[sec] 896151470[nsec] ; kernel: 1388251191[sec] 442690693[nsec]

As you can see kernel and userspace clock is not synchronized, so I can't really measure latency between kernel and userspace events, Right ?

Thank you for any idea, Ran

1

1 Answers

0
votes

From your test result, it seems there is just an "offset" between this 2 APIs, but the delta of these 2 events in sec are correct (1 sec diff).And from the doc http://lxr.free-electrons.com/source/kernel/time/timekeeping.c?v=2.6.37#L101, the kernel time API "calculate the delta since the last update_wall_time". So they are not actually having the same time system. (The user space is get the system timer). I think another way that you can use the Linux kernel called Ftrace to measure this kind of delay.