Skip to contentSkip to conversation

rcu: Extended quiescent state for adaptive nohz

PATCH In review [email protected] 2 participants 18 messages Jun 4, 2012 – Jun 11, 2012 RCU

lore
Share & tools
lore
#0 lore raw

cover rcu: Extended quiescent state for adaptive nohz

From: Frederic Weisbecker <[email protected]>

Paul, Ingo,

This is a rebase of the nohz cpusets RCU APIs on top of Paul's latest -rcu (rcu/core) branch.

I have only built tested it yet, I need to do a full rebase of my tree to test it in practice. But I wanted to show you how it looks like first.

I also wonder if we can set that to a tree somewhere. Ingo suggested to set up a tree on -tip to apply the uncontroversial part of nohz cpusets patches and iterate from there. I think it would accelerate everything if we start doing that.

Tell me what you think.

Thanks.

Frederic Weisbecker (2):
rcu: New rcu_user_enter() and rcu_user_exit() APIs
rcu: New rcu_user_enter_irq() and rcu_user_exit_irq() APIs

 include/linux/rcupdate.h |    4 +
 kernel/rcutree.c         |  184 +++++++++++++++++++++++++++++++++++++++------
 2 files changed, 163 insertions(+), 25 deletions(-)
Signature · 1 line
1.7.5.4
#1 lore raw

PATCH 1/2 rcu: New rcu_user_enter() and rcu_user_exit() APIs

From: Frederic Weisbecker <[email protected]>

These two APIs are provided to help the implementation of an adaptive tickless kernel (cf: nohz cpusets). We need to run into RCU extended quiescent state when we are in userland so that a tickless CPU is not involved in the global RCU state machine and can shutdown its tick safely.

These APIs are called from syscall and exception entry/exit points and can't be called from interrupt.

They are essentially the same than rcu_idle_enter() and rcu_idle_exit() minus the checks that ensure the CPU is running the idle task.

Cc Alessio Igor Bogani <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Avi Kivity <[email protected]>
Cc Chris Metcalf <[email protected]>
Cc Christoph Lameter <[email protected]>
Cc Daniel Lezcano <[email protected]>
Cc Geoff Levand <[email protected]>
Cc Gilad Ben Yossef <[email protected]>
Cc Hakan Akkan <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Max Krasnyansky <[email protected]>
Cc Paul E. McKenney <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Stephen Hemminger <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Sven-Thorsten Dietrich <[email protected]>
Cc Thomas Gleixner <[email protected]>
---
 include/linux/rcupdate.h |    2 +
 kernel/rcutree.c         |  135 +++++++++++++++++++++++++++++++++++++---------
 2 files changed, 112 insertions(+), 25 deletions(-)
include/linux/rcupdate.h +2 -0
index b737a5b..e8323df 100644
@@ -191,6 +191,8 @@ extern void rcu_idle_enter(void);
 extern void rcu_idle_exit(void);
 extern void rcu_irq_enter(void);
 extern void rcu_irq_exit(void);
+extern void rcu_user_enter(void);
+extern void rcu_user_exit(void);
 extern void exit_rcu(void);
 
 /**
kernel/rcutree.c +110 -25

198 lines not on this page · raw message

Signature · 1 line
1.7.5.4
#2 lore raw

PATCH 2/2 rcu: New rcu_user_enter_irq() and rcu_user_exit_irq() APIs

In reply to [email protected]

From: Frederic Weisbecker <[email protected]>

A CPU running in adaptive tickless mode wants to enter into RCU extended quiescent state while running in userspace. This way we can shut down the tick that is usually needed on each CPU for the needs of RCU.

Typically, RCU enters the extended quiescent state when we resume to userspace through a syscall or exception exit, this is done using rcu_user_enter(). Then RCU exit this state by calling rcu_user_exit() from syscall or exception entry.

However there are two other points where we may want to enter or exit this state. Some remote CPU may require a tickless CPU to restart its tick for any reason and send it an IPI for this purpose. As we restart the tick, we don't want to resume from the IPI in RCU extended quiescent state anymore. Similarly we may stop the tick from an interrupt in userspace and we need to be able to enter RCU extended quiescent state when we resume from this interrupt to userspace.

To these ends, we provide two new APIs:

- rcu_user_enter_irq(). This must be called from a non-nesting interrupt betwenn rcu_irq_enter() and rcu_irq_exit(). After the irq calls rcu_irq_exit(), we'll run into RCU extended quiescent state.

- rcu_user_exit_irq(). This must be called from a non-nesting interrupt, interrupting an RCU extended quiescent state, and between rcu_irq_enter() and rcu_irq_exit(). After the irq calls rcu_irq_exit(), we'll prevent from resuming the RCU extended quiescent.

Cc Alessio Igor Bogani <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Avi Kivity <[email protected]>
Cc Chris Metcalf <[email protected]>
Cc Christoph Lameter <[email protected]>
Cc Daniel Lezcano <[email protected]>
Cc Geoff Levand <[email protected]>
Cc Gilad Ben Yossef <[email protected]>
Cc Hakan Akkan <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Max Krasnyansky <[email protected]>
Cc Paul E. McKenney <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Stephen Hemminger <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Sven-Thorsten Dietrich <[email protected]>
Cc Thomas Gleixner <[email protected]>
---
 include/linux/rcupdate.h |    2 +
 kernel/rcutree.c         |   49 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 51 insertions(+), 0 deletions(-)
include/linux/rcupdate.h +2 -0
index e8323df..c0280ce 100644
@@ -193,6 +193,8 @@ extern void rcu_irq_enter(void);
 extern void rcu_irq_exit(void);
 extern void rcu_user_enter(void);
 extern void rcu_user_exit(void);
+extern void rcu_user_enter_irq(void);
+extern void rcu_user_exit_irq(void);
 extern void exit_rcu(void);
 
 /**
kernel/rcutree.c +49 -0

61 lines not on this page · raw message

Signature · 1 line
1.7.5.4
#3 lore raw
In reply to [email protected]
Quoted 7 lines · On Mon, Jun 04, 2012 at 02:08:26PM +0200, [email protected] wrote:

From: Frederic Weisbecker <[email protected]>

Paul, Ingo,

This is a rebase of the nohz cpusets RCU APIs on top of Paul's latest -rcu (rcu/core) branch.

Quoted 8 lines

I have only built tested it yet, I need to do a full rebase of my tree to test it in practice. But I wanted to show you how it looks like first.

I also wonder if we can set that to a tree somewhere. Ingo suggested to set up a tree on -tip to apply the uncontroversial part of nohz cpusets patches and iterate from there. I think it would accelerate everything if we start doing that.

It would probably be best to put these two in the -rcu set in order to avoid conflicts with possible further RCU_FAST_NO_HZ work. I could push this to -tip early, if that would help.

Thanx, Paul

Quoted 21 lines

Tell me what you think.

Thanks.

Frederic Weisbecker (2):
rcu: New rcu_user_enter() and rcu_user_exit() APIs
rcu: New rcu_user_enter_irq() and rcu_user_exit_irq() APIs

 include/linux/rcupdate.h |    4 +
 kernel/rcutree.c         |  184 +++++++++++++++++++++++++++++++++++++++------
 2 files changed, 163 insertions(+), 25 deletions(-)
Signature · 7 lines
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
#4 lore raw

2012/6/4 Paul E. McKenney <[email protected]>:

Quoted 12 lines · On Mon, Jun 04, 2012 at 02:08:26PM +0200, [email protected] wrote:
Quoted 11 lines

From: Frederic Weisbecker <[email protected]>

Paul, Ingo,

This is a rebase of the nohz cpusets RCU APIs on top of Paul's latest -rcu (rcu/core) branch.

I have only built tested it yet, I need to do a full rebase of my tree to test it in practice. But I wanted to show you how it looks like first.

Quoted 8 lines
Quoted 4 lines

I also wonder if we can set that to a tree somewhere. Ingo suggested to set up a tree on -tip to apply the uncontroversial part of nohz cpusets patches and iterate from there. I think it would accelerate everything if we start doing that.

It would probably be best to put these two in the -rcu set in order to avoid conflicts with possible further RCU_FAST_NO_HZ work.  I could push this to -tip early, if that would help.

But then these APIs are going to be upstream on 3.6 Is that ok for you even if they don't have any upstream user? We can ifdef it.

#5 lore raw
Quoted 18 lines · Frederic Weisbecker

2012/6/4 Paul E. McKenney <[email protected]>:

Quoted 17 lines · On Mon, Jun 04, 2012 at 02:08:26PM +0200, [email protected] wrote:
Quoted 15 lines

From: Frederic Weisbecker <[email protected]>

Paul, Ingo,

This is a rebase of the nohz cpusets RCU APIs on top of Paul's latest -rcu (rcu/core) branch.

I have only built tested it yet, I need to do a full rebase of my tree to test it in practice. But I wanted to show you how it looks like first.

I also wonder if we can set that to a tree somewhere. Ingo suggested to set up a tree on -tip to apply the uncontroversial part of nohz cpusets patches and iterate from there. I think it would accelerate everything if we start doing that.

Quoted 7 lines
Quoted 3 lines

It would probably be best to put these two in the -rcu set in order to avoid conflicts with possible further RCU_FAST_NO_HZ work.  I could push this to -tip early, if that would help.

But then these APIs are going to be upstream on 3.6 Is that ok for you even if they don't have any upstream user? We can ifdef it.

I figured on maintaining a separate rcu/idle topic branch that I would merge locally for building and testing, but which I would not push to rcu/next. If Ingo agrees, I can push separately to -tip so that it does not go upstream until you are ready, at which point I would merge it into rcu/next.

Seem reasonable, or would something else work better?

Thanx, Paul

#6 lore raw
Quoted 27 lines · Paul E. McKenney
Quoted 18 lines · Frederic Weisbecker

2012/6/4 Paul E. McKenney <[email protected]>:

Quoted 17 lines · On Mon, Jun 04, 2012 at 02:08:26PM +0200, [email protected] wrote:
Quoted 15 lines

From: Frederic Weisbecker <[email protected]>

Paul, Ingo,

This is a rebase of the nohz cpusets RCU APIs on top of Paul's latest -rcu (rcu/core) branch.

I have only built tested it yet, I need to do a full rebase of my tree to test it in practice. But I wanted to show you how it looks like first.

I also wonder if we can set that to a tree somewhere. Ingo suggested to set up a tree on -tip to apply the uncontroversial part of nohz cpusets patches and iterate from there. I think it would accelerate everything if we start doing that.

Quoted 7 lines
Quoted 3 lines

It would probably be best to put these two in the -rcu set in order to avoid conflicts with possible further RCU_FAST_NO_HZ work.  I could push this to -tip early, if that would help.

But then these APIs are going to be upstream on 3.6 Is that ok for you even if they don't have any upstream user? We can ifdef it.

Quoted 7 lines

I figured on maintaining a separate rcu/idle topic branch that I would merge locally for building and testing, but which I would not push to rcu/next. If Ingo agrees, I can push separately to -tip so that it does not go upstream until you are ready, at which point I would merge it into rcu/next.

Seem reasonable, or would something else work better?

Sounds very good!

Thanks.

#7 lore raw
Quoted 34 lines · Frederic Weisbecker
Quoted 33 lines · Paul E. McKenney
Quoted 18 lines · Frederic Weisbecker

2012/6/4 Paul E. McKenney <[email protected]>:

Quoted 17 lines · On Mon, Jun 04, 2012 at 02:08:26PM +0200, [email protected] wrote:
Quoted 15 lines

From: Frederic Weisbecker <[email protected]>

Paul, Ingo,

This is a rebase of the nohz cpusets RCU APIs on top of Paul's latest -rcu (rcu/core) branch.

I have only built tested it yet, I need to do a full rebase of my tree to test it in practice. But I wanted to show you how it looks like first.

I also wonder if we can set that to a tree somewhere. Ingo suggested to set up a tree on -tip to apply the uncontroversial part of nohz cpusets patches and iterate from there. I think it would accelerate everything if we start doing that.

Quoted 7 lines
Quoted 3 lines

It would probably be best to put these two in the -rcu set in order to avoid conflicts with possible further RCU_FAST_NO_HZ work.  I could push this to -tip early, if that would help.

But then these APIs are going to be upstream on 3.6 Is that ok for you even if they don't have any upstream user? We can ifdef it.

I figured on maintaining a separate rcu/idle topic branch that I would merge locally for building and testing, but which I would not push to rcu/next. If Ingo agrees, I can push separately to -tip so that it does not go upstream until you are ready, at which point I would merge it into rcu/next.

Quoted 3 lines
Quoted 1 line

Seem reasonable, or would something else work better?

Sounds very good!

Here you go:

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

Thanx, Paul

#8 lore raw
Quoted 35 lines · Paul E. McKenney
Quoted 34 lines · Frederic Weisbecker
Quoted 33 lines · Paul E. McKenney
Quoted 18 lines · Frederic Weisbecker

2012/6/4 Paul E. McKenney <[email protected]>:

Quoted 17 lines · On Mon, Jun 04, 2012 at 02:08:26PM +0200, [email protected] wrote:
Quoted 15 lines

From: Frederic Weisbecker <[email protected]>

Paul, Ingo,

This is a rebase of the nohz cpusets RCU APIs on top of Paul's latest -rcu (rcu/core) branch.

I have only built tested it yet, I need to do a full rebase of my tree to test it in practice. But I wanted to show you how it looks like first.

I also wonder if we can set that to a tree somewhere. Ingo suggested to set up a tree on -tip to apply the uncontroversial part of nohz cpusets patches and iterate from there. I think it would accelerate everything if we start doing that.

Quoted 7 lines
Quoted 3 lines

It would probably be best to put these two in the -rcu set in order to avoid conflicts with possible further RCU_FAST_NO_HZ work.  I could push this to -tip early, if that would help.

But then these APIs are going to be upstream on 3.6 Is that ok for you even if they don't have any upstream user? We can ifdef it.

I figured on maintaining a separate rcu/idle topic branch that I would merge locally for building and testing, but which I would not push to rcu/next. If Ingo agrees, I can push separately to -tip so that it does not go upstream until you are ready, at which point I would merge it into rcu/next.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Seem reasonable, or would something else work better?

Sounds very good!

Here you go:

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

Thanks!

I can see you've implemented a version for TinyRCU. Nohz cpusets only work on SMP right now because there must be at least one CPU running with the tick to maintain the timekeeping. I'm pretty confident that one day we'll remove the jiffies and we'll be able to do the whole timekeeping by using the TSC or so. There is quite a way before we reach that though.

#9 lore raw
Quoted 44 lines · Frederic Weisbecker
Quoted 35 lines · Paul E. McKenney
Quoted 34 lines · Frederic Weisbecker
Quoted 33 lines · Paul E. McKenney
Quoted 18 lines · Frederic Weisbecker

2012/6/4 Paul E. McKenney <[email protected]>:

Quoted 17 lines · On Mon, Jun 04, 2012 at 02:08:26PM +0200, [email protected] wrote:
Quoted 15 lines

From: Frederic Weisbecker <[email protected]>

Paul, Ingo,

This is a rebase of the nohz cpusets RCU APIs on top of Paul's latest -rcu (rcu/core) branch.

I have only built tested it yet, I need to do a full rebase of my tree to test it in practice. But I wanted to show you how it looks like first.

I also wonder if we can set that to a tree somewhere. Ingo suggested to set up a tree on -tip to apply the uncontroversial part of nohz cpusets patches and iterate from there. I think it would accelerate everything if we start doing that.

Quoted 7 lines
Quoted 3 lines

It would probably be best to put these two in the -rcu set in order to avoid conflicts with possible further RCU_FAST_NO_HZ work.  I could push this to -tip early, if that would help.

But then these APIs are going to be upstream on 3.6 Is that ok for you even if they don't have any upstream user? We can ifdef it.

I figured on maintaining a separate rcu/idle topic branch that I would merge locally for building and testing, but which I would not push to rcu/next. If Ingo agrees, I can push separately to -tip so that it does not go upstream until you are ready, at which point I would merge it into rcu/next.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Seem reasonable, or would something else work better?

Sounds very good!

Here you go:

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

Quoted 7 lines

Thanks!

I can see you've implemented a version for TinyRCU. Nohz cpusets only work on SMP right now because there must be at least one CPU running with the tick to maintain the timekeeping. I'm pretty confident that one day we'll remove the jiffies and we'll be able to do the whole timekeeping by using the TSC or so. There is quite a way before we reach that though.

In the meantime, would it make sense to slow the tick rate by a factor of 10 or so on that one CPU when nothing else is going on? Or does timekeeping absolutely require running the tick at full speed?

Thanx, Paul

#12 lore raw

PATCH 1/1 rcu: Allow calls to rcu_exit_user_irq from nesting irqs

In reply to Paul E. McKenney
Quoted 3 lines · Paul E. McKenney

Here you go:

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

So I've rebased my nohz cpusets patchset and applied these patches. During testing I found a bug and realized I need to make rcu_exit_user_irq() callable from any irq nesting level.

Here is a fix:

---

Quoted 1 line

From c30610d5ed2c292a87f7e32216c3419cdc12dff0 Mon Sep 17 00:00:00 2001

From: Frederic Weisbecker <[email protected]>
Date: Sat, 9 Jun 2012 14:06:30 +0200
Subject: [PATCH] rcu: Allow calls to rcu_exit_user_irq from nesting irqs

rcu_exit_user_irq() which exits RCU idle mode after the current irq returns has been designed to be called from non nesting irqs only.

However the IPI that restarts the tick and exits RCU user-idle mode in nohz cpusets can happen anytime. For example it can be a nesting irq by interrupting a softirq. In this case the stack of RCU API calls becomes:

==> IRQ

    rcu_irq_enter()
    ....
    do_softirq {
===== > IRQ (restart tick IPI)
        rcu_irq_enter()
        rcu_exit_user_irq()
        rcu_irq_exit()
<=====
    }
    rcu_irq_exit();

Hence we need to make rcu_exit_user_irq() callable from any nesting level of interrupt.

rcu_enter_user_irq() is only called from non nesting irqs though. But to stay consistant with the new change we also allow it to be called from any irq nesting level.

---
 kernel/rcutree.c |   36 +++++++++++++++---------------------
 1 files changed, 15 insertions(+), 21 deletions(-)
kernel/rcutree.c +15 -21
index 1b0dca2..3e84c4c 100644
@@ -465,11 +465,11 @@ void rcu_user_enter(void)
 
 /**
  * rcu_user_enter_irq - inform RCU that we are going to resume userspace
- * after the current irq returns.
+ * after the current non-nesting irq returns.
  *
- * This is similar to rcu_user_enter() but in the context of a non
- * nesting irq. After this call, RCU enters into idle mode when the
- * interrupt returns.
+ * This is similar to rcu_user_enter() but in the context of an
+ * irq. After this call, RCU enters into idle mode when the
+ * current non-nesting interrupt returns.
  */
 void rcu_user_enter_irq(void)
 {
@@ -478,12 +478,9 @@ void rcu_user_enter_irq(void)
 
 	local_irq_save(flags);
 	rdtp = &__get_cpu_var(rcu_dynticks);
-	/*
-	 * Ensure this irq is a non nesting one interrupting
-	 * a non-idle RCU state.
-	 */
-	WARN_ON_ONCE(rdtp->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE + 1);
-	rdtp->dynticks_nesting = 1;
+	/* Ensure we are interrupting a non-idle RCU state */
+	WARN_ON_ONCE(!(rdtp->dynticks_nesting & DYNTICK_TASK_NEST_MASK));
+	rdtp->dynticks_nesting -= DYNTICK_TASK_EXIT_IDLE;
 	local_irq_restore(flags);
 }
 
@@ -619,12 +616,12 @@ void rcu_user_exit(void)
 
 /**
  * rcu_user_exit_irq - inform RCU that we won't resume to userspace
- * idle mode after the current irq returns.
+ * idle mode after the current non-nesting irq returns.
  *
- * This is similar to rcu_user_exit() but in the context of a non
- * nesting irq. This is called when the irq has interrupted a userspace
- * RCU idle mode context. When the interrupt returns after this call,
- * the CPU won't restore the RCU idle mode.
+ * This is similar to rcu_user_exit() but in the context of an
+ * irq. This is called when the irq has interrupted a userspace
+ * RCU idle mode context. When the current non-nesting interrupt
+ * returns after this call, the CPU won't restore the RCU idle mode.
  */
 void rcu_user_exit_irq(void)
 {
@@ -633,12 +630,9 @@ void rcu_user_exit_irq(void)
 
 	local_irq_save(flags);
 	rdtp = &__get_cpu_var(rcu_dynticks);
-	/*
-	 * Ensure this irq is a non-nesting one interrupting
-	 * an RCU idle mode.
-	 */
-	WARN_ON_ONCE(rdtp->dynticks_nesting != 1);
-	rdtp->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE + 1;
+	/* Ensure we are interrupting an RCU idle mode. */
+	WARN_ON_ONCE(rdtp->dynticks_nesting & DYNTICK_TASK_NEST_MASK);
+	rdtp->dynticks_nesting += DYNTICK_TASK_EXIT_IDLE;
 	local_irq_restore(flags);
 }
 
Signature · 1 line
1.7.0.4
#10 lore raw
In reply to Paul E. McKenney
Quoted 9 lines · Paul E. McKenney
Quoted 5 lines

I can see you've implemented a version for TinyRCU. Nohz cpusets only work on SMP right now because there must be at least one CPU running with the tick to maintain the timekeeping. I'm pretty confident that one day we'll remove the jiffies and we'll be able to do the whole timekeeping by using the TSC or so. There is quite a way before we reach that though.

In the meantime, would it make sense to slow the tick rate by a factor of 10 or so on that one CPU when nothing else is going on? Or does timekeeping absolutely require running the tick at full speed?

I'm not sure of the possible consequences of that.

#11 lore raw
Quoted 7 lines · Frederic Weisbecker
Quoted 6 lines · Paul E. McKenney
Quoted 5 lines

I can see you've implemented a version for TinyRCU. Nohz cpusets only work on SMP right now because there must be at least one CPU running with the tick to maintain the timekeeping. I'm pretty confident that one day we'll remove the jiffies and we'll be able to do the whole timekeeping by using the TSC or so. There is quite a way before we reach that though.

Quoted 5 lines
Quoted 3 lines

In the meantime, would it make sense to slow the tick rate by a factor of 10 or so on that one CPU when nothing else is going on? Or does timekeeping absolutely require running the tick at full speed?

I'm not sure of the possible consequences of that.

OK, so I will remove the TINY_RCU patches for the moment. If reducing tick speed on the sole remaining idle CPU ever becomes feasible and useful, they are easy to add back in.

Thanx, Paul

#13 lore raw

Re: [PATCH] rcu: Allow calls to rcu_exit_user_irq from nesting irqs

In reply to Frederic Weisbecker
Quoted 8 lines · Frederic Weisbecker
Quoted 3 lines · Paul E. McKenney

Here you go:

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

So I've rebased my nohz cpusets patchset and applied these patches. During testing I found a bug and realized I need to make rcu_exit_user_irq() callable from any irq nesting level.

OK. ;-)

Quoted 64 lines

Here is a fix:

---

Quoted 1 line

From c30610d5ed2c292a87f7e32216c3419cdc12dff0 Mon Sep 17 00:00:00 2001

From: Frederic Weisbecker <[email protected]>
Date: Sat, 9 Jun 2012 14:06:30 +0200
Subject: [PATCH] rcu: Allow calls to rcu_exit_user_irq from nesting irqs

rcu_exit_user_irq() which exits RCU idle mode after the current irq returns has been designed to be called from non nesting irqs only.

However the IPI that restarts the tick and exits RCU user-idle mode in nohz cpusets can happen anytime. For example it can be a nesting irq by interrupting a softirq. In this case the stack of RCU API calls becomes:

==> IRQ

    rcu_irq_enter()
    ....
    do_softirq {
===== > IRQ (restart tick IPI)
        rcu_irq_enter()
        rcu_exit_user_irq()
        rcu_irq_exit()
<=====
    }
    rcu_irq_exit();

Hence we need to make rcu_exit_user_irq() callable from any nesting level of interrupt.

rcu_enter_user_irq() is only called from non nesting irqs though. But to stay consistant with the new change we also allow it to be called from any irq nesting level.

---
 kernel/rcutree.c |   36 +++++++++++++++---------------------
 1 files changed, 15 insertions(+), 21 deletions(-)
kernel/rcutree.c +4 -4
index 1b0dca2..3e84c4c 100644
@@ -465,11 +465,11 @@ void rcu_user_enter(void)
 
 /**
  * rcu_user_enter_irq - inform RCU that we are going to resume userspace
- * after the current irq returns.
+ * after the current non-nesting irq returns.
  *
- * This is similar to rcu_user_enter() but in the context of a non
- * nesting irq. After this call, RCU enters into idle mode when the
- * interrupt returns.
+ * This is similar to rcu_user_enter() but in the context of an
+ * irq. After this call, RCU enters into idle mode when the
+ * current non-nesting interrupt returns.
  */
 void rcu_user_enter_irq(void)
 {
@@ -478,12 +478,9 @@ void rcu_user_enter_irq(void)
 
 	local_irq_save(flags);

kernel/rcutree.c void rcu_user_enter_irq(void) · line 483

Quoted 10 lines
kernel/rcutree.c +3 -6
 	rdtp = &__get_cpu_var(rcu_dynticks);
-	/*
-	 * Ensure this irq is a non nesting one interrupting
-	 * a non-idle RCU state.
-	 */
-	WARN_ON_ONCE(rdtp->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE + 1);
-	rdtp->dynticks_nesting = 1;
+	/* Ensure we are interrupting a non-idle RCU state */
+	WARN_ON_ONCE(!(rdtp->dynticks_nesting & DYNTICK_TASK_NEST_MASK));
+	rdtp->dynticks_nesting -= DYNTICK_TASK_EXIT_IDLE;

This will be broken on architectures that can fail to return from interrupts and exceptions and vice versa. The resulting value of rdtp->dynticks_nesting might well go negative, or might fail to reach zero when the outermost interrupt returns.

One workaround would be to add up the relevant fields of preempt_count() and assign the result to rdtp->dynticks_nesting.

Quoted 24 lines
kernel/rcutree.c +5 -5
 	local_irq_restore(flags);
 }
 
@@ -619,12 +616,12 @@ void rcu_user_exit(void)
 
 /**
  * rcu_user_exit_irq - inform RCU that we won't resume to userspace
- * idle mode after the current irq returns.
+ * idle mode after the current non-nesting irq returns.
  *
- * This is similar to rcu_user_exit() but in the context of a non
- * nesting irq. This is called when the irq has interrupted a userspace
- * RCU idle mode context. When the interrupt returns after this call,
- * the CPU won't restore the RCU idle mode.
+ * This is similar to rcu_user_exit() but in the context of an
+ * irq. This is called when the irq has interrupted a userspace
+ * RCU idle mode context. When the current non-nesting interrupt
+ * returns after this call, the CPU won't restore the RCU idle mode.
  */
 void rcu_user_exit_irq(void)
 {
@@ -633,12 +630,9 @@ void rcu_user_exit_irq(void)
 
 	local_irq_save(flags);

kernel/rcutree.c void rcu_user_exit_irq(void) · line 635

Quoted 10 lines
kernel/rcutree.c +3 -6
 	rdtp = &__get_cpu_var(rcu_dynticks);
-	/*
-	 * Ensure this irq is a non-nesting one interrupting
-	 * an RCU idle mode.
-	 */
-	WARN_ON_ONCE(rdtp->dynticks_nesting != 1);
-	rdtp->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE + 1;
+	/* Ensure we are interrupting an RCU idle mode. */
+	WARN_ON_ONCE(rdtp->dynticks_nesting & DYNTICK_TASK_NEST_MASK);
+	rdtp->dynticks_nesting += DYNTICK_TASK_EXIT_IDLE;

This one works because all of the interrupt misnesting events that I know of happen from system-call context, not from idle or from user-mode execution.

Thanx, Paul

Quoted 7 lines
kernel/rcutree.c +0 -0
 	local_irq_restore(flags);
 }
 
Signature · 1 line
1.7.0.4
#14 lore raw

Re: [PATCH] rcu: Allow calls to rcu_exit_user_irq from nesting irqs

Quoted 22 lines · Paul E. McKenney
Quoted 5 lines · Frederic Weisbecker

void rcu_user_enter_irq(void)
{

kernel/rcutree.c +0 -0
@@ -478,12 +478,9 @@ void rcu_user_enter_irq(void)
 
 	local_irq_save(flags);

kernel/rcutree.c void rcu_user_enter_irq(void) · line 483

Quoted 10 lines
kernel/rcutree.c +3 -6
 	rdtp = &__get_cpu_var(rcu_dynticks);
-	/*
-	 * Ensure this irq is a non nesting one interrupting
-	 * a non-idle RCU state.
-	 */
-	WARN_ON_ONCE(rdtp->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE + 1);
-	rdtp->dynticks_nesting = 1;
+	/* Ensure we are interrupting a non-idle RCU state */
+	WARN_ON_ONCE(!(rdtp->dynticks_nesting & DYNTICK_TASK_NEST_MASK));
+	rdtp->dynticks_nesting -= DYNTICK_TASK_EXIT_IDLE;

This will be broken on architectures that can fail to return from interrupts and exceptions and vice versa. The resulting value of rdtp->dynticks_nesting might well go negative, or might fail to reach zero when the outermost interrupt returns.

Quoted 2 lines

One workaround would be to add up the relevant fields of preempt_count() and assign the result to rdtp->dynticks_nesting.

That's ok. I made rcu_user_enter_irq() to support nesting irqs in order to stay consistant with the same change in rcu_user_exit_irq(). But this is not necessary. rcu_user_enter_irq() itself is only called from the outermost irq.

Also there is a sanity check that ensures that in the current code in rcu/idle tree so rcu_user_enter_irq() can stay as is there.

I'll resend the patch with only the change in rcu_user_exit_irq().

Thanks.

#15 lore raw

PATCH v2 1/1 rcu: Allow calls to rcu_exit_user_irq from nesting irqs

In reply to Paul E. McKenney

From: Frederic Weisbecker <[email protected]>
Date: Sat, 9 Jun 2012 14:06:30 +0200
Subject: [PATCH] rcu: Allow calls to rcu_exit_user_irq from nesting irqs

rcu_exit_user_irq() which exits RCU idle mode after the current irq returns has been designed to be called from non nesting irqs only.

However the IPI that restarts the tick and exits RCU user-idle mode in nohz cpusets can happen anytime. For example it can be a nesting irq by interrupting a softirq. In this case the stack of RCU API calls becomes:

==> IRQ

    rcu_irq_enter()
    ....
    do_softirq {
===== > IRQ (restart tick IPI)
        rcu_irq_enter()
        rcu_exit_user_irq()
        rcu_irq_exit()
<=====
    }
    rcu_irq_exit();

Hence we need to make rcu_exit_user_irq() callable from any nesting level of interrupt.

v2: rcu_user_enter_irq() is only called from non nesting irqs though so the change doesn't need to be propagated to it.

---
 kernel/rcutree.c |   19 ++++++++-----------
 1 files changed, 8 insertions(+), 11 deletions(-)
kernel/rcutree.c +8 -11
index 1b0dca2..7a54265 100644
@@ -619,12 +619,12 @@ void rcu_user_exit(void)
 
 /**
  * rcu_user_exit_irq - inform RCU that we won't resume to userspace
- * idle mode after the current irq returns.
+ * idle mode after the current non-nesting irq returns.
  *
- * This is similar to rcu_user_exit() but in the context of a non
- * nesting irq. This is called when the irq has interrupted a userspace
- * RCU idle mode context. When the interrupt returns after this call,
- * the CPU won't restore the RCU idle mode.
+ * This is similar to rcu_user_exit() but in the context of an
+ * irq. This is called when the irq has interrupted a userspace
+ * RCU idle mode context. When the current non-nesting interrupt
+ * returns after this call, the CPU won't restore the RCU idle mode.
  */
 void rcu_user_exit_irq(void)
 {
@@ -633,12 +633,9 @@ void rcu_user_exit_irq(void)
 
 	local_irq_save(flags);
 	rdtp = &__get_cpu_var(rcu_dynticks);
-	/*
-	 * Ensure this irq is a non-nesting one interrupting
-	 * an RCU idle mode.
-	 */
-	WARN_ON_ONCE(rdtp->dynticks_nesting != 1);
-	rdtp->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE + 1;
+	/* Ensure we are interrupting an RCU idle mode. */
+	WARN_ON_ONCE(rdtp->dynticks_nesting & DYNTICK_TASK_NEST_MASK);
+	rdtp->dynticks_nesting += DYNTICK_TASK_EXIT_IDLE;
 	local_irq_restore(flags);
 }
 
Signature · 1 line
1.7.0.4
#16 lore raw

Re: [PATCH v2] rcu: Allow calls to rcu_exit_user_irq from nesting irqs

Quoted 25 lines · Frederic Weisbecker

From: Frederic Weisbecker <[email protected]>
Date: Sat, 9 Jun 2012 14:06:30 +0200
Subject: [PATCH] rcu: Allow calls to rcu_exit_user_irq from nesting irqs

rcu_exit_user_irq() which exits RCU idle mode after the current irq returns has been designed to be called from non nesting irqs only.

However the IPI that restarts the tick and exits RCU user-idle mode in nohz cpusets can happen anytime. For example it can be a nesting irq by interrupting a softirq. In this case the stack of RCU API calls becomes:

==> IRQ

    rcu_irq_enter()
    ....
    do_softirq {
===== > IRQ (restart tick IPI)
        rcu_irq_enter()
        rcu_exit_user_irq()
        rcu_irq_exit()
<=====
    }
    rcu_irq_exit();
Quoted 5 lines

Hence we need to make rcu_exit_user_irq() callable from any nesting level of interrupt.

v2: rcu_user_enter_irq() is only called from non nesting irqs though so the change doesn't need to be propagated to it.

I have queued this on -rcu on branch rcu/idle. I have also removed the TINY_RCU commits as discussed. If you ever need them back, the magic branch name is idle.2012.06.06a.

Thanx, Paul

Quoted 52 lines
---
 kernel/rcutree.c |   19 ++++++++-----------
 1 files changed, 8 insertions(+), 11 deletions(-)
kernel/rcutree.c +8 -11
index 1b0dca2..7a54265 100644
@@ -619,12 +619,12 @@ void rcu_user_exit(void)
 
 /**
  * rcu_user_exit_irq - inform RCU that we won't resume to userspace
- * idle mode after the current irq returns.
+ * idle mode after the current non-nesting irq returns.
  *
- * This is similar to rcu_user_exit() but in the context of a non
- * nesting irq. This is called when the irq has interrupted a userspace
- * RCU idle mode context. When the interrupt returns after this call,
- * the CPU won't restore the RCU idle mode.
+ * This is similar to rcu_user_exit() but in the context of an
+ * irq. This is called when the irq has interrupted a userspace
+ * RCU idle mode context. When the current non-nesting interrupt
+ * returns after this call, the CPU won't restore the RCU idle mode.
  */
 void rcu_user_exit_irq(void)
 {
@@ -633,12 +633,9 @@ void rcu_user_exit_irq(void)
 
 	local_irq_save(flags);
 	rdtp = &__get_cpu_var(rcu_dynticks);
-	/*
-	 * Ensure this irq is a non-nesting one interrupting
-	 * an RCU idle mode.
-	 */
-	WARN_ON_ONCE(rdtp->dynticks_nesting != 1);
-	rdtp->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE + 1;
+	/* Ensure we are interrupting an RCU idle mode. */
+	WARN_ON_ONCE(rdtp->dynticks_nesting & DYNTICK_TASK_NEST_MASK);
+	rdtp->dynticks_nesting += DYNTICK_TASK_EXIT_IDLE;
 	local_irq_restore(flags);
 }
 
Signature · 7 lines
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
#17 lore raw

Re: [PATCH v2] rcu: Allow calls to rcu_exit_user_irq from nesting irqs

Quoted 29 lines · Paul E. McKenney
Quoted 28 lines · Frederic Weisbecker

From: Frederic Weisbecker <[email protected]>
Date: Sat, 9 Jun 2012 14:06:30 +0200
Subject: [PATCH] rcu: Allow calls to rcu_exit_user_irq from nesting irqs

rcu_exit_user_irq() which exits RCU idle mode after the current irq returns has been designed to be called from non nesting irqs only.

However the IPI that restarts the tick and exits RCU user-idle mode in nohz cpusets can happen anytime. For example it can be a nesting irq by interrupting a softirq. In this case the stack of RCU API calls becomes:

==> IRQ

    rcu_irq_enter()
    ....
    do_softirq {
===== > IRQ (restart tick IPI)
        rcu_irq_enter()
        rcu_exit_user_irq()
        rcu_irq_exit()
<=====
    }
    rcu_irq_exit();

Hence we need to make rcu_exit_user_irq() callable from any nesting level of interrupt.

Quoted 6 lines
Quoted 2 lines

v2: rcu_user_enter_irq() is only called from non nesting irqs though so the change doesn't need to be propagated to it.

I have queued this on -rcu on branch rcu/idle. I have also removed the TINY_RCU commits as discussed. If you ever need them back, the magic branch name is idle.2012.06.06a.

Thanks a lot!