Skip to content

Commit 807e0d1

Browse files
Wen YangKAGA-KOKO
authored andcommitted
tick/sched: Fix bogus condition in report_idle_softirq()
In commit 0345691 ("tick/rcu: Stop allowing RCU_SOFTIRQ in idle") the new function report_idle_softirq() was created by breaking code out of the existing can_stop_idle_tick() for kernels v5.18 and newer. In doing so, the code essentially went from this form: if (A) { static int ratelimit; if (ratelimit < 10 && !C && A&D) { pr_warn("NOHZ tick-stop error: ..."); ratelimit++; } return false; } to a new function: static bool report_idle_softirq(void) { static int ratelimit; if (likely(!A)) return false; if (ratelimit < 10) return false; ... pr_warn("NOHZ tick-stop error: local softirq work is pending, handler #%02x!!!\n", pending); ratelimit++; return true; } commit a7e282c ("tick/rcu: Fix bogus ratelimit condition") realized ratelimit was essentially set to zero instead of ten, and hence *no* softirq pending messages would ever be issued, but "fixed" it as: - if (ratelimit < 10) + if (ratelimit >= 10) return false; However, this fix introduced another issue: When ratelimit is greater than or equal 10, even if A is true, it will directly return false. While ratelimit in the original code was only used to control printing and will not affect the return value. Restore the original logic and restrict ratelimit to control the printk and not the return value. Fixes: 0345691 ("tick/rcu: Stop allowing RCU_SOFTIRQ in idle") Fixes: a7e282c ("tick/rcu: Fix bogus ratelimit condition") Signed-off-by: Wen Yang <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent 6a23ae0 commit 807e0d1

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

kernel/time/tick-sched.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,16 +1152,15 @@ static bool report_idle_softirq(void)
11521152
return false;
11531153
}
11541154

1155-
if (ratelimit >= 10)
1156-
return false;
1157-
11581155
/* On RT, softirq handling may be waiting on some lock */
11591156
if (local_bh_blocked())
11601157
return false;
11611158

1162-
pr_warn("NOHZ tick-stop error: local softirq work is pending, handler #%02x!!!\n",
1163-
pending);
1164-
ratelimit++;
1159+
if (ratelimit < 10) {
1160+
pr_warn("NOHZ tick-stop error: local softirq work is pending, handler #%02x!!!\n",
1161+
pending);
1162+
ratelimit++;
1163+
}
11651164

11661165
return true;
11671166
}

0 commit comments

Comments
 (0)