Skip to contentSkip to conversation

rcu: Remove redundant rcu_is_cpu_rrupt_from_idle() function

PATCH In review Alexander Gordeev 2 participants 15 messages Oct 29, 2014 – Oct 31, 2014 RCU

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rcu: Remove redundant rcu_is_cpu_rrupt_from_idle() function

Function rcu_is_cpu_rrupt_from_idle() is called from scheduling- clock interrupt handler to check if the current CPU was interrupted from idle. If true, it results in invocation of RCU callbacks. But the common hardware interrupt exit path also contains similar check and therefore the call to rcu_is_cpu_rrupt_from_idle() is redundant.

---
 kernel/rcu/tiny.c | 12 +-----------
 kernel/rcu/tree.c | 14 +-------------
 2 files changed, 2 insertions(+), 24 deletions(-)
kernel/rcu/tiny.c +1 -11
index c0623fc..0bfb3b9 100644
@@ -186,16 +186,6 @@ EXPORT_SYMBOL(__rcu_is_watching);
 #endif /* defined(CONFIG_DEBUG_LOCK_ALLOC) || defined(CONFIG_RCU_TRACE) */
 
 /*
- * Test whether the current CPU was interrupted from idle.  Nested
- * interrupts don't count, we must be running at the first interrupt
- * level.
- */
-static int rcu_is_cpu_rrupt_from_idle(void)
-{
-	return rcu_dynticks_nesting <= 1;
-}
-
-/*
  * Helper function for rcu_sched_qs() and rcu_bh_qs().
  * Also irqs are disabled to avoid confusion due to interrupt handlers
  * invoking call_rcu().
@@ -250,7 +240,7 @@ void rcu_bh_qs(void)
 void rcu_check_callbacks(int cpu, int user)
 {
 	RCU_TRACE(check_cpu_stalls());
-	if (user || rcu_is_cpu_rrupt_from_idle())
+	if (user)
 		rcu_sched_qs();
 	else if (!in_softirq())
 		rcu_bh_qs();
kernel/rcu/tree.c +1 -13
index 133e472..8e9341c 100644
@@ -884,18 +884,6 @@ EXPORT_SYMBOL_GPL(rcu_lockdep_current_cpu_online);
 
 #endif /* #if defined(CONFIG_PROVE_RCU) && defined(CONFIG_HOTPLUG_CPU) */
 
-/**
- * rcu_is_cpu_rrupt_from_idle - see if idle or immediately interrupted from idle
- *
- * If the current CPU is idle or running at a first-level (not nested)
- * interrupt from idle, return true.  The caller must have at least
- * disabled preemption.
- */
-static int rcu_is_cpu_rrupt_from_idle(void)
-{
-	return __this_cpu_read(rcu_dynticks.dynticks_nesting) <= 1;
-}
-
 /*
  * Snapshot the specified CPU's dynticks counter so that we can later
  * credit them with an implicit quiescent state.  Return 1 if this CPU
@@ -2391,7 +2379,7 @@ void rcu_check_callbacks(int cpu, int user)
 {
 	trace_rcu_utilization(TPS("Start scheduler-tick"));
 	increment_cpu_stall_ticks();
-	if (user || rcu_is_cpu_rrupt_from_idle()) {
+	if (user) {
 
 		/*
 		 * Get here if this CPU took its interrupt from user
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 5 lines · Alexander Gordeev

Function rcu_is_cpu_rrupt_from_idle() is called from scheduling- clock interrupt handler to check if the current CPU was interrupted from idle. If true, it results in invocation of RCU callbacks. But the common hardware interrupt exit path also contains similar check and therefore the call to rcu_is_cpu_rrupt_from_idle() is redundant.

By common hardware interrupt exit path, you are meaning the calls to rcu_irq_exit()? If not, please let me know exactly what you mean here.

Thanx, Paul

Quoted 72 lines
---
 kernel/rcu/tiny.c | 12 +-----------
 kernel/rcu/tree.c | 14 +-------------
 2 files changed, 2 insertions(+), 24 deletions(-)
kernel/rcu/tiny.c +1 -11
index c0623fc..0bfb3b9 100644
@@ -186,16 +186,6 @@ EXPORT_SYMBOL(__rcu_is_watching);
 #endif /* defined(CONFIG_DEBUG_LOCK_ALLOC) || defined(CONFIG_RCU_TRACE) */
 
 /*
- * Test whether the current CPU was interrupted from idle.  Nested
- * interrupts don't count, we must be running at the first interrupt
- * level.
- */
-static int rcu_is_cpu_rrupt_from_idle(void)
-{
-	return rcu_dynticks_nesting <= 1;
-}
-
-/*
  * Helper function for rcu_sched_qs() and rcu_bh_qs().
  * Also irqs are disabled to avoid confusion due to interrupt handlers
  * invoking call_rcu().
@@ -250,7 +240,7 @@ void rcu_bh_qs(void)
 void rcu_check_callbacks(int cpu, int user)
 {
 	RCU_TRACE(check_cpu_stalls());
-	if (user || rcu_is_cpu_rrupt_from_idle())
+	if (user)
 		rcu_sched_qs();
 	else if (!in_softirq())
 		rcu_bh_qs();
kernel/rcu/tree.c +1 -13
index 133e472..8e9341c 100644
@@ -884,18 +884,6 @@ EXPORT_SYMBOL_GPL(rcu_lockdep_current_cpu_online);
 
 #endif /* #if defined(CONFIG_PROVE_RCU) && defined(CONFIG_HOTPLUG_CPU) */
 
-/**
- * rcu_is_cpu_rrupt_from_idle - see if idle or immediately interrupted from idle
- *
- * If the current CPU is idle or running at a first-level (not nested)
- * interrupt from idle, return true.  The caller must have at least
- * disabled preemption.
- */
-static int rcu_is_cpu_rrupt_from_idle(void)
-{
-	return __this_cpu_read(rcu_dynticks.dynticks_nesting) <= 1;
-}
-
 /*
  * Snapshot the specified CPU's dynticks counter so that we can later
  * credit them with an implicit quiescent state.  Return 1 if this CPU
@@ -2391,7 +2379,7 @@ void rcu_check_callbacks(int cpu, int user)
 {
 	trace_rcu_utilization(TPS("Start scheduler-tick"));
 	increment_cpu_stall_ticks();
-	if (user || rcu_is_cpu_rrupt_from_idle()) {
+	if (user) {
 
 		/*
 		 * Get here if this CPU took its interrupt from user
Signature · 1 line
1.8.3.1
#2 lore raw
Quoted 10 lines · Paul E. McKenney
Quoted 5 lines · Alexander Gordeev

Function rcu_is_cpu_rrupt_from_idle() is called from scheduling- clock interrupt handler to check if the current CPU was interrupted from idle. If true, it results in invocation of RCU callbacks. But the common hardware interrupt exit path also contains similar check and therefore the call to rcu_is_cpu_rrupt_from_idle() is redundant.

By common hardware interrupt exit path, you are meaning the calls to rcu_irq_exit()? If not, please let me know exactly what you mean here.

Yes, I mean rcu_irq_exit().

Quoted 1 line

Thanx, Paul

Signature · 3 lines
Regards,
Alexander Gordeev
[email protected]
#3 lore raw
Quoted 8 lines · Alexander Gordeev
Quoted 7 lines · Paul E. McKenney
Quoted 5 lines · Alexander Gordeev

Function rcu_is_cpu_rrupt_from_idle() is called from scheduling- clock interrupt handler to check if the current CPU was interrupted from idle. If true, it results in invocation of RCU callbacks. But the common hardware interrupt exit path also contains similar check and therefore the call to rcu_is_cpu_rrupt_from_idle() is redundant.

Quoted 5 lines
Quoted 3 lines

By common hardware interrupt exit path, you are meaning the calls to rcu_irq_exit()? If not, please let me know exactly what you mean here.

Yes, I mean rcu_irq_exit().

Unless you can get the indication of whether or not the original interrupt came from userspace execution into rcu_irq_exit(), this will not work. It will result in grace-period hangs on some configurations.

Now, if you -can- get the userspace-execution indication into rcu_irq_exit(), this might be of interest. However, it might be faster to simply let the scheduling-clock interrupt do the job as it currently does, especially for workloads with lots of interrupts.

Or did you have something else in mind?

Thanx, Paul

#4 lore raw
Quoted 13 lines · Paul E. McKenney
Quoted 12 lines · Alexander Gordeev
Quoted 10 lines · Paul E. McKenney
Quoted 5 lines · Alexander Gordeev

Function rcu_is_cpu_rrupt_from_idle() is called from scheduling- clock interrupt handler to check if the current CPU was interrupted from idle. If true, it results in invocation of RCU callbacks. But the common hardware interrupt exit path also contains similar check and therefore the call to rcu_is_cpu_rrupt_from_idle() is redundant.

By common hardware interrupt exit path, you are meaning the calls to rcu_irq_exit()? If not, please let me know exactly what you mean here.

Quoted 5 lines
Quoted 1 line

Yes, I mean rcu_irq_exit().

Unless you can get the indication of whether or not the original interrupt came from userspace execution into rcu_irq_exit(), this will not work. It will result in grace-period hangs on some configurations.

Okay, that was my concern wrt tree RCU. By contrast, tiny RCU does not seem able to hang a grace-period, isn't it?

Quoted 6 lines

Now, if you -can- get the userspace-execution indication into rcu_irq_exit(), this might be of interest. However, it might be faster to simply let the scheduling-clock interrupt do the job as it currently does, especially for workloads with lots of interrupts.

Or did you have something else in mind?

Nope. I would even leave as is tiny RCU's rcu_is_cpu_rrupt_from_idle() for clarity then ;)

Quoted 1 line

Thanx, Paul

Signature · 3 lines
Regards,
Alexander Gordeev
[email protected]
#5 lore raw
Quoted 14 lines · Alexander Gordeev
Quoted 13 lines · Paul E. McKenney
Quoted 12 lines · Alexander Gordeev
Quoted 10 lines · Paul E. McKenney
Quoted 5 lines · Alexander Gordeev

Function rcu_is_cpu_rrupt_from_idle() is called from scheduling- clock interrupt handler to check if the current CPU was interrupted from idle. If true, it results in invocation of RCU callbacks. But the common hardware interrupt exit path also contains similar check and therefore the call to rcu_is_cpu_rrupt_from_idle() is redundant.

By common hardware interrupt exit path, you are meaning the calls to rcu_irq_exit()? If not, please let me know exactly what you mean here.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Yes, I mean rcu_irq_exit().

Unless you can get the indication of whether or not the original interrupt came from userspace execution into rcu_irq_exit(), this will not work. It will result in grace-period hangs on some configurations.

Okay, that was my concern wrt tree RCU. By contrast, tiny RCU does not seem able to hang a grace-period, isn't it?

Although it is true that tiny RCU cannot hang a synchronize_rcu() grace period, it most certainly can hang a call_rcu() grace period in exactly the same way.

Quoted 9 lines
Quoted 6 lines

Now, if you -can- get the userspace-execution indication into rcu_irq_exit(), this might be of interest. However, it might be faster to simply let the scheduling-clock interrupt do the job as it currently does, especially for workloads with lots of interrupts.

Or did you have something else in mind?

Nope. I would even leave as is tiny RCU's rcu_is_cpu_rrupt_from_idle() for clarity then ;)

Also to avoid userspace execution from preventing RCU callbacks from ever being invoked. ;-)

Thanx, Paul

#6 lore raw
Quoted 21 lines · Paul E. McKenney
Quoted 20 lines · Alexander Gordeev
Quoted 18 lines · Paul E. McKenney
Quoted 8 lines · Alexander Gordeev
Quoted 7 lines · Paul E. McKenney
Quoted 5 lines · Alexander Gordeev

Function rcu_is_cpu_rrupt_from_idle() is called from scheduling- clock interrupt handler to check if the current CPU was interrupted from idle. If true, it results in invocation of RCU callbacks. But the common hardware interrupt exit path also contains similar check and therefore the call to rcu_is_cpu_rrupt_from_idle() is redundant.

Quoted 5 lines
Quoted 3 lines

By common hardware interrupt exit path, you are meaning the calls to rcu_irq_exit()? If not, please let me know exactly what you mean here.

Yes, I mean rcu_irq_exit().

Unless you can get the indication of whether or not the original interrupt came from userspace execution into rcu_irq_exit(), this will not work. It will result in grace-period hangs on some configurations.

Quoted 6 lines
Quoted 2 lines

Okay, that was my concern wrt tree RCU. By contrast, tiny RCU does not seem able to hang a grace-period, isn't it?

Although it is true that tiny RCU cannot hang a synchronize_rcu() grace period, it most certainly can hang a call_rcu() grace period in exactly the same way.

Sorry for being a pain in the neck - just want to make sure I am following.

I only see possibility to cause callbacks not being called for "too long" in case a system has lots of nested interrupts and rcu_idle_enter_common() is not being called from hardware interrupt context as result. How could rcu_is_cpu_rrupt_from_idle() help here?

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Now, if you -can- get the userspace-execution indication into rcu_irq_exit(), this might be of interest. However, it might be faster to simply let the scheduling-clock interrupt do the job as it currently does, especially for workloads with lots of interrupts.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Or did you have something else in mind?

Nope. I would even leave as is tiny RCU's rcu_is_cpu_rrupt_from_idle() for clarity then ;)

Also to avoid userspace execution from preventing RCU callbacks from ever being invoked. ;-)

Hmm.. Am I missing something else? I did not remove the userspace check from the scheduling-clock interrupt:

@@ -250,7 +240,7 @@ void rcu_bh_qs(void)
void rcu_check_callbacks(int cpu, int user)
{
RCU_TRACE(check_cpu_stalls());
- if (user || rcu_is_cpu_rrupt_from_idle())
+ if (user)
rcu_sched_qs();
else if (!in_softirq())
rcu_bh_qs();

Thanks!

Quoted 1 line

Thanx, Paul

Signature · 3 lines
Regards,
Alexander Gordeev
[email protected]
#7 lore raw
Quoted 22 lines · Alexander Gordeev
Quoted 21 lines · Paul E. McKenney
Quoted 20 lines · Alexander Gordeev
Quoted 18 lines · Paul E. McKenney
Quoted 8 lines · Alexander Gordeev
Quoted 7 lines · Paul E. McKenney
Quoted 5 lines · Alexander Gordeev

Function rcu_is_cpu_rrupt_from_idle() is called from scheduling- clock interrupt handler to check if the current CPU was interrupted from idle. If true, it results in invocation of RCU callbacks. But the common hardware interrupt exit path also contains similar check and therefore the call to rcu_is_cpu_rrupt_from_idle() is redundant.

Quoted 5 lines
Quoted 3 lines

By common hardware interrupt exit path, you are meaning the calls to rcu_irq_exit()? If not, please let me know exactly what you mean here.

Yes, I mean rcu_irq_exit().

Unless you can get the indication of whether or not the original interrupt came from userspace execution into rcu_irq_exit(), this will not work. It will result in grace-period hangs on some configurations.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

Okay, that was my concern wrt tree RCU. By contrast, tiny RCU does not seem able to hang a grace-period, isn't it?

Although it is true that tiny RCU cannot hang a synchronize_rcu() grace period, it most certainly can hang a call_rcu() grace period in exactly the same way.

Sorry for being a pain in the neck - just want to make sure I am following.

No worries!

Quoted 4 lines

I only see possibility to cause callbacks not being called for "too long" in case a system has lots of nested interrupts and rcu_idle_enter_common() is not being called from hardware interrupt context as result. How could rcu_is_cpu_rrupt_from_idle() help here?

Let's start assuming that something in the idle loop posts a callback, and then let me see if I understand your reasoning...

1. The system is idle and stays that way, no runnable tasks.

2. An interrupt occurs. Upon return from interrupt, rcu_irq_exit()
is invoked, which calls rcu_idle_enter_common(), which in turn calls rcu_sched_qs(), which does a raise_softirq(RCU_SOFTIRQ).

3. The softirq happens shortly and invokes rcu_process_callbacks(),
which invokes __rcu_process_callbacks().

4. So now callbacks can be invoked. At least they can be if

	->donetail has been updated.  Which it will have been because
	rcu_sched_qs() invokes rcu_qsctr_help().

So your point that rcu_is_cpu_rrupt_from_idle() might be redundant could well be valid -- sorry for being so dismissive earlier.

Quoted 17 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Now, if you -can- get the userspace-execution indication into rcu_irq_exit(), this might be of interest. However, it might be faster to simply let the scheduling-clock interrupt do the job as it currently does, especially for workloads with lots of interrupts.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Or did you have something else in mind?

Nope. I would even leave as is tiny RCU's rcu_is_cpu_rrupt_from_idle() for clarity then ;)

Also to avoid userspace execution from preventing RCU callbacks from ever being invoked. ;-)

Hmm.. Am I missing something else? I did not remove the userspace check from the scheduling-clock interrupt:

Review void rcu_bh_qs(void) · line 246

Quoted 8 lines
(quoted diff) +1 -1
@@ -250,7 +240,7 @@ void rcu_bh_qs(void)
 void rcu_check_callbacks(int cpu, int user)
 {
 	RCU_TRACE(check_cpu_stalls());
-	if (user || rcu_is_cpu_rrupt_from_idle())
+	if (user)
 		rcu_sched_qs();
 	else if (!in_softirq())
 		rcu_bh_qs();

Probably just me being confused. Hopefully so, as shrinking TINY_RCU further will probably be welcome.

Have you done any testing of this change?

Thanx, Paul

#8 lore raw
Quoted 22 lines · Paul E. McKenney
Quoted 5 lines
Quoted 3 lines

Although it is true that tiny RCU cannot hang a synchronize_rcu() grace period, it most certainly can hang a call_rcu() grace period in exactly the same way.

Sorry for being a pain in the neck - just want to make sure I am following.

No worries!

Quoted 4 lines

I only see possibility to cause callbacks not being called for "too long" in case a system has lots of nested interrupts and rcu_idle_enter_common() is not being called from hardware interrupt context as result. How could rcu_is_cpu_rrupt_from_idle() help here?

Let's start assuming that something in the idle loop posts a callback, and then let me see if I understand your reasoning...

1. The system is idle and stays that way, no runnable tasks.

2. An interrupt occurs. Upon return from interrupt, rcu_irq_exit()
is invoked, which calls rcu_idle_enter_common(), which in turn calls rcu_sched_qs(), which does a raise_softirq(RCU_SOFTIRQ).

Quoted 6 lines

3. The softirq happens shortly and invokes rcu_process_callbacks(),
which invokes __rcu_process_callbacks().

4. So now callbacks can be invoked. At least they can be if

	->donetail has been updated.  Which it will have been because
	rcu_sched_qs() invokes rcu_qsctr_help().

Yes, that is exactly my reasoning.

Quoted 19 lines

So your point that rcu_is_cpu_rrupt_from_idle() might be redundant could well be valid -- sorry for being so dismissive earlier.

Quoted 16 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Now, if you -can- get the userspace-execution indication into rcu_irq_exit(), this might be of interest. However, it might be faster to simply let the scheduling-clock interrupt do the job as it currently does, especially for workloads with lots of interrupts.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Or did you have something else in mind?

Nope. I would even leave as is tiny RCU's rcu_is_cpu_rrupt_from_idle() for clarity then ;)

Also to avoid userspace execution from preventing RCU callbacks from ever being invoked. ;-)

Hmm.. Am I missing something else? I did not remove the userspace check from the scheduling-clock interrupt:

Quoted 12 lines

Review void rcu_bh_qs(void) · line 246

Quoted 9 lines
(quoted diff) +1 -1
@@ -250,7 +240,7 @@ void rcu_bh_qs(void)
 void rcu_check_callbacks(int cpu, int user)
 {
 	RCU_TRACE(check_cpu_stalls());
-	if (user || rcu_is_cpu_rrupt_from_idle())
+	if (user)
 		rcu_sched_qs();
 	else if (!in_softirq())
 		rcu_bh_qs();

Probably just me being confused. Hopefully so, as shrinking TINY_RCU further will probably be welcome.

Should I resend tiny-only patch?

Quoted 1 line

Have you done any testing of this change?

Just booted to a unicore kernel and dd'ed 1G of /dev/sda to /dev/null.

Quoted 2 lines

Thanx, Paul

Signature · 3 lines
Regards,
Alexander Gordeev
[email protected]
#9 lore raw
Quoted 64 lines · Alexander Gordeev
Quoted 22 lines · Paul E. McKenney
Quoted 5 lines
Quoted 3 lines

Although it is true that tiny RCU cannot hang a synchronize_rcu() grace period, it most certainly can hang a call_rcu() grace period in exactly the same way.

Sorry for being a pain in the neck - just want to make sure I am following.

No worries!

Quoted 4 lines

I only see possibility to cause callbacks not being called for "too long" in case a system has lots of nested interrupts and rcu_idle_enter_common() is not being called from hardware interrupt context as result. How could rcu_is_cpu_rrupt_from_idle() help here?

Let's start assuming that something in the idle loop posts a callback, and then let me see if I understand your reasoning...

1. The system is idle and stays that way, no runnable tasks.

2. An interrupt occurs. Upon return from interrupt, rcu_irq_exit()
is invoked, which calls rcu_idle_enter_common(), which in turn calls rcu_sched_qs(), which does a raise_softirq(RCU_SOFTIRQ).

Quoted 6 lines

3. The softirq happens shortly and invokes rcu_process_callbacks(),
which invokes __rcu_process_callbacks().

4. So now callbacks can be invoked. At least they can be if

	->donetail has been updated.  Which it will have been because
	rcu_sched_qs() invokes rcu_qsctr_help().

Yes, that is exactly my reasoning.

Quoted 19 lines

So your point that rcu_is_cpu_rrupt_from_idle() might be redundant could well be valid -- sorry for being so dismissive earlier.

Quoted 16 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Now, if you -can- get the userspace-execution indication into rcu_irq_exit(), this might be of interest. However, it might be faster to simply let the scheduling-clock interrupt do the job as it currently does, especially for workloads with lots of interrupts.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Or did you have something else in mind?

Nope. I would even leave as is tiny RCU's rcu_is_cpu_rrupt_from_idle() for clarity then ;)

Also to avoid userspace execution from preventing RCU callbacks from ever being invoked. ;-)

Hmm.. Am I missing something else? I did not remove the userspace check from the scheduling-clock interrupt:

Quoted 12 lines

Review void rcu_bh_qs(void) · line 246

Quoted 9 lines
(quoted diff) +1 -1
@@ -250,7 +240,7 @@ void rcu_bh_qs(void)
 void rcu_check_callbacks(int cpu, int user)
 {
 	RCU_TRACE(check_cpu_stalls());
-	if (user || rcu_is_cpu_rrupt_from_idle())
+	if (user)
 		rcu_sched_qs();
 	else if (!in_softirq())
 		rcu_bh_qs();

Probably just me being confused. Hopefully so, as shrinking TINY_RCU further will probably be welcome.

Quoted 1 line

Should I resend tiny-only patch?

Please, but also expand the commit log to contain the above reasoning.

Quoted 3 lines
Quoted 1 line

Have you done any testing of this change?

Just booted to a unicore kernel and dd'ed 1G of /dev/sda to /dev/null.

OK, that is a start. Could I convince you to build a kernel?

Thanx, Paul

#10 lore raw
Quoted 5 lines · Paul E. McKenney
Quoted 3 lines
Quoted 1 line

Have you done any testing of this change?

Just booted to a unicore kernel and dd'ed 1G of /dev/sda to /dev/null.

OK, that is a start. Could I convince you to build a kernel?

I did build one with the patch I posted. Or you mean something else here?

Quoted 2 lines

Thanx, Paul

Signature · 3 lines
Regards,
Alexander Gordeev
[email protected]
#11 lore raw
Quoted 8 lines · Alexander Gordeev
Quoted 5 lines · Paul E. McKenney
Quoted 3 lines
Quoted 1 line

Have you done any testing of this change?

Just booted to a unicore kernel and dd'ed 1G of /dev/sda to /dev/null.

OK, that is a start. Could I convince you to build a kernel?

I did build one with the patch I posted. Or you mean something else here?

Something else, I think.

While running a kernel that was built with your patch, do a couple of kernel builds concurrently. ;-)

Thanx, Paul

#12 lore raw
Quoted 6 lines · Paul E. McKenney
Quoted 5 lines · Alexander Gordeev
Quoted 4 lines · Paul E. McKenney
Quoted 3 lines
Quoted 1 line

Have you done any testing of this change?

Just booted to a unicore kernel and dd'ed 1G of /dev/sda to /dev/null.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

OK, that is a start. Could I convince you to build a kernel?

I did build one with the patch I posted. Or you mean something else here?

Something else, I think.

While running a kernel that was built with your patch, do a couple of kernel builds concurrently. ;-)

Did it. No issues found. Sending updated patch shortly.

Thanks!

Quoted 2 lines

Thanx, Paul

Signature · 3 lines
Regards,
Alexander Gordeev
[email protected]
#13 lore raw

PATCH v2 1/1 rcu: Remove redundant rcu_is_cpu_rrupt_from_idle() from tiny RCU

Let's start assuming that something in the idle loop posts a callback, and scheduling-clock interrupt occurs:

1. The system is idle and stays that way, no runnable tasks.

2. Scheduling-clock interrupt occurs, rcu_check_callbacks() is called as result, which in turn calls rcu_is_cpu_rrupt_from_idle().

3. rcu_is_cpu_rrupt_from_idle() reports the CPU was interrupted from idle, which results in rcu_sched_qs() call, which does a raise_softirq(RCU_SOFTIRQ).

4. Upon return from interrupt, rcu_irq_exit() is invoked, which calls rcu_idle_enter_common(), which in turn calls rcu_sched_qs() again, which does another raise_softirq(RCU_SOFTIRQ).

5. The softirq happens shortly and invokes rcu_process_callbacks(), which invokes __rcu_process_callbacks().

6. So now callbacks can be invoked. At least they can be if ->donetail has been updated. Which it will have been because rcu_sched_qs() invokes rcu_qsctr_help().

In the described scenario rcu_sched_qs() and raise_softirq(RCU_SOFTIRQ) get called twice in steps 3 and 4. This redundancy could be eliminated by removing rcu_is_cpu_rrupt_from_idle() function.

---
 kernel/rcu/tiny.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
kernel/rcu/tiny.c +1 -11
index c0623fc..0bfb3b9 100644
@@ -186,16 +186,6 @@ EXPORT_SYMBOL(__rcu_is_watching);
 #endif /* defined(CONFIG_DEBUG_LOCK_ALLOC) || defined(CONFIG_RCU_TRACE) */
 
 /*
- * Test whether the current CPU was interrupted from idle.  Nested
- * interrupts don't count, we must be running at the first interrupt
- * level.
- */
-static int rcu_is_cpu_rrupt_from_idle(void)
-{
-	return rcu_dynticks_nesting <= 1;
-}
-
-/*
  * Helper function for rcu_sched_qs() and rcu_bh_qs().
  * Also irqs are disabled to avoid confusion due to interrupt handlers
  * invoking call_rcu().
@@ -250,7 +240,7 @@ void rcu_bh_qs(void)
 void rcu_check_callbacks(int cpu, int user)
 {
 	RCU_TRACE(check_cpu_stalls());
-	if (user || rcu_is_cpu_rrupt_from_idle())
+	if (user)
 		rcu_sched_qs();
 	else if (!in_softirq())
 		rcu_bh_qs();
Signature · 6 lines
1.8.3.1

-- 
Regards,
Alexander Gordeev
[email protected]
#14 lore raw

Re: [PATCH v2] rcu: Remove redundant rcu_is_cpu_rrupt_from_idle() from tiny RCU

Quoted 23 lines · Alexander Gordeev

Let's start assuming that something in the idle loop posts a callback, and scheduling-clock interrupt occurs:

1. The system is idle and stays that way, no runnable tasks.

2. Scheduling-clock interrupt occurs, rcu_check_callbacks() is called as result, which in turn calls rcu_is_cpu_rrupt_from_idle().

3. rcu_is_cpu_rrupt_from_idle() reports the CPU was interrupted from idle, which results in rcu_sched_qs() call, which does a raise_softirq(RCU_SOFTIRQ).

4. Upon return from interrupt, rcu_irq_exit() is invoked, which calls rcu_idle_enter_common(), which in turn calls rcu_sched_qs() again, which does another raise_softirq(RCU_SOFTIRQ).

5. The softirq happens shortly and invokes rcu_process_callbacks(), which invokes __rcu_process_callbacks().

6. So now callbacks can be invoked. At least they can be if ->donetail has been updated. Which it will have been because rcu_sched_qs() invokes rcu_qsctr_help().

Quoted 6 lines

In the described scenario rcu_sched_qs() and raise_softirq(RCU_SOFTIRQ) get called twice in steps 3 and 4. This redundancy could be eliminated by removing rcu_is_cpu_rrupt_from_idle() function.

Queued for 3.20, thank you!

Thanx, Paul

Quoted 47 lines
---
 kernel/rcu/tiny.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
kernel/rcu/tiny.c +1 -11
index c0623fc..0bfb3b9 100644
@@ -186,16 +186,6 @@ EXPORT_SYMBOL(__rcu_is_watching);
 #endif /* defined(CONFIG_DEBUG_LOCK_ALLOC) || defined(CONFIG_RCU_TRACE) */
 
 /*
- * Test whether the current CPU was interrupted from idle.  Nested
- * interrupts don't count, we must be running at the first interrupt
- * level.
- */
-static int rcu_is_cpu_rrupt_from_idle(void)
-{
-	return rcu_dynticks_nesting <= 1;
-}
-
-/*
  * Helper function for rcu_sched_qs() and rcu_bh_qs().
  * Also irqs are disabled to avoid confusion due to interrupt handlers
  * invoking call_rcu().
@@ -250,7 +240,7 @@ void rcu_bh_qs(void)
 void rcu_check_callbacks(int user)
 {
 	RCU_TRACE(check_cpu_stalls());
-	if (user || rcu_is_cpu_rrupt_from_idle())
+	if (user)
 		rcu_sched_qs();
 	else if (!in_softirq())
 		rcu_bh_qs();
Signature · 11 lines
1.8.3.1

-- 
Regards,
Alexander Gordeev
[email protected]
--
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/