[PATCH] fix bad delta time values in /proc/timer_list

From: Shaffer, Scott
Date: Mon Jan 17 2011 - 15:25:53 EST


elapsed times printed from /proc/timer_list are incorrect for the
CLOCK_REALTIME timer list.

print_timer() is passed monotonic nsecs as current time, but should
be passed monotonic nsecs + hrtimer_clock_base.offset for the
timer list it is printing.

This patch fixes CLOCK_REALTIME timer lists, and does not break
CLOCK_MONOTONIC timer lists.


This shows a thread's timer that is <10ms:

xunil2.ccur.com # grep -A 9 "cpu: 1" /proc/timer_list
cpu: 1
clock 0:
.base: f67031d0
.index: 0
.resolution: 1 nsecs
.get_time: ktime_get_real
.offset: 1294953310697580572 nsecs
active timers:
#0: <f518ff3c>, hrtimer_wakeup, S:01, hrtimer_start_range_ns, pthread_sleep2/7067
# expires at 1295021767185712301-1295021767185712301 nsecs [in 1294953310698070434 to 1294953310698070434 nsecs]


With the patch below, that thread's timer looks like:

#0: <f37d7f3c>, hrtimer_wakeup, S:01, hrtimer_start_range_ns, pthread_sleep2/9403
# expires at 1295022944770566772-1295022944770566772 nsecs [in 5305914 to 5305914 nsecs]


Signed-off-by: Scott Shaffer <scott.shaffer@xxxxxxxx>

--- a/kernel/time/timer_list.c 2011-01-04 19:50:19.000000000 -0500
+++ b/kernel/time/timer_list.c 2011-01-14 14:09:03.000000000 -0500
@@ -102,7 +102,8 @@ next_one:
tmp = *timer;
raw_spin_unlock_irqrestore(&base->cpu_base->lock, flags);

- print_timer(m, timer, &tmp, i, now);
+ print_timer(m, timer, &tmp, i,
+ (now + ktime_to_ns(base->offset)));
next++;
goto next_one;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/