Skip to content

Commit

Permalink
perf session: Make events_stats u64 to avoid overflow on 32-bit arches
Browse files Browse the repository at this point in the history
Pekka Enberg reported weird percentages in perf report. It
turns out we are overflowing a 32-bit variables in struct
events_stats on 32-bit architectures.

Before:

 [acme@ana linux-2.6-tip]$ perf report -i pekka.perf.data 2> /dev/null | head -10
   281.96%       Xorg                        b710a561  [.] 0x000000b710a561
   140.15%       Xorg  [kernel]                        [k] __initramfs_end
    51.56%   metacity  libgobject-2.0.so.0.2000.1      [.] 0x00000000026e46
    35.12%  evolution  libcairo.so.2.10800.6           [.] 0x000000000203bd
    33.84%   metacity  libpthread-2.9.so               [.] 0x00000000007a3d

After:

 [acme@ana linux-2.6-tip]$ perf report -i pekka.perf.data 2> /dev/null | head -10
    30.04%       Xorg                       b710a561   [.] 0x000000b710a561
    14.93%       Xorg  [kernel]                        [k] __initramfs_end
     5.49%   metacity  libgobject-2.0.so.0.2000.1      [.] 0x00000000026e46
     3.74%  evolution  libcairo.so.2.10800.6           [.] 0x000000000203bd
     3.61%   metacity  libpthread-2.9.so               [.] 0x00000000007a3d

Reported-by: Pekka Enberg <penberg@cs.helsinki.fi>
Tested-by: Pekka Enberg <penberg@cs.helsinki.fi>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <1261148583-20395-1-git-send-email-acme@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
acmel authored and Ingo Molnar committed Dec 18, 2009
1 parent 99e8c5a commit b5b60fd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tools/perf/builtin-report.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ static int __cmd_report(void)

perf_session__collapse_resort(session);
perf_session__output_resort(session, session->events_stats.total);
fprintf(stdout, "# Samples: %ld\n#\n", session->events_stats.total);
fprintf(stdout, "# Samples: %Ld\n#\n", session->events_stats.total);
perf_session__fprintf_hists(session, NULL, false, stdout);
if (sort_order == default_sort_order &&
parent_pattern == default_parent_pattern)
Expand Down
4 changes: 2 additions & 2 deletions tools/perf/util/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ typedef union event_union {
} event_t;

struct events_stats {
unsigned long total;
unsigned long lost;
u64 total;
u64 lost;
};

void event__print_totals(void);
Expand Down

0 comments on commit b5b60fd

Please sign in to comment.