Re: [PATCH 1/2] Introduce clocksource_forward_now

From: Andrew Morton
Date: Thu Apr 03 2008 - 17:23:25 EST


On Wed, 2 Apr 2008 13:39:43 +0200 (CEST)
Roman Zippel <zippel@xxxxxxxxxxxxxx> wrote:

> Hi,
>
> On Tue, 18 Mar 2008, john stultz wrote:
>
> > My solution is to introduce CLOCK_MONOTONIC_RAW. This exposes a
> > nanosecond based time value, that increments starting at bootup and has
> > no frequency adjustments made to it what so ever.
>
> There is a problem with the time offset since the last update_wall_time()
> call, which isn't taken into account when switching clocks (possibly
> during suspend/resume too), so that the clock might jump back during a
> clock switch.
> To avoid making the whole more complex it's better to do small cleanup
> first, so this patch introduces clocksource_forward_now() which takes care
> of this offset since the last update_wall_time() call and adds it to the
> clock, so there is no need anymore to deal with it explicitly.
> This is also gets rid of the timekeeping_suspend_nsecs hack, instead of
> waiting until resume, the value is accumulated during suspend. In the end
> there is only a single user of __get_nsec_offset() left, so I integrated
> it back to getnstimeofday().
>

It's unclear what tree this was agaisnt, but it was the wrong one.

> --- linux-2.6.orig/kernel/time/timekeeping.c
> +++ linux-2.6/kernel/time/timekeeping.c

Hopefully these changes will work when mixed with the pending 2.6.26
changes, but nobody yet knows.

> @@ -459,10 +452,10 @@ void update_wall_time(void)
> */
> while (offset >= clock->cycle_interval) {
> /* accumulate one interval */
> - clock->xtime_nsec += clock->xtime_interval;
> - clock->cycle_last += clock->cycle_interval;
> offset -= clock->cycle_interval;
> + clock->cycle_last += clock->cycle_interval;
>
> + clock->xtime_nsec += clock->xtime_interval;
> if (clock->xtime_nsec >= (u64)NSEC_PER_SEC << clock->shift) {
> clock->xtime_nsec -= (u64)NSEC_PER_SEC << clock->shift;
> xtime.tv_sec++;

This do-nothing change conflited with
clocksource-introduce-clock_monotonic_raw.patch (and fixes). Please check
that the result is OK (ie: clocksource.raw_snsec ddd not need any changes)


--
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/