linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Vyukov <dvyukov@google.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Florian Westphal <fw@strlen.de>,
	Anatol Pomozov <anatol.pomozov@gmail.com>,
	"Paul E. McKenney" <paulmck@linux.ibm.com>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: seqcount usage in xt_replace_table()
Date: Thu, 10 Jan 2019 13:53:28 +0100	[thread overview]
Message-ID: <CACT4Y+YZ-bOFM_vHN5GiE5Yh=qqGjO_cgsJD4cnNyupOd6-A-Q@mail.gmail.com> (raw)
In-Reply-To: <20190110124123.GA21224@hirez.programming.kicks-ass.net>

On Thu, Jan 10, 2019 at 1:41 PM Peter Zijlstra <peterz@infradead.org> wrote:
>
> On Tue, Jan 08, 2019 at 11:37:46PM +0100, Florian Westphal wrote:
> > Anatol Pomozov <anatol.pomozov@gmail.com> wrote:
> > > Or maybe xt_replace_table() can be enhanced? When I hear that
> > > something waits until an event happens on all CPUs I think about
> > > wait_event() function. Would it be better for xt_replace_table() to
> > > introduce an atomic counter that is decremented by CPUs, and the main
> > > CPU waits until the counter gets zero?
> >
> > That would mean placing an additional atomic op into the
> > iptables evaluation path (ipt_do_table and friends).
> >
>
> For:
>
>         /*
>          * 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.

Do we want WRITE_ONCE here then?
We want it to be compiled to an actual memory access and then it's up
to hardware to make it visible to other CPUs.
smp_wmb should most likely have this as a side effect too, but
somewhat indirect.
Also race-detector-friendly.


> > Only alternative I see that might work is synchronize_rcu (the
> > _do_table functions are called with rcu read lock held).
> >
> > I guess current scheme is cheaper though.
>
> Is performance a concern in this path? There is no comment justifying
> this 'creative' stuff.
>

  reply	other threads:[~2019-01-10 12:53 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-08 19:33 seqcount usage in xt_replace_table() Anatol Pomozov
2019-01-08 22:37 ` Florian Westphal
2019-01-10 12:41   ` Peter Zijlstra
2019-01-10 12:53     ` Dmitry Vyukov [this message]
2019-01-10 20:18       ` Peter Zijlstra
2019-01-10 14:48     ` Florian Westphal
2019-01-10 20:20       ` Peter Zijlstra
2019-01-10 20:25       ` Peter Zijlstra
2019-01-10 22:29         ` Florian Westphal
2019-01-11  8:34           ` Peter Zijlstra
2019-01-11 14:08             ` Paul E. McKenney
2019-01-10 14:52     ` Paul E. McKenney
2019-01-09  0:02 ` Andrea Parri
2019-01-09  0:36   ` Anatol Pomozov
2019-01-09  5:35     ` Dmitry Vyukov
2019-01-09 11:24     ` Andrea Parri
2019-01-09 11:55       ` Dmitry Vyukov
2019-01-09 12:11         ` Andrea Parri
2019-01-09 12:29           ` Dmitry Vyukov
2019-01-09 17:10             ` Paul E. McKenney
2019-01-10  8:49               ` Dmitry Vyukov
2019-01-10 12:30                 ` Andrea Parri
2019-01-10 12:38                   ` Dmitry Vyukov
2019-01-10 12:46                     ` Andrea Parri
2019-01-10 13:25                       ` Dmitry Vyukov
2019-01-10 14:50                     ` Paul E. McKenney
2019-01-10 12:44 ` Peter Zijlstra
2019-01-10 12:54   ` Dmitry Vyukov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CACT4Y+YZ-bOFM_vHN5GiE5Yh=qqGjO_cgsJD4cnNyupOd6-A-Q@mail.gmail.com' \
    --to=dvyukov@google.com \
    --cc=anatol.pomozov@gmail.com \
    --cc=fw@strlen.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulmck@linux.ibm.com \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).