Re: 2.6.39-rc6-mmotm0506 - lockdep splat in RCU code on page fault

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, May 10, 2011 at 10:57:46AM +0200, Ingo Molnar wrote:
> 
> * Paul E. McKenney <paulmck@xxxxxxxxxxxxxxxxxx> wrote:
> 
> > -	raw_spin_lock_irqsave(&rnp->lock, flags);
> > -	rnp->wakemask |= rdp->grpmask;
> > -	raw_spin_unlock_irqrestore(&rnp->lock, flags);
> > +	do {
> > +		old = rnp->wakemask;
> > +		new = old | rdp->grpmask;
> > +	} while (cmpxchg(&rnp->wakemask, old, new) != old);
> 
> Hm, isnt this an inferior version of atomic_or_long() in essence?
> 
> Note that atomic_or_long() is x86 only, so a generic one would have to be 
> offered too i suspect, atomic_cmpxchg() driven or so - which would look like 
> the above loop.
> 
> Most architectures could offer atomic_or_long() i suspect.

Is the following what you had in mind?  This (untested) patch provides
only the generic function: if this is what you had in mind, I can put
together optimized versions for a couple of the architectures.

							Thanx, Paul

------------------------------------------------------------------------

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index cc6c53a..e7c2e69 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -171,6 +171,9 @@ config ARCH_HAS_DEFAULT_IDLE
 config ARCH_HAS_CACHE_LINE_SIZE
 	def_bool y
 
+config ARCH_HAS_ATOMIC_OR_LONG
+	def_bool X86_64
+
 config HAVE_SETUP_PER_CPU_AREA
 	def_bool y
 
diff --git a/include/linux/atomic.h b/include/linux/atomic.h
index 96c038e..2fc3222 100644
--- a/include/linux/atomic.h
+++ b/include/linux/atomic.h
@@ -34,4 +34,17 @@ static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
 }
 #endif
 
+#ifndef CONFIG_ARCH_HAS_ATOMIC_OR_LONG
+static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
+{
+	unsigned long old;
+	unsigned long new;
+
+	do {
+		old = ACCESS_ONCE(*v1);
+		new = old | v2;
+	} while (cmpxchg(v1, old, new) != old);
+}
+#endif /* #ifndef CONFIG_ARCH_HAS_ATOMIC_OR_LONG */
+
 #endif /* _LINUX_ATOMIC_H */
diff --git a/kernel/rcutree.c b/kernel/rcutree.c
index 20c22c5..86f44a3 100644
--- a/kernel/rcutree.c
+++ b/kernel/rcutree.c
@@ -36,7 +36,7 @@
 #include <linux/interrupt.h>
 #include <linux/sched.h>
 #include <linux/nmi.h>
-#include <asm/atomic.h>
+#include <linux/atomic.h>
 #include <linux/bitops.h>
 #include <linux/module.h>
 #include <linux/completion.h>
@@ -1525,15 +1525,10 @@ static void rcu_cpu_kthread_setrt(int cpu, int to_rt)
  */
 static void rcu_cpu_kthread_timer(unsigned long arg)
 {
-	unsigned long old;
-	unsigned long new;
 	struct rcu_data *rdp = per_cpu_ptr(rcu_state->rda, arg);
 	struct rcu_node *rnp = rdp->mynode;
 
-	do {
-		old = rnp->wakemask;
-		new = old | rdp->grpmask;
-	} while (cmpxchg(&rnp->wakemask, old, new) != old);
+	atomic_or_long(&rnp->wakemask, rdp->grpmask);
 	invoke_rcu_node_kthread(rnp);
 }
 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxxx  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]