lkml.org 
[lkml]   [2019]   [Jan]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: seqcount usage in xt_replace_table()
On Thu, Jan 10, 2019 at 03:48:12PM +0100, Florian Westphal wrote:
> Peter Zijlstra <peterz@infradead.org> wrote:
> > /*
> > * Ensure contents of newinfo are visible before assigning to
> > * private.
> > */
> > smp_wmb();
> > table->private = newinfo;
> >
> > we have:
> >
> > smp_store_release(&table->private, newinfo);
> >
> > But what store does that second smp_wmb() order against? The comment:
> >
> > /* make sure all cpus see new ->private value */
> > smp_wmb();
> >
> > makes no sense what so ever, no smp_*() barrier can provide such
> > guarantees.
>
> IIRC I added this at the request of a reviewer of an earlier iteration
> of that patch.
>
> IIRC the concern was that compiler/hw could re-order
>
> smb_wmb();
> table->private = newinfo;
> /* wait until all cpus are done with old table */
>
> into:
>
> smb_wmb();
> /* wait until all cpus are done with old table */
> ...
> table->private = newinfo;
>
> and that (obviously) makes the wait-loop useless.

The thing is, the 'wait for all cpus' thing is pure loads, not stores,
so smp_wmb() is a complete NOP there.

If you want to ensure those loads happen after that store (which does
indeed seem like a sensible thing), you're going to have to use
smp_mb().

\
 
 \ /
  Last update: 2019-01-10 21:21    [W:0.093 / U:0.356 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site