Commit baf64b85445546a38b44052d71782dfe7531e350

Authored by Dave Hansen
Committed by Ingo Molnar
1 parent 058ebd0eba

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@quad

Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Dave Hansen <dave@sr71.net>
Link: http://lkml.kernel.org/r/20130708214404.B0B6EA66@viggo.jf.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>

Showing 1 changed file with 4 additions and 3 deletions Side-by-side Diff

arch/x86/kernel/nmi.c
... ... @@ -111,7 +111,7 @@
111 111 */
112 112 list_for_each_entry_rcu(a, &desc->head, list) {
113 113 u64 before, delta, whole_msecs;
114   - int decimal_msecs, thishandled;
  114 + int remainder_ns, decimal_msecs, thishandled;
115 115  
116 116 before = local_clock();
117 117 thishandled = a->handler(type, regs);
... ... @@ -123,8 +123,9 @@
123 123 continue;
124 124  
125 125 nmi_longest_ns = delta;
126   - whole_msecs = do_div(delta, (1000 * 1000));
127   - decimal_msecs = do_div(delta, 1000) % 1000;
  126 + whole_msecs = delta;
  127 + remainder_ns = do_div(whole_msecs, (1000 * 1000));
  128 + decimal_msecs = remainder_ns / 1000;
128 129 printk_ratelimited(KERN_INFO
129 130 "INFO: NMI handler (%ps) took too long to run: "
130 131 "%lld.%03d msecs\n", a->handler, whole_msecs,