Re: [Patch] Re: Nasty suprise with uptime

From: Tim Schmielau (tim@physik3.uni-rostock.de)
Date: Wed Oct 31 2001 - 14:26:16 EST


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

The expensive code in the timer interupt will be executed every
497.1 days, so that's bearable.

> Race will be handled by readers of 64bit jiffy. There won't be many of them.
>
> > > + /* 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
>
> Inline! Inline! Don't use macro unless you must!
>
> // extern or static? which is correct?
> // I see both types in kernel .h :-(
> extern inline u64 get_jiffies64() {
> unsigned long hi,lo;
> do {
> hi = jiffies_hi;
> barrier();
> lo = jiffies;
> barrier();
> } while (hi != jiffies_hi);
> return lo + (((u64)hi) << 32);
> }

should be
        return lo + (((u64)hi) << BITS_PER_LONG);
to not break 64 bit platforms.

Admittedly, I broke 64 bit myself by submitting a wrong version of my
patch. The condition
        if (jiffies != 0xffffffffUL) {
                jiffies++;
in do_timer needs to be
        if (jiffies != (unsigned long)-1) {
                jiffies++;

>
> And guys, why you don't comment on my hand-crafted asm version of
> union { u32 jiffies; u64 jiffies64; }; ? Is it flawed?
> --
> vda
>

I believe not, but it is platform-specific.

Tim

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed Oct 31 2001 - 21:00:45 EST