[PATCH] fix gettimeofday vs. update_gtod race
Nathan Lynch
ntl at pobox.com
Thu Aug 17 10:18:07 EST 2006
Benjamin Herrenschmidt wrote:
> On Fri, 2006-08-11 at 15:41 -0500, Nathan Lynch wrote:
>
> > + /* Sampling the time base must be done after loading
> > + * do_gtod.varp in order to avoid racing with update_gtod.
> > + */
> > + rmb();
> > + tb_ticks = get_tb() - temp_varp->tb_orig_stamp;
>
> The barrier isn't necessary
No? I didn't find anything about mftb having synchronizing
behavior. How should we ensure that temp_varp is assigned before
reading the timebase?
Surely at least a compiler barrier is needed?
> and the race not completely closed imho...
How so? I could've missed something, but I've hammered the patch
pretty hard, fwiw.
> I need to think about it a bit more closely but what about instead
> just check if tb_ticks goes negative, and if yes, just do get_tb()
> again ? That might be faster than having a sync in there and should
> still be correct.
I did try something like that but found that a loop (i.e. multiple
get_tb's to "catch up") was necessary.
More information about the Linuxppc-dev
mailing list