Commit baf64b85 authored by Dave Hansen's avatar Dave Hansen Committed by Ingo Molnar

perf/x86: Fix incorrect use of do_div() in NMI warning

I completely botched understanding the calling conventions of
do_div().  I assumed that do_div() returned the result instead
of realizing that it modifies its argument and returns a
remainder.  The side-effect from this would be bogus numbers
for the "msecs" value in the warning messages:

	INFO: NMI handler (perf_event_nmi_handler) took too long to run: 0.114 msecs

Note, there was a second fix posted by Stephane Eranian for
a separate patch which I also botched:

	http://lkml.kernel.org/r/20130704223010.GA30625@quadSigned-off-by: default avatarDave Hansen <dave.hansen@linux.intel.com>
Cc: Dave Hansen <dave@sr71.net>
Link: http://lkml.kernel.org/r/20130708214404.B0B6EA66@viggo.jf.intel.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 058ebd0e
...@@ -111,7 +111,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2 ...@@ -111,7 +111,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
*/ */
list_for_each_entry_rcu(a, &desc->head, list) { list_for_each_entry_rcu(a, &desc->head, list) {
u64 before, delta, whole_msecs; u64 before, delta, whole_msecs;
int decimal_msecs, thishandled; int remainder_ns, decimal_msecs, thishandled;
before = local_clock(); before = local_clock();
thishandled = a->handler(type, regs); thishandled = a->handler(type, regs);
...@@ -123,8 +123,9 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2 ...@@ -123,8 +123,9 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
continue; continue;
nmi_longest_ns = delta; nmi_longest_ns = delta;
whole_msecs = do_div(delta, (1000 * 1000)); whole_msecs = delta;
decimal_msecs = do_div(delta, 1000) % 1000; remainder_ns = do_div(whole_msecs, (1000 * 1000));
decimal_msecs = remainder_ns / 1000;
printk_ratelimited(KERN_INFO printk_ratelimited(KERN_INFO
"INFO: NMI handler (%ps) took too long to run: " "INFO: NMI handler (%ps) took too long to run: "
"%lld.%03d msecs\n", a->handler, whole_msecs, "%lld.%03d msecs\n", a->handler, whole_msecs,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment