Skip to content

Commit

Permalink
perf bench internals inject-build-id: Fix trap divide when collecting…
Browse files Browse the repository at this point in the history
… just one DSO

'perf bench internals inject-build-id' suffers from the following error when
only one DSO is collected.

  # perf bench internals inject-build-id -v
    Collected 1 DSOs
  traps: internals-injec[2305] trap divide error
  ip:557566ba6394 sp:7ffd4de97fe0 error:0 in perf[557566b2a000+23d000]
    Build-id injection benchmark
    Iteration #1
  Floating point exception

This patch removes the unnecessary minus one from the divisor which also
corrects the randomization range.

Signed-off-by: He Zhe <[email protected]>
Fixes: 0bf02a0 ("perf bench: Add build-id injection benchmark")
Cc: Adrian Hunter <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Ian Rogers <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Mark Rutland <[email protected]>
Cc: Namhyung Kim <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
He Zhe authored and acmel committed May 7, 2024
1 parent b78854e commit d9180e2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tools/perf/bench/inject-buildid.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ static int inject_build_id(struct bench_data *data, u64 *max_rss)
return -1;

for (i = 0; i < nr_mmaps; i++) {
int idx = rand() % (nr_dsos - 1);
int idx = rand() % nr_dsos;
struct bench_dso *dso = &dsos[idx];
u64 timestamp = rand() % 1000000;

Expand Down

0 comments on commit d9180e2

Please sign in to comment.