public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* CPU ordering with respect to krefs
@ 2007-04-02 12:47 Oliver Neukum
  2007-04-02 14:33 ` Eric Dumazet
  0 siblings, 1 reply; 4+ messages in thread
From: Oliver Neukum @ 2007-04-02 12:47 UTC (permalink / raw)
  To: Greg KH, linux-kernel

Hi,

some atomic operations are only atomic, not ordered. Thus a CPU is allowed
to reorder memory references to an object to before the reference is
obtained. This fixes it.

	Regards
		Oliver
Signed-off-by: Oliver Neukum <oneukum@suse.de>
------

--- a/lib/kref.c	2007-04-02 14:40:40.000000000 +0200
+++ b/lib/kref.c	2007-04-02 14:40:50.000000000 +0200
@@ -21,6 +21,7 @@
 void kref_init(struct kref *kref)
 {
 	atomic_set(&kref->refcount,1);
+	smp_mb();
 }
 
 /**
@@ -31,6 +32,7 @@
 {
 	WARN_ON(!atomic_read(&kref->refcount));
 	atomic_inc(&kref->refcount);
+	smp_mb__after_atomic_inc();
 }
 
 /**

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

end of thread, other threads:[~2007-04-17  5:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-02 12:47 CPU ordering with respect to krefs Oliver Neukum
2007-04-02 14:33 ` Eric Dumazet
2007-04-12  6:27   ` Greg KH
2007-04-17  5:44     ` Oliver Neukum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox