]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
watchdog/softlockup: fix wrong output when watchdog_thresh < 3
authorZhenguoYao <yaozhenguo1@gmail.com>
Tue, 12 Aug 2025 07:41:32 +0000 (15:41 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Sun, 14 Sep 2025 00:32:47 +0000 (17:32 -0700)
When watchdog_thresh is below 3, sample_period will be less than 1 second.
So the following output will print when softlockup:

CPU#3 Utilization every 0s during lockup

Fix this by changing time unit from seconds to milliseconds.

Link: https://lkml.kernel.org/r/20250812074132.27810-1-yaozhenguo@jd.com
Signed-off-by: ZhenguoYao <yaozhenguo1@gmail.com>
Cc: Bitao Hu <yaoma@linux.alibaba.com>
Cc: Li Huafei <lihuafei1@huawei.com>
Cc: Max Kellermann <max.kellermann@ionos.com>
Cc: Thomas Gleinxer <tglx@linutronix.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
kernel/watchdog.c

index 80b56c002c7f123c49f65465fe7af9c74de4f46a..9c7134f7d2c48b4e9bba16c0a374f2df1da34448 100644 (file)
@@ -455,17 +455,17 @@ static void print_cpustat(void)
 {
        int i, group;
        u8 tail = __this_cpu_read(cpustat_tail);
-       u64 sample_period_second = sample_period;
+       u64 sample_period_msecond = sample_period;
 
-       do_div(sample_period_second, NSEC_PER_SEC);
+       do_div(sample_period_msecond, NSEC_PER_MSEC);
 
        /*
         * Outputting the "watchdog" prefix on every line is redundant and not
         * concise, and the original alarm information is sufficient for
         * positioning in logs, hence here printk() is used instead of pr_crit().
         */
-       printk(KERN_CRIT "CPU#%d Utilization every %llus during lockup:\n",
-              smp_processor_id(), sample_period_second);
+       printk(KERN_CRIT "CPU#%d Utilization every %llums during lockup:\n",
+              smp_processor_id(), sample_period_msecond);
 
        for (i = 0; i < NUM_SAMPLE_PERIODS; i++) {
                group = (tail + i) % NUM_SAMPLE_PERIODS;