* [PATCH] x86/nmi: Fix nmi_handle duration miscalculation @ 2020-08-17 9:04 Libing Zhou 2020-08-19 8:06 ` peterz 0 siblings, 1 reply; 3+ messages in thread From: Libing Zhou @ 2020-08-17 9:04 UTC (permalink / raw) To: tglx, mingo, bp, bp, x86; +Cc: linux-kernel, libing.zhou, hpa In nmi_check_duration(), the 'whole_msecs' value should get from 'duration' to reflect actual time duration, but not 'action->max_duration'. Signed-off-by: Libing Zhou <libing.zhou@nokia-sbell.com> --- arch/x86/kernel/nmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c index 4fc9954a9560..c51ee659e520 100644 --- a/arch/x86/kernel/nmi.c +++ b/arch/x86/kernel/nmi.c @@ -102,7 +102,7 @@ fs_initcall(nmi_warning_debugfs); static void nmi_check_duration(struct nmiaction *action, u64 duration) { - u64 whole_msecs = READ_ONCE(action->max_duration); + u64 whole_msecs = duration; int remainder_ns, decimal_msecs; if (duration < nmi_longest_ns || duration < action->max_duration) -- 2.22.0 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] x86/nmi: Fix nmi_handle duration miscalculation 2020-08-17 9:04 [PATCH] x86/nmi: Fix nmi_handle duration miscalculation Libing Zhou @ 2020-08-19 8:06 ` peterz 2020-08-20 2:31 ` Zhou, Libing (NSB - CN/Hangzhou) 0 siblings, 1 reply; 3+ messages in thread From: peterz @ 2020-08-19 8:06 UTC (permalink / raw) To: Libing Zhou; +Cc: tglx, mingo, bp, bp, x86, linux-kernel, hpa On Mon, Aug 17, 2020 at 05:04:41PM +0800, Libing Zhou wrote: > In nmi_check_duration(), the 'whole_msecs' value should > get from 'duration' to reflect actual time duration, > but not 'action->max_duration'. Fixes: 248ed51048c4 ("x86/nmi: Remove irq_work from the long duration NMI handler") > Signed-off-by: Libing Zhou <libing.zhou@nokia-sbell.com> > --- > arch/x86/kernel/nmi.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c > index 4fc9954a9560..c51ee659e520 100644 > --- a/arch/x86/kernel/nmi.c > +++ b/arch/x86/kernel/nmi.c > @@ -102,7 +102,7 @@ fs_initcall(nmi_warning_debugfs); > > static void nmi_check_duration(struct nmiaction *action, u64 duration) > { > - u64 whole_msecs = READ_ONCE(action->max_duration); > + u64 whole_msecs = duration; > int remainder_ns, decimal_msecs; > > if (duration < nmi_longest_ns || duration < action->max_duration) The, IMO, saner solution is: --- diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c index 4fc9954a9560..47381666d6a5 100644 --- a/arch/x86/kernel/nmi.c +++ b/arch/x86/kernel/nmi.c @@ -102,7 +102,6 @@ fs_initcall(nmi_warning_debugfs); static void nmi_check_duration(struct nmiaction *action, u64 duration) { - u64 whole_msecs = READ_ONCE(action->max_duration); int remainder_ns, decimal_msecs; if (duration < nmi_longest_ns || duration < action->max_duration) @@ -110,12 +109,12 @@ static void nmi_check_duration(struct nmiaction *action, u64 duration) action->max_duration = duration; - remainder_ns = do_div(whole_msecs, (1000 * 1000)); + remainder_ns = do_div(duration, (1000 * 1000)); decimal_msecs = remainder_ns / 1000; printk_ratelimited(KERN_INFO "INFO: NMI handler (%ps) took too long to run: %lld.%03d msecs\n", - action->handler, whole_msecs, decimal_msecs); + action->handler, duration, decimal_msecs); } static int nmi_handle(unsigned int type, struct pt_regs *regs) ^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [PATCH] x86/nmi: Fix nmi_handle duration miscalculation 2020-08-19 8:06 ` peterz @ 2020-08-20 2:31 ` Zhou, Libing (NSB - CN/Hangzhou) 0 siblings, 0 replies; 3+ messages in thread From: Zhou, Libing (NSB - CN/Hangzhou) @ 2020-08-20 2:31 UTC (permalink / raw) To: peterz; +Cc: tglx, mingo, bp, bp, x86, linux-kernel, hpa Thanks for your comments, I will recommit patch soon. -----Original Message----- From: peterz@infradead.org <peterz@infradead.org> Sent: 2020年8月19日 16:07 To: Zhou, Libing (NSB - CN/Hangzhou) <libing.zhou@nokia-sbell.com> Cc: tglx@linutronix.de; mingo@redhat.com; bp@alien8.de; bp@suse.de; x86@kernel.org; linux-kernel@vger.kernel.org; hpa@zytor.com Subject: Re: [PATCH] x86/nmi: Fix nmi_handle duration miscalculation On Mon, Aug 17, 2020 at 05:04:41PM +0800, Libing Zhou wrote: > In nmi_check_duration(), the 'whole_msecs' value should get from > 'duration' to reflect actual time duration, but not > 'action->max_duration'. Fixes: 248ed51048c4 ("x86/nmi: Remove irq_work from the long duration NMI handler") > Signed-off-by: Libing Zhou <libing.zhou@nokia-sbell.com> > --- > arch/x86/kernel/nmi.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c index > 4fc9954a9560..c51ee659e520 100644 > --- a/arch/x86/kernel/nmi.c > +++ b/arch/x86/kernel/nmi.c > @@ -102,7 +102,7 @@ fs_initcall(nmi_warning_debugfs); > > static void nmi_check_duration(struct nmiaction *action, u64 > duration) { > - u64 whole_msecs = READ_ONCE(action->max_duration); > + u64 whole_msecs = duration; > int remainder_ns, decimal_msecs; > > if (duration < nmi_longest_ns || duration < action->max_duration) The, IMO, saner solution is: --- diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c index 4fc9954a9560..47381666d6a5 100644 --- a/arch/x86/kernel/nmi.c +++ b/arch/x86/kernel/nmi.c @@ -102,7 +102,6 @@ fs_initcall(nmi_warning_debugfs); static void nmi_check_duration(struct nmiaction *action, u64 duration) { - u64 whole_msecs = READ_ONCE(action->max_duration); int remainder_ns, decimal_msecs; if (duration < nmi_longest_ns || duration < action->max_duration) @@ -110,12 +109,12 @@ static void nmi_check_duration(struct nmiaction *action, u64 duration) action->max_duration = duration; - remainder_ns = do_div(whole_msecs, (1000 * 1000)); + remainder_ns = do_div(duration, (1000 * 1000)); decimal_msecs = remainder_ns / 1000; printk_ratelimited(KERN_INFO "INFO: NMI handler (%ps) took too long to run: %lld.%03d msecs\n", - action->handler, whole_msecs, decimal_msecs); + action->handler, duration, decimal_msecs); } static int nmi_handle(unsigned int type, struct pt_regs *regs) ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-08-20 2:46 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-08-17 9:04 [PATCH] x86/nmi: Fix nmi_handle duration miscalculation Libing Zhou 2020-08-19 8:06 ` peterz 2020-08-20 2:31 ` Zhou, Libing (NSB - CN/Hangzhou)
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).