[PATCH] tick/rcu: fix an issue in the report_idle_softirq function

wenyang.linux@foxmail.com posted 1 patch 2 years, 9 months ago
kernel/time/tick-sched.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] tick/rcu: fix an issue in the report_idle_softirq function
Posted by wenyang.linux@foxmail.com 2 years, 9 months ago
From: Wen Yang <wenyang.linux@foxmail.com>

Commit 0345691b24c0 ("tick/rcu: Stop allowing RCU_SOFTIRQ in idle")
introduced the function report_idle_softirq, but the ratelimit logic
was broken because it is a static variable that returned before being
incremented, as follows:

	static int ratelimit;
...

	if (ratelimit < 10)
		return false;  ---> always return here
...
	ratelimit++;           ---> no chance to run

We need to adjust  the original "< 10" logic to ">= 10".

Fixes: 0345691b24c0 ("tick/rcu: Stop allowing RCU_SOFTIRQ in idle")
Signed-off-by: Wen Yang <wenyang.linux@foxmail.com>
Cc: Frederic Weisbecker <frederic@kernel.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Paul E. McKenney <paulmck@kernel.org>
Cc: Paul Menzel <pmenzel@molgen.mpg.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org
---
 kernel/time/tick-sched.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index a46506f7ec6d..8891ad1d9a11 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -1035,7 +1035,7 @@ static bool report_idle_softirq(void)
 			return false;
 	}
 
-	if (ratelimit < 10)
+	if (ratelimit >= 10)
 		return false;
 
 	/* On RT, softirqs handling may be waiting on some lock */
-- 
2.25.1
[tip: timers/core] tick/rcu: Fix bogus ratelimit condition
Posted by tip-bot2 for Wen Yang 2 years, 7 months ago
The following commit has been merged into the timers/core branch of tip:

Commit-ID:     a7e282c77785c7eabf98836431b1f029481085ad
Gitweb:        https://git.kernel.org/tip/a7e282c77785c7eabf98836431b1f029481085ad
Author:        Wen Yang <wenyang.linux@foxmail.com>
AuthorDate:    Fri, 05 May 2023 00:12:53 +08:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Sun, 18 Jun 2023 22:41:53 +02:00

tick/rcu: Fix bogus ratelimit condition

The ratelimit logic in report_idle_softirq() is broken because the
exit condition is always true:

	static int ratelimit;

	if (ratelimit < 10)
		return false;  ---> always returns here

	ratelimit++;           ---> no chance to run

Make it check for >= 10 instead.

Fixes: 0345691b24c0 ("tick/rcu: Stop allowing RCU_SOFTIRQ in idle")
Signed-off-by: Wen Yang <wenyang.linux@foxmail.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/tencent_5AAA3EEAB42095C9B7740BE62FBF9A67E007@qq.com

---
 kernel/time/tick-sched.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 5225467..8905505 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -1030,7 +1030,7 @@ static bool report_idle_softirq(void)
 			return false;
 	}
 
-	if (ratelimit < 10)
+	if (ratelimit >= 10)
 		return false;
 
 	/* On RT, softirqs handling may be waiting on some lock */
[tip: timers/core] tick/rcu: Fix bogus ratelimit condition
Posted by tip-bot2 for Wen Yang 2 years, 8 months ago
The following commit has been merged into the timers/core branch of tip:

Commit-ID:     5579a8a8f15bd08b731a015630daca6ccd0f8a14
Gitweb:        https://git.kernel.org/tip/5579a8a8f15bd08b731a015630daca6ccd0f8a14
Author:        Wen Yang <wenyang.linux@foxmail.com>
AuthorDate:    Fri, 05 May 2023 00:12:53 +08:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Sat, 10 Jun 2023 14:36:17 +02:00

tick/rcu: Fix bogus ratelimit condition

The ratelimit logic in report_idle_softirq() is broken because the
exit condition is always true:

	static int ratelimit;

	if (ratelimit < 10)
		return false;  ---> always returns here

	ratelimit++;           ---> no chance to run

Make it check for >= 10 instead.

Fixes: 0345691b24c0 ("tick/rcu: Stop allowing RCU_SOFTIRQ in idle")
Signed-off-by: Wen Yang <wenyang.linux@foxmail.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/tencent_5AAA3EEAB42095C9B7740BE62FBF9A67E007@qq.com

---
 kernel/time/tick-sched.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 5225467..8905505 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -1030,7 +1030,7 @@ static bool report_idle_softirq(void)
 			return false;
 	}
 
-	if (ratelimit < 10)
+	if (ratelimit >= 10)
 		return false;
 
 	/* On RT, softirqs handling may be waiting on some lock */