Skip to contentSkip to conversation

core kernel fixes

GIT PULL Ingo Molnar 4 participants 11 messages Oct 5, 2010 – Oct 7, 2010 RCU

lore
Share & tools
lore
#0 lore raw

Linus,

Please pull the latest core-fixes-for-linus git tree from:

git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.git core-fixes-for-linus

Thanks,

Ingo

------------------>
Eric Dumazet (1):
rcu: rcu_read_lock_bh_held(): disabling irqs also disables bh

Heiko Carstens (1):
generic-ipi: Fix deadlock in __smp_call_function_single

 include/linux/rcupdate.h |    2 +-
 kernel/smp.c             |   17 ++++++++++++++---
 2 files changed, 15 insertions(+), 4 deletions(-)
include/linux/rcupdate.h +1 -1
index 9fbc54a..83af1f8 100644
@@ -454,7 +454,7 @@ static inline notrace void rcu_read_unlock_sched_notrace(void)
  * Makes rcu_dereference_check() do the dirty work.
  */
 #define rcu_dereference_bh(p) \
-		rcu_dereference_check(p, rcu_read_lock_bh_held())
+		rcu_dereference_check(p, rcu_read_lock_bh_held() || irqs_disabled())
 
 /**
  * rcu_dereference_sched - fetch RCU-protected pointer, checking for RCU-sched
kernel/smp.c +14 -3
index 75c970c..ed6aacf 100644
@@ -365,9 +365,10 @@ call:
 EXPORT_SYMBOL_GPL(smp_call_function_any);
 
 /**
- * __smp_call_function_single(): Run a function on another CPU
+ * __smp_call_function_single(): Run a function on a specific CPU
  * @cpu: The CPU to run on.
  * @data: Pre-allocated and setup data structure
+ * @wait: If true, wait until function has completed on specified CPU.
  *
  * Like smp_call_function_single(), but allow caller to pass in a
  * pre-allocated data structure. Useful for embedding @data inside
@@ -376,8 +377,10 @@ EXPORT_SYMBOL_GPL(smp_call_function_any);
 void __smp_call_function_single(int cpu, struct call_single_data *data,
 				int wait)
 {
-	csd_lock(data);
+	unsigned int this_cpu;
+	unsigned long flags;
 
+	this_cpu = get_cpu();
 	/*
 	 * Can deadlock when called with interrupts disabled.
 	 * We allow cpu's that are not yet online though, as no one else can
@@ -387,7 +390,15 @@ void __smp_call_function_single(int cpu, struct call_single_data *data,
 	WARN_ON_ONCE(cpu_online(smp_processor_id()) && wait && irqs_disabled()
 		     && !oops_in_progress);
 
-	generic_exec_single(cpu, data, wait);
+	if (cpu == this_cpu) {
+		local_irq_save(flags);
+		data->func(data->info);
+		local_irq_restore(flags);
+	} else {
+		csd_lock(data);
+		generic_exec_single(cpu, data, wait);
+	}
+	put_cpu();
 }
 
 /**
#1 lore raw
Quoted 3 lines · Ingo Molnar

 #define rcu_dereference_bh(p) \
-               rcu_dereference_check(p, rcu_read_lock_bh_held())
+               rcu_dereference_check(p, rcu_read_lock_bh_held() || irqs_disabled())

Wouldn't that irqs_disabled() check have made more sense inside rcu_read_lock_bh_held()?

That's the function that is _supposed_ to check whether bottom halves are disabled, no? So why add a workaround for that function being buggy/incomplete in one place that uses it?

Linus

#2 lore raw
Quoted 11 lines · Linus Torvalds
Quoted 3 lines · Ingo Molnar

 #define rcu_dereference_bh(p) \
-               rcu_dereference_check(p, rcu_read_lock_bh_held())
+               rcu_dereference_check(p, rcu_read_lock_bh_held() || irqs_disabled())

Wouldn't that irqs_disabled() check have made more sense inside rcu_read_lock_bh_held()?

That's the function that is _supposed_ to check whether bottom halves are disabled, no? So why add a workaround for that function being buggy/incomplete in one place that uses it?

Good point!!! If the following diff looks good to you, I will get it tested and pushed.

Thanx, Paul

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

kernel/rcupdate.c +1 -1
index 4d16983..0af1dc7 100644
@@ -86,7 +86,7 @@ int rcu_read_lock_bh_held(void)
 {
 	if (!debug_lockdep_rcu_enabled())
 		return 1;
-	return in_softirq();
+	return in_softirq() || irqs_disabled();
 }
 EXPORT_SYMBOL_GPL(rcu_read_lock_bh_held);
 
#3 lore raw
Quoted 3 lines · Paul E. McKenney

Good point!!!  If the following diff looks good to you, I will get it tested and pushed.

Looks good. Except since I pulled the thing despite my complaint, you'll also need to undo the extra irqs_disabled() test.

Linus

#4 lore raw
Quoted 8 lines · Linus Torvalds
Quoted 3 lines · Paul E. McKenney

Good point!!!  If the following diff looks good to you, I will get it tested and pushed.

Looks good. Except since I pulled the thing despite my complaint, you'll also need to undo the extra irqs_disabled() test.

No problem, the diff I sent you combined two commits. ;-)

Thanx, Paul

#5 lore raw
Quoted 4 lines · Paul E. McKenney
Quoted 3 lines · Linus Torvalds
Quoted 1 line · Paul E. McKenney
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Good point!!! If the following diff looks good to you, I will get it tested and pushed.

Looks good. Except since I pulled the thing despite my complaint, you'll also need to undo the extra irqs_disabled() test.

No problem, the diff I sent you combined two commits. ;-)

Hi Paul & Linus

I originally considered adding the test in rcu_read_lock_bh_held() too, but thought (wrongly) :

"rcu_read_unlock_bh() doesnt block hard IRQ, thus
rcu_read_lock_bh_held() should not test hard irq."

I remember anyway my first patch was wrong, since I was not using irqs_disabled() but in_irq()

http://kerneltrap.org/mailarchive/linux-kernel/2010/9/22/4622784

Thanks !

#6 lore raw
Quoted 19 lines · Eric Dumazet
Quoted 4 lines · Paul E. McKenney
Quoted 3 lines · Linus Torvalds
Quoted 1 line · Paul E. McKenney
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Good point!!! If the following diff looks good to you, I will get it tested and pushed.

Looks good. Except since I pulled the thing despite my complaint, you'll also need to undo the extra irqs_disabled() test.

No problem, the diff I sent you combined two commits. ;-)

Hi Paul & Linus

I originally considered adding the test in rcu_read_lock_bh_held() too, but thought (wrongly) :

Quoted 7 lines

"rcu_read_unlock_bh() doesnt block hard IRQ, thus
rcu_read_lock_bh_held() should not test hard irq."

I remember anyway my first patch was wrong, since I was not using irqs_disabled() but in_irq()

http://kerneltrap.org/mailarchive/linux-kernel/2010/9/22/4622784

Eric,

I believe that history shows that we were all groping around in the dark on this one... Me not least of all. ;-)

Not sure we are completely there yet, but we are at least in a feasible state.

Ingo, I have this queued up at:

git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-2.6-rcu.git rcu/urgent

It passes targeted testing. If Eric is OK with it, it is ready to be pulled. At least as soon as kernel.org gets it out to the mirrors. Commmit 773e3f9357.

Thanx, Paul

#7 lore raw
Quoted 7 lines · Paul E. McKenney

Ingo, I have this queued up at:

git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-2.6-rcu.git rcu/urgent

It passes targeted testing. If Eric is OK with it, it is ready to be pulled. At least as soon as kernel.org gets it out to the mirrors. Commmit 773e3f9357.

Now that the original fix is in Linus's tree, can the followup commits wait until v2.6.37?

Linus, Paul, what's your preference?

Thanks,

Ingo

#8 lore raw
Quoted 7 lines · Ingo Molnar
Quoted 4 lines · Paul E. McKenney

Ingo, I have this queued up at:

git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-2.6-rcu.git rcu/urgent

Quoted 8 lines
Quoted 3 lines

It passes targeted testing. If Eric is OK with it, it is ready to be pulled. At least as soon as kernel.org gets it out to the mirrors. Commmit 773e3f9357.

Now that the original fix is in Linus's tree, can the followup commits wait until v2.6.37?

Linus, Paul, what's your preference?

I am fine either way.

Thanx, Paul

Quoted 3 lines

Thanks,

Ingo

#9 lore raw
Quoted 12 lines · Paul E. McKenney
Quoted 11 lines · Ingo Molnar
Quoted 7 lines · Paul E. McKenney

Ingo, I have this queued up at:

git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-2.6-rcu.git rcu/urgent

It passes targeted testing. If Eric is OK with it, it is ready to be pulled. At least as soon as kernel.org gets it out to the mirrors. Commmit 773e3f9357.

Quoted 6 lines
Quoted 4 lines

Now that the original fix is in Linus's tree, can the followup commits wait until v2.6.37?

Linus, Paul, what's your preference?

I am fine either way.

Ok, Linus released -rc7 which is probably the last -rc so to reduce final-rc code flux i have pulled your fix into tip:core/rcu, for v2.6.37.

Thanks,

Ingo

#10 lore raw
Quoted 18 lines · Ingo Molnar
Quoted 15 lines · Paul E. McKenney
Quoted 14 lines · Ingo Molnar
Quoted 7 lines · Paul E. McKenney

Ingo, I have this queued up at:

git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-2.6-rcu.git rcu/urgent

It passes targeted testing. If Eric is OK with it, it is ready to be pulled. At least as soon as kernel.org gets it out to the mirrors. Commmit 773e3f9357.

Now that the original fix is in Linus's tree, can the followup commits wait until v2.6.37?

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Linus, Paul, what's your preference?

I am fine either way.

Ok, Linus released -rc7 which is probably the last -rc so to reduce final-rc code flux i have pulled your fix into tip:core/rcu, for v2.6.37.

Ah, good, thank you! I am rebasing on top of that. Here is hoping that this approach quiets down the conflict in -next as well. ;-)

Thanx, Paul