Re: [patch 54/55] timekeeping: Provide fast and NMI safe access to CLOCK_MONOTONIC[_RAW]
From: Thomas Gleixner
Date: Sat Jul 12 2014 - 15:31:52 EST
On Sat, 12 Jul 2014, Mathieu Desnoyers wrote:
> ----- Original Message -----
> > From: "Thomas Gleixner" <tglx@xxxxxxxxxxxxx>
> > On Fri, 11 Jul 2014, Mathieu Desnoyers wrote:
> > > Any reason why the updater wouldn't do:
> > >
> > > tkf->seq++;
> > > smp_wmb();
> > > update(tkf->base[1 - (tkf->seq & 0x01)], tk);
> > >
> > > instead of updating both array entries each time ?
> >
> > base[0]; <- Current active
> > seq++; -> Makes base[1] the active one for readers
> > update(base[0]);
> >
> > So readers are always one update cycle behind. Probably not an issue
> > most of the time, but think about fast wrapping clocksources and
> > NOHZ....
>
> Ah, yep, got it.
>
> So instead of calling update() twice per update, could we do
> the following instead ?
>
> tkf->seq++;
> smp_wmb();
> update(tkf->base[0], tk);
> tkf->seq++;
> smp_wmb();
> memcpy(tkf->base[1], tkf->base[0], sizeof(tkf->base[1]);
>
> just in case "update" would happen to be expensive for
> some clock implementation.
Sure, same end result ...
Thanks,
tglx
--
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/