Skip to content

Commit f94c91f

Browse files
Libing Zhousuryasaimadhu
authored andcommitted
x86/nmi: Fix nmi_handle() duration miscalculation
When nmi_check_duration() is checking the time an NMI handler took to execute, the whole_msecs value used should be read from the @duration argument, not from the ->max_duration, the latter being used to store the current maximal duration. [ bp: Rewrite commit message. ] Fixes: 248ed51 ("x86/nmi: Remove irq_work from the long duration NMI handler") Suggested-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Libing Zhou <libing.zhou@nokia-sbell.com> Signed-off-by: Borislav Petkov <bp@suse.de> Cc: Changbin Du <changbin.du@gmail.com> Link: https://lkml.kernel.org/r/20200820025641.44075-1-libing.zhou@nokia-sbell.com
1 parent ea4e3be commit f94c91f

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

arch/x86/kernel/nmi.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,20 +102,19 @@ fs_initcall(nmi_warning_debugfs);
102102

103103
static void nmi_check_duration(struct nmiaction *action, u64 duration)
104104
{
105-
u64 whole_msecs = READ_ONCE(action->max_duration);
106105
int remainder_ns, decimal_msecs;
107106

108107
if (duration < nmi_longest_ns || duration < action->max_duration)
109108
return;
110109

111110
action->max_duration = duration;
112111

113-
remainder_ns = do_div(whole_msecs, (1000 * 1000));
112+
remainder_ns = do_div(duration, (1000 * 1000));
114113
decimal_msecs = remainder_ns / 1000;
115114

116115
printk_ratelimited(KERN_INFO
117116
"INFO: NMI handler (%ps) took too long to run: %lld.%03d msecs\n",
118-
action->handler, whole_msecs, decimal_msecs);
117+
action->handler, duration, decimal_msecs);
119118
}
120119

121120
static int nmi_handle(unsigned int type, struct pt_regs *regs)

0 commit comments

Comments
 (0)