All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@linux.ibm.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>,
	Dmitry Vyukov <dvyukov@google.com>,
	Andrea Parri <andrea.parri@amarulasolutions.com>,
	Alan Stern <stern@rowland.harvard.edu>,
	Eric Dumazet <edumazet@google.com>,
	David Miller <davem@davemloft.net>,
	netdev <netdev@vger.kernel.org>,
	syzbot <syzkaller@googlegroups.com>
Subject: Re: [PATCH] inet: frags: Remove unnecessary smp_store_release/READ_ONCE
Date: Fri, 31 May 2019 10:11:35 -0700	[thread overview]
Message-ID: <20190531171135.GM28207@linux.ibm.com> (raw)
In-Reply-To: <4e2f7f20-5b7f-131f-4d8b-09cfc6e087d4@gmail.com>

On Fri, May 31, 2019 at 08:45:47AM -0700, Eric Dumazet wrote:
> 
> 
> On 5/31/19 7:45 AM, Herbert Xu wrote:
> > On Fri, May 31, 2019 at 10:24:08AM +0200, Dmitry Vyukov wrote:
> >>
> >> OK, let's call it barrier. But we need more than a barrier here then.
> > 
> > READ_ONCE/WRITE_ONCE is not some magical dust that you sprinkle
> > around in your code to make it work without locks.  You need to
> > understand exactly why you need them and why the code would be
> > buggy if you don't use them.
> > 
> > In this case the code doesn't need them because an implicit
> > barrier() (which is *stronger* than READ_ONCE/WRITE_ONCE) already
> > exists in both places.
> >
> 
> More over, adding READ_ONCE() while not really needed prevents some compiler
> optimizations.
> 
> ( Not in this particular case, since fqdir->dead is read exactly once, but we could
> have had a loop )
> 
> I have already explained that the READ_ONCE() was a leftover of the first version
> of the patch, that I refined later, adding correct (and slightly more complex) RCU
> barriers and rules.
> 
> Dmitry, the self-documentation argument is perfectly good, but Herbert
> put much nicer ad hoc comments.

I don't see all the code, but let me see if I understand based on the
pieces that I do see...

o	fqdir_exit() does a store-release to ->dead, then arranges
	for fqdir_rwork_fn() to be called from workqueue context
	after a grace period has elapsed.

o	If inet_frag_kill() is invoked only from fqdir_rwork_fn(),
	and if they are using the same fqdir, then inet_frag_kill()
	would always see fqdir->dead==true.

	But then it would not be necessary to check it, so this seems
	unlikely.

o	If fqdir_exit() does store-releases to a number of ->dead
	fields under rcu_read_lock(), and if the next fqdir_exit()
	won't happen until after all the callbacks complete
	(combination of flushing workqueues and rcu_barrier(), for
	example), then ->dead would be stable when inet_frag_kill()
	is invoked, and might be true or not.  (This again requires
	inet_frag_kill() be only invoked from fqdir_rwork_fn().)

So I can imagine cases where this would in fact work.  But did I get
it right or is something else happening?

							Thanx, Paul


  parent reply	other threads:[~2019-05-31 17:11 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-24 16:03 [PATCH net-next 00/11] inet: frags: avoid possible races at netns dismantle Eric Dumazet
2019-05-24 16:03 ` [PATCH net-next 01/11] inet: rename netns_frags to fqdir Eric Dumazet
2019-05-24 16:03 ` [PATCH net-next 02/11] net: rename inet_frags_exit_net() to fqdir_exit() Eric Dumazet
2019-05-24 16:03 ` [PATCH net-next 03/11] net: rename struct fqdir fields Eric Dumazet
2019-05-24 16:03 ` [PATCH net-next 04/11] ipv4: no longer reference init_net in ip4_frags_ns_ctl_table[] Eric Dumazet
2019-05-24 16:03 ` [PATCH net-next 05/11] ipv6: no longer reference init_net in ip6_frags_ns_ctl_table[] Eric Dumazet
2019-05-24 16:03 ` [PATCH net-next 06/11] netfilter: ipv6: nf_defrag: no longer reference init_net in nf_ct_frag6_sysctl_table Eric Dumazet
2019-05-24 16:03 ` [PATCH net-next 07/11] ieee820154: 6lowpan: no longer reference init_net in lowpan_frags_ns_ctl_table Eric Dumazet
2019-05-24 16:03 ` [PATCH net-next 08/11] net: rename inet_frags_init_net() to fdir_init() Eric Dumazet
2019-05-24 16:03 ` [PATCH net-next 09/11] net: add a net pointer to struct fqdir Eric Dumazet
2019-05-24 16:03 ` [PATCH net-next 10/11] net: dynamically allocate fqdir structures Eric Dumazet
2019-05-24 16:03 ` [PATCH net-next 11/11] inet: frags: rework rhashtable dismantle Eric Dumazet
2019-05-28  6:34   ` Herbert Xu
2019-05-28 13:31     ` Eric Dumazet
2019-05-29  5:40       ` [PATCH] inet: frags: Remove unnecessary smp_store_release/READ_ONCE Herbert Xu
2019-05-29  5:43         ` Dmitry Vyukov
2019-05-29  5:47           ` Herbert Xu
2019-05-31  8:24             ` Dmitry Vyukov
2019-05-31 14:45               ` Herbert Xu
2019-05-31 15:45                 ` Eric Dumazet
2019-05-31 16:29                   ` Andrea Parri
2019-05-31 17:11                     ` Eric Dumazet
2019-06-07 12:06                       ` Dmitry Vyukov
2019-05-31 17:11                   ` Paul E. McKenney [this message]
2019-05-31 17:18                     ` Eric Dumazet
2019-05-29 21:30         ` Eric Dumazet
2019-05-30 18:51         ` David Miller
2019-05-26 21:26 ` [PATCH net-next 00/11] inet: frags: avoid possible races at netns dismantle David Miller

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=20190531171135.GM28207@linux.ibm.com \
    --to=paulmck@linux.ibm.com \
    --cc=andrea.parri@amarulasolutions.com \
    --cc=davem@davemloft.net \
    --cc=dvyukov@google.com \
    --cc=edumazet@google.com \
    --cc=eric.dumazet@gmail.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=netdev@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    --cc=syzkaller@googlegroups.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.