From: Andi Kleen <ak@suse.de>
To: Dipankar Sarma <dipankar@in.ibm.com>
Cc: Andi Kleen <ak@suse.de>, akpm@osdl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Allow lockless traversal of notifier lists
Date: Mon, 28 Nov 2005 17:05:47 +0100 [thread overview]
Message-ID: <20051128160547.GA20775@brahms.suse.de> (raw)
In-Reply-To: <20051128160129.GA8478@in.ibm.com>
On Mon, Nov 28, 2005 at 09:31:29PM +0530, Dipankar Sarma wrote:
> On Mon, Nov 28, 2005 at 02:37:57PM +0100, Andi Kleen wrote:
> >
> > *
> > * Currently always returns zero.
> > */
> > @@ -116,6 +119,7 @@
> > list= &((*list)->next);
> > }
> > n->next = *list;
> > + wmb();
> > *list=n;
> > write_unlock(¬ifier_lock);
>
> Shouldn't this be smp_wmb() ?
Yes.
>
> Also, not all archs have strong ordering for data dependent reads.
Ah you mean the Alpha exception? Right Alpha would need that.
Thanks for the review.
-Andi
Revised patch with Alphaextrawurst.
----
As discussed in other thread.
Just needed an additional write barrier, so that a parallel
running lockup can never see inconsistent state. As long as there
is no unregistration or the unregistration is done using
locking or RCU in the caller they should be ok now.
This only makes a difference on non i386/x86-64 architectures.
x86 was already ok because it never reorders writes.
diff -u linux-2.6.15rc2-work/kernel/sys.c-o linux-2.6.15rc2-work/kernel/sys.c
--- linux-2.6.15rc2-work/kernel/sys.c-o 2005-11-16 00:34:33.000000000 +0100
+++ linux-2.6.15rc2-work/kernel/sys.c 2005-11-28 17:03:22.000000000 +0100
@@ -102,6 +102,9 @@
* @n: New entry in notifier chain
*
* Adds a notifier to a notifier chain.
+ * As long as unregister is not used this is safe against parallel
+ * lockless notifier lookups. If unregister is used then unregister
+ * needs to do additional locking or use RCU.
*
* Currently always returns zero.
*/
@@ -116,6 +119,7 @@
list= &((*list)->next);
}
n->next = *list;
+ smp_wmb();
*list=n;
write_unlock(¬ifier_lock);
return 0;
@@ -129,6 +133,8 @@
* @n: New entry in notifier chain
*
* Removes a notifier from a notifier chain.
+ * Note this needs additional locking or RCU in the caller to be safe
+ * against parallel traversals.
*
* Returns zero on success, or %-ENOENT on failure.
*/
@@ -175,6 +181,7 @@
while(nb)
{
+ smp_read_barrier_depends();
ret=nb->notifier_call(nb,val,v);
if(ret&NOTIFY_STOP_MASK)
{
next prev parent reply other threads:[~2005-11-28 16:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-28 13:37 [PATCH] Allow lockless traversal of notifier lists Andi Kleen
2005-11-28 16:01 ` Dipankar Sarma
2005-11-28 16:05 ` Andi Kleen [this message]
2005-11-28 16:17 ` Dipankar Sarma
2005-11-28 16:27 ` Andi Kleen
2005-11-28 17:42 ` Dipankar Sarma
2005-11-29 0:01 ` Andi Kleen
2005-11-29 6:11 ` Dipankar Sarma
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=20051128160547.GA20775@brahms.suse.de \
--to=ak@suse.de \
--cc=akpm@osdl.org \
--cc=dipankar@in.ibm.com \
--cc=linux-kernel@vger.kernel.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 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.