Skip to contentSkip to conversation

tick: Invalid ratelimit check

PATCH New Srinivas Pandruvada 1 participant 2 messages Aug 23, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tick: Invalid ratelimit check

In the function report_idle_softirq(), ratelimit is a static variable and checked for < 10 to return false. Since this variable is not assigned to any other value before the check, this condition will always be true.

report_idle_softirq() introduced with the
commit 0345691b24c0 ("tick/rcu: Stop allowing RCU_SOFTIRQ in idle") checks for pending soft irq during stopping of tick and returns true if tick can't be stopped.

The purpose of ratelimit is to limit printing of warning messages, so move the check for printing warning message only. Also don't return false as tick can't be stopped here for pending soft irq.

Fixes 0345691b24c0 ("tick/rcu: Stop allowing RCU_SOFTIRQ in idle")

---

One more change from the prior version of kernel:
In prior version !local_bh_blocked() check was only used for printing warning message. The output was not used to decide whether to allow tick-stop or not. But with change introduced with 5.18, the output will also decide whether to stop tick or not even if local_softirq_pending() returns true.
Not sure if this is intentional change or not.

 kernel/time/tick-sched.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
kernel/time/tick-sched.c +5 -6
index b0e3c9205946..4db634525bf4 100644
@@ -1025,16 +1025,15 @@ static bool report_idle_softirq(void)
 			return false;
 	}
 
-	if (ratelimit < 10)
-		return false;
-
 	/* On RT, softirqs handling may be waiting on some lock */
 	if (!local_bh_blocked())
 		return false;
 
-	pr_warn("NOHZ tick-stop error: local softirq work is pending, handler #%02x!!!\n",
-		pending);
-	ratelimit++;
+	if (ratelimit < 10) {
+		pr_warn("NOHZ tick-stop error: local softirq work is pending, handler #%02x!!!\n",
+			pending);
+		ratelimit++;
+	}
 
 	return true;
 }
Signature · 1 line
2.35.3
#1 lore raw

PATCH 1/1 tick: Invalid ratelimit check

In the function report_idle_softirq(), ratelimit is a static variable and checked for < 10 to return false. Since this variable is not assigned to any other value before the check, this condition will always be true.

report_idle_softirq() introduced with the
commit 0345691b24c0 ("tick/rcu: Stop allowing RCU_SOFTIRQ in idle") checks for pending soft irq during stopping of tick and returns true if tick can't be stopped.

The purpose of ratelimit is to limit printing of warning messages, so move the check for printing warning message only. Also don't return false as tick can't be stopped here for pending soft irq.

Fixes 0345691b24c0 ("tick/rcu: Stop allowing RCU_SOFTIRQ in idle")

---

One more change from prior version:
In prior version !local_bh_blocked() check was only used for printing warning message. The output was not used to decide whether to allow tick-stop or not. But with change introduced with 5.18, the output will also decide whether to stop tick or not even if local_softirq_pending() return true.

 kernel/time/tick-sched.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
kernel/time/tick-sched.c +5 -6
index b0e3c9205946..4db634525bf4 100644
@@ -1025,16 +1025,15 @@ static bool report_idle_softirq(void)
 			return false;
 	}
 
-	if (ratelimit < 10)
-		return false;
-
 	/* On RT, softirqs handling may be waiting on some lock */
 	if (!local_bh_blocked())
 		return false;
 
-	pr_warn("NOHZ tick-stop error: local softirq work is pending, handler #%02x!!!\n",
-		pending);
-	ratelimit++;
+	if (ratelimit < 10) {
+		pr_warn("NOHZ tick-stop error: local softirq work is pending, handler #%02x!!!\n",
+			pending);
+		ratelimit++;
+	}
 
 	return true;
 }
Signature · 1 line
2.35.3