All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Allow lockless traversal of notifier lists
@ 2005-11-28 13:37 Andi Kleen
  2005-11-28 16:01 ` Dipankar Sarma
  0 siblings, 1 reply; 8+ messages in thread
From: Andi Kleen @ 2005-11-28 13:37 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel


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.

That's the first step for fixing all the callers. Some that 
already don't unregister or do it safely are already ok.

Also fixed up the kerneldoc description to document the various
locking restriction.

Signed-off-by: Andi Kleen <ak@suse.de>

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 14:33:20.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;
+	wmb();
 	*list=n;
 	write_unlock(&notifier_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.
  */

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-11-29  6:09 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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.