Skip to content
/ linux Public

Commit 5e22785

Browse files
HSM6236Sasha Levin
authored andcommitted
watchdog/softlockup: fix sample ring index wrap in need_counting_irqs()
[ Upstream commit cafe407 ] cpustat_tail indexes cpustat_util[], which is a NUM_SAMPLE_PERIODS-sized ring buffer. need_counting_irqs() currently wraps the index using NUM_HARDIRQ_REPORT, which only happens to match NUM_SAMPLE_PERIODS. Use NUM_SAMPLE_PERIODS for the wrap to keep the ring math correct even if the NUM_HARDIRQ_REPORT or NUM_SAMPLE_PERIODS changes. Link: https://lkml.kernel.org/r/tencent_7068189CB6D6689EB353F3D17BF5A5311A07@qq.com Fixes: e9a9292 ("watchdog/softlockup: Report the most frequent interrupts") Signed-off-by: Shengming Hu <hu.shengming@zte.com.cn> Reviewed-by: Petr Mladek <pmladek@suse.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Mark Brown <broonie@kernel.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Zhang Run <zhang.run@zte.com.cn> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent d14871c commit 5e22785

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/watchdog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ static bool need_counting_irqs(void)
521521
u8 util;
522522
int tail = __this_cpu_read(cpustat_tail);
523523

524-
tail = (tail + NUM_HARDIRQ_REPORT - 1) % NUM_HARDIRQ_REPORT;
524+
tail = (tail + NUM_SAMPLE_PERIODS - 1) % NUM_SAMPLE_PERIODS;
525525
util = __this_cpu_read(cpustat_util[tail][STATS_HARDIRQ]);
526526
return util > HARDIRQ_PERCENT_THRESH;
527527
}

0 commit comments

Comments
 (0)