From: Chandra Seetharaman <sekharan@us.ibm.com>
To: paulmck@us.ibm.com
Cc: linux-kernel@vger.kernel.org,
Alan Stern <stern@rowland.harvard.edu>,
lse-tech@lists.sourceforge.net
Subject: Re: [Lse-tech] Subject: [RFC][PATCH] Fix for unsafe notifier chain mechanism
Date: Fri, 11 Nov 2005 18:30:42 -0800 [thread overview]
Message-ID: <1131762642.14041.151.camel@linuxchandra> (raw)
In-Reply-To: <20051112014421.GH1289@us.ibm.com>
On Fri, 2005-11-11 at 17:44 -0800, Paul E. McKenney wrote:
Thanks for the comments Paul.
> > + rcu_assign_pointer(n->next, *nl);
>
> The above can simply be "n->next = *nl;". The reason is that this change
> of state is not visible to RCU readers until after the following statement,
> and it therefore need not be an RCU-reader-safe assignment. You only need
> to use rcu_assign_pointer() when the results of the assignment are
> immediately visible to RCU readers.
will do.
>
> > + rcu_assign_pointer(*nl, n);
> > + up_write(&nh->rwsem);
> > + if (nh->type == ATOMIC_NOTIFIER)
> > + synchronize_rcu();
>
> This "if" statement and the "synchronize_rcu()" are not needed. Nothing
> has been removed from the list, so nothing will be freed, so no need to
> wait for readers to get done.
>
> In contrast, the synchronize_rcu() in notifier_chain_unregister() -is-
> needed, since we need to free the removed element.
will do
> > + if (nh->type == ATOMIC_NOTIFIER)
> > + rcu_read_lock();
> > + else
> > + down_read(&nh->rwsem);
>
> Is it possible for the value of nh->type to change? If so, there needs
> to be some additional mechanism to guard against such a change. However,
> if this field is constant, this code is just fine as is.
No, it is not supposed to change.
--
----------------------------------------------------------------------
Chandra Seetharaman | Be careful what you choose....
- sekharan@us.ibm.com | .......you may get it.
----------------------------------------------------------------------
next prev parent reply other threads:[~2005-11-12 2:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-11 23:43 Subject: [RFC][PATCH] Fix for unsafe notifier chain mechanism Chandra Seetharaman
2005-11-12 1:44 ` [Lse-tech] " Paul E. McKenney
2005-11-12 2:30 ` Chandra Seetharaman [this message]
2005-11-12 2:36 ` Alan Stern
2005-11-12 5:22 ` Paul E. McKenney
2005-11-12 15:35 ` Alan Stern
2005-11-12 19:28 ` Paul E. McKenney
2005-11-12 21:01 ` Alan Stern
2005-11-12 22:38 ` Paul E. McKenney
2005-11-13 16:47 ` Alan Stern
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=1131762642.14041.151.camel@linuxchandra \
--to=sekharan@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lse-tech@lists.sourceforge.net \
--cc=paulmck@us.ibm.com \
--cc=stern@rowland.harvard.edu \
/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