]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
x86/nmi: Improve NMI duration console printouts
authorSohil Mehta <sohil.mehta@intel.com>
Thu, 27 Mar 2025 23:46:29 +0000 (23:46 +0000)
committerIngo Molnar <mingo@kernel.org>
Tue, 1 Apr 2025 20:26:38 +0000 (22:26 +0200)
Convert the last remaining printk() in nmi.c to pr_info(). Along with
it, use timespec macros to calculate the NMI handler duration.

Signed-off-by: Sohil Mehta <sohil.mehta@intel.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Kai Huang <kai.huang@intel.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Nikolay Borisov <nik.borisov@suse.com>
Link: https://lore.kernel.org/r/20250327234629.3953536-10-sohil.mehta@intel.com
arch/x86/kernel/nmi.c

index 59ed74ec010ec83df36b62b597d5948e0d46e132..be93ec7255bfc125cd48f9f9807c07e70eff85a5 100644 (file)
@@ -119,12 +119,12 @@ static void nmi_check_duration(struct nmiaction *action, u64 duration)
 
        action->max_duration = duration;
 
-       remainder_ns = do_div(duration, (1000 * 1000));
-       decimal_msecs = remainder_ns / 1000;
+       /* Convert duration from nsec to msec */
+       remainder_ns = do_div(duration, NSEC_PER_MSEC);
+       decimal_msecs = remainder_ns / NSEC_PER_USEC;
 
-       printk_ratelimited(KERN_INFO
-               "INFO: NMI handler (%ps) took too long to run: %lld.%03d msecs\n",
-               action->handler, duration, decimal_msecs);
+       pr_info_ratelimited("INFO: NMI handler (%ps) took too long to run: %lld.%03d msecs\n",
+                           action->handler, duration, decimal_msecs);
 }
 
 static int nmi_handle(unsigned int type, struct pt_regs *regs)