Re: [Patch] Re: Nasty suprise with uptime

Andreas Dilger
2001-10-31T18:41:12Z

On Oct 31, 2001 19:16 +0100, Tim Schmielau wrote:
> The idea was that all drivers that use the 32 bit jiffies counter have to
> be aware of the wraparound anyways, and won't see a difference.

Agreed. I also like the change that you initialize jiffies to a pre-wrap
value, so the jiffies wrap bugs can more easily be found/fixed.

> The race only happens for 64 bit accesses to jiffies, but hey, without
> the patch these values come out wrong _every_ time, so I believed a
> tiny window for a single wrong display of uptime every 497.1 days to be
> acceptable.

I would say that the race is so rare that it should not be handled, especially
since it adds extra code in the timer interrupt.

> + /* We need to make sure jiffies_high does not change while
> + * reading jiffies and jiffies_high */
> + do {
> + jiffies_high_tmp = jiffies_high_shadow;
> + barrier();
> + jiffies_tmp = jiffies;
> + barrier();
> + } while (jiffies_high != jiffies_high_tmp);

Maybe this could be condensed into a macro/inline, so that people don't
screw it up (and it looks cleaner). Like get_jiffies64() or so, for
those few places that really care about the full value and can't stand
a miniscule chance of a race (i.e. uptime output is not a candidate).

Cheers, Andreas
--
Andreas Dilger