lkml.org 
[lkml]   [2021]   [Jul]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH memory-model 2/4] tools/memory-model: Add example for heuristic lockless reads
On Fri, Jul 23, 2021 at 09:24:31AM -0700, Paul E. McKenney wrote:
> On Thu, Jul 22, 2021 at 10:08:46PM -0400, Alan Stern wrote:

> > > + void do_something_locked(struct foo *fp)
> > > + {
> > > + bool gf = true;
> > > +
> > > + /* IMPORTANT: Heuristic plus spin_lock()! */
> > > + if (!data_race(global_flag)) {
> > > + spin_lock(&fp->f_lock);
> > > + if (!smp_load_acquire(&global_flag)) {

> > > + void begin_global(void)
> > > + {
> > > + int i;
> > > +
> > > + spin_lock(&global_lock);
> > > + WRITE_ONCE(global_flag, true);
> >
> > Why does this need to be WRITE_ONCE? It still races with the first read
> > of global_flag above.
>
> But also with the smp_load_acquire() of global_flag, right?

What I'm curious about is why, given these two races, you notate one of
them by changing a normal write to WRITE_ONCE and you notate the other
by changing a normal read to a data_race() read. Why not handle them
both the same way?

Alan

\
 
 \ /
  Last update: 2021-07-23 19:00    [W:1.065 / U:0.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site