Skip to contentSkip to conversation

tick: Fix softirq related warnings

PATCH In review Frederic Weisbecker 3 participants 7 messages Feb 8, 2022 – Feb 14, 2022

Subsystems (2)
lore
Share & tools
lore

Frederic Weisbecker

author maintainer
#0 lore raw

cover tick: Fix softirq related warnings

Some cleanups and debug rework.

git://git.kernel.org/pub/scm/linux/kernel/git/frederic/linux-dynticks.git
timers/core

HEAD: 18b00369d58da4c73946d5f8ebed8e8c7ade89e2

Thanks,
Frederic
---

Frederic Weisbecker (3):
tick/rcu: Remove obsolete rcu_needs_cpu() parameters tick/rcu: Stop allowing RCU_SOFTIRQ in idle
lib/irq_poll: Declare IRQ_POLL softirq vector as ksoftirqd-parking safe

 include/linux/interrupt.h | 11 ++++++++-
 include/linux/rcutiny.h   |  3 +--
 include/linux/rcutree.h   |  2 +-
 kernel/rcu/tree.c         |  3 +--
 kernel/time/tick-sched.c  | 60 ++++++++++++++++++++++++++++++++++-------------
 5 files changed, 57 insertions(+), 22 deletions(-)
author maintainer
#1 lore raw

PATCH 1/3 tick/rcu: Remove obsolete rcu_needs_cpu() parameters

With the removal of CONFIG_RCU_FAST_NO_HZ, the parameters in rcu_needs_cpu() are not necessary anymore. Simply remove them.

Cc Thomas Gleixner <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Paul E. McKenney <[email protected]>
Cc Paul Menzel <[email protected]>
---
 include/linux/rcutiny.h  |  3 +--
 include/linux/rcutree.h  |  2 +-
 kernel/rcu/tree.c        |  3 +--
 kernel/time/tick-sched.c | 10 ++++------
 4 files changed, 7 insertions(+), 11 deletions(-)
include/linux/rcutiny.h +1 -2
index 858f4d429946..5fed476f977f 100644
@@ -64,9 +64,8 @@ static inline void rcu_softirq_qs(void)
 		rcu_tasks_qs(current, (preempt)); \
 	} while (0)
 
-static inline int rcu_needs_cpu(u64 basemono, u64 *nextevt)
+static inline int rcu_needs_cpu(void)
 {
-	*nextevt = KTIME_MAX;
 	return 0;
 }
 
include/linux/rcutree.h +1 -1
index 53209d669400..6cc91291d078 100644
@@ -19,7 +19,7 @@
 
 void rcu_softirq_qs(void);
 void rcu_note_context_switch(bool preempt);
-int rcu_needs_cpu(u64 basem, u64 *nextevt);
+int rcu_needs_cpu(void);
 void rcu_cpu_stall_reset(void);
 
 /*
kernel/rcu/tree.c +1 -2
index a4c25a6283b0..80faf2273ce9 100644
@@ -1086,9 +1086,8 @@ void rcu_irq_enter_irqson(void)
  * Just check whether or not this CPU has non-offloaded RCU callbacks
  * queued.
  */
-int rcu_needs_cpu(u64 basemono, u64 *nextevt)
+int rcu_needs_cpu(void)
 {
-	*nextevt = KTIME_MAX;
 	return !rcu_segcblist_empty(&this_cpu_ptr(&rcu_data)->cblist) &&
 		!rcu_rdp_is_offloaded(this_cpu_ptr(&rcu_data));
 }
kernel/time/tick-sched.c +4 -6
index 17a283ce2b20..2abb5112feb9 100644
@@ -768,7 +768,7 @@ static inline bool local_timer_softirq_pending(void)
 
 static ktime_t tick_nohz_next_event(struct tick_sched *ts, int cpu)
 {
-	u64 basemono, next_tick, next_tmr, next_rcu, delta, expires;
+	u64 basemono, next_tick, delta, expires;
 	unsigned long basejiff;
 	unsigned int seq;
 
@@ -791,7 +791,7 @@ static ktime_t tick_nohz_next_event(struct tick_sched *ts, int cpu)
 	 * minimal delta which brings us back to this place
 	 * immediately. Lather, rinse and repeat...
 	 */
-	if (rcu_needs_cpu(basemono, &next_rcu) || arch_needs_cpu() ||
+	if (rcu_needs_cpu() || arch_needs_cpu() ||
 	    irq_work_needs_cpu() || local_timer_softirq_pending()) {
 		next_tick = basemono + TICK_NSEC;
 	} else {
@@ -802,10 +802,8 @@ static ktime_t tick_nohz_next_event(struct tick_sched *ts, int cpu)
 		 * disabled this also looks at the next expiring
 		 * hrtimer.
 		 */
-		next_tmr = get_next_timer_interrupt(basejiff, basemono);
-		ts->next_timer = next_tmr;
-		/* Take the next rcu event into account */
-		next_tick = next_rcu < next_tmr ? next_rcu : next_tmr;
+		next_tick = get_next_timer_interrupt(basejiff, basemono);
+		ts->next_timer = next_tick;
 	}
 
 	/*
Signature · 1 line
2.25.1
author maintainer
#2 lore raw

PATCH 2/3 tick/rcu: Stop allowing RCU_SOFTIRQ in idle

In reply to Frederic Weisbecker

RCU_SOFTIRQ used to be special in that it could be raised on purpose within the idle path to prevent from stopping the tick. Some code still prevents from unnecessary warnings related to this specific behaviour while entering in dynticks-idle mode.

However the nohz layout has changed quite a bit in ten years, and the removal of CONFIG_RCU_FAST_NO_HZ has been the final straw to this safe-conduct. Now the RCU_SOFTIRQ vector is expected to be raised from sane places.

A remaining corner case is admitted though when the vector is invoked in fragile hotplug path.

Cc Thomas Gleixner <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Paul E. McKenney <[email protected]>
Cc Paul Menzel <[email protected]>
---
 include/linux/interrupt.h |  8 ++++++-
 kernel/time/tick-sched.c  | 50 +++++++++++++++++++++++++++++++--------
 2 files changed, 47 insertions(+), 11 deletions(-)
include/linux/interrupt.h +7 -1
index 9367f1cb2e3c..9613326d2f8a 100644
@@ -579,7 +579,13 @@ enum
 	NR_SOFTIRQS
 };
 
-#define SOFTIRQ_STOP_IDLE_MASK (~(1 << RCU_SOFTIRQ))
+/*
+ * Ignoring the RCU vector after ksoftirqd is parked is fine
+ * because:
+ * 	1) rcutree_migrate_callbacks() takes care of the queue.
+ * 	2) rcu_report_dead() reports the final quiescent states.
+ */
+#define SOFTIRQ_HOTPLUG_SAFE_MASK (BIT(RCU_SOFTIRQ))
 
 /* map softirq index to softirq name. update 'softirq_to_name' in
  * kernel/softirq.c when adding a new softirq.
kernel/time/tick-sched.c +40 -10

63 lines not on this page · raw message

Signature · 1 line
2.25.1
author maintainer
#3 lore raw

PATCH 3/3 lib/irq_poll: Declare IRQ_POLL softirq vector as ksoftirqd-parking safe

In reply to Frederic Weisbecker

The following warning may appear while setting a CPU down:

NOHZ tick-stop error: Non-RCU local softirq work is pending, handler #20!!!

The IRQ_POLL_SOFTIRQ vector can be raised during the hotplug cpu_down() path after ksoftirqd is parked and before the CPU actually dies. However this is handled afterward at the CPUHP_IRQ_POLL_DEAD stage where the queue gets migrated.

Hence this warning can be considered spurious and the vector can join the "hotplug-safe" list.

Cc Thomas Gleixner <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Paul E. McKenney <[email protected]>
Cc Paul Menzel <[email protected]>
---
 include/linux/interrupt.h | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
include/linux/interrupt.h +7 -4
index 9613326d2f8a..f40754caaefa 100644
@@ -580,12 +580,15 @@ enum
 };
 
 /*
- * Ignoring the RCU vector after ksoftirqd is parked is fine
- * because:
- * 	1) rcutree_migrate_callbacks() takes care of the queue.
+ * The following vectors can be safely ignored after ksoftirqd is parked:
+ *
+ * _ RCU:
+ * 	1) rcutree_migrate_callbacks() migrates the queue.
  * 	2) rcu_report_dead() reports the final quiescent states.
+ *
+ * _ IRQ_POLL: irq_poll_cpu_dead() migrates the queue
  */
-#define SOFTIRQ_HOTPLUG_SAFE_MASK (BIT(RCU_SOFTIRQ))
+#define SOFTIRQ_HOTPLUG_SAFE_MASK (BIT(RCU_SOFTIRQ) | BIT(IRQ_POLL_SOFTIRQ))
 
 /* map softirq index to softirq name. update 'softirq_to_name' in
  * kernel/softirq.c when adding a new softirq.
Signature · 1 line
2.25.1
maintainer
#4 lore raw
In reply to Frederic Weisbecker
Quoted 7 lines · Frederic Weisbecker

Some cleanups and debug rework.

git://git.kernel.org/pub/scm/linux/kernel/git/frederic/linux-dynticks.git
timers/core

HEAD: 18b00369d58da4c73946d5f8ebed8e8c7ade89e2

Quoted 8 lines

Thanks,
Frederic
---

Frederic Weisbecker (3):
tick/rcu: Remove obsolete rcu_needs_cpu() parameters tick/rcu: Stop allowing RCU_SOFTIRQ in idle
lib/irq_poll: Declare IRQ_POLL softirq vector as ksoftirqd-parking safe

I have queued these for local testing, but I am guessing that you would like them to go up some other path.

Thanx, Paul

Quoted 6 lines
 include/linux/interrupt.h | 11 ++++++++-
 include/linux/rcutiny.h   |  3 +--
 include/linux/rcutree.h   |  2 +-
 kernel/rcu/tree.c         |  3 +--
 kernel/time/tick-sched.c  | 60 ++++++++++++++++++++++++++++++++++-------------
 5 files changed, 57 insertions(+), 22 deletions(-)
Tested-by on the v1 series
#5 lore raw
In reply to Frederic Weisbecker

Dear Frederic,

Am 08.02.22 um 17:16 schrieb Frederic Weisbecker:

Quoted 17 lines

Some cleanups and debug rework.

git://git.kernel.org/pub/scm/linux/kernel/git/frederic/linux-dynticks.git
timers/core

HEAD: 18b00369d58da4c73946d5f8ebed8e8c7ade89e2

Thanks,
Frederic
---

Frederic Weisbecker (3):
tick/rcu: Remove obsolete rcu_needs_cpu() parameters tick/rcu: Stop allowing RCU_SOFTIRQ in idle
lib/irq_poll: Declare IRQ_POLL softirq vector as ksoftirqd-parking safe

Quoted 6 lines
  include/linux/interrupt.h | 11 ++++++++-
  include/linux/rcutiny.h   |  3 +--
  include/linux/rcutree.h   |  2 +-
  kernel/rcu/tree.c         |  3 +--
  kernel/time/tick-sched.c  | 60 ++++++++++++++++++++++++++++++++++-------------
  5 files changed, 57 insertions(+), 22 deletions(-)

I tested this series on the IBM S822LC with Ubuntu 20.10 and rcu/dev (commit 0ba8896d2fd7 (lib/irq_poll: Declare IRQ_POLL softirq vector as ksoftirqd-parking safe)). Running sudo ppc64_cpu --smt=off the warnings are gone.

Kind regards,

Paul

maintainer
#6 lore raw
Quoted 28 lines · Paul Menzel

Dear Frederic,

Am 08.02.22 um 17:16 schrieb Frederic Weisbecker:

Quoted 17 lines

Some cleanups and debug rework.

git://git.kernel.org/pub/scm/linux/kernel/git/frederic/linux-dynticks.git
timers/core

HEAD: 18b00369d58da4c73946d5f8ebed8e8c7ade89e2

Thanks,
Frederic
---

Frederic Weisbecker (3):
tick/rcu: Remove obsolete rcu_needs_cpu() parameters tick/rcu: Stop allowing RCU_SOFTIRQ in idle
lib/irq_poll: Declare IRQ_POLL softirq vector as ksoftirqd-parking safe

Quoted 6 lines
  include/linux/interrupt.h | 11 ++++++++-
  include/linux/rcutiny.h   |  3 +--
  include/linux/rcutree.h   |  2 +-
  kernel/rcu/tree.c         |  3 +--
  kernel/time/tick-sched.c  | 60 ++++++++++++++++++++++++++++++++++-------------
  5 files changed, 57 insertions(+), 22 deletions(-)
Quoted 6 lines

I tested this series on the IBM S822LC with Ubuntu 20.10 and rcu/dev (commit 0ba8896d2fd7 (lib/irq_poll: Declare IRQ_POLL softirq vector as ksoftirqd-parking safe)). Running sudo ppc64_cpu --smt=off the warnings are gone.

I will apply on my next rebase, thank you!

And thanks to Peter and Christophe for chasing this down!

Thanx, Paul