Skip to content

Commit

Permalink
perf tools: Fix dso_id inode generation comparison
Browse files Browse the repository at this point in the history
[ Upstream commit 68566a7 ]

Synthesized MMAP events have zero ino_generation, so do not compare
them to DSOs with a real ino_generation otherwise we end up with a DSO
without a build id.

Fixes: 0e3149f ("perf dso: Move dso_id from 'struct map' to 'struct dso'")
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: kvm@vger.kernel.org
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20220711093218.10967-2-adrian.hunter@intel.com
[ Added clarification to the comment from Ian + more detailed explanation from Adrian ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
ahunter6 authored and gregkh committed Aug 17, 2022
1 parent c7d4e6c commit 3ea02fc
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions tools/perf/util/dsos.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,19 @@ static int __dso_id__cmp(struct dso_id *a, struct dso_id *b)
if (a->ino > b->ino) return -1;
if (a->ino < b->ino) return 1;

if (a->ino_generation > b->ino_generation) return -1;
if (a->ino_generation < b->ino_generation) return 1;
/*
* Synthesized MMAP events have zero ino_generation, avoid comparing
* them with MMAP events with actual ino_generation.
*
* I found it harmful because the mismatch resulted in a new
* dso that did not have a build ID whereas the original dso did have a
* build ID. The build ID was essential because the object was not found
* otherwise. - Adrian
*/
if (a->ino_generation && b->ino_generation) {
if (a->ino_generation > b->ino_generation) return -1;
if (a->ino_generation < b->ino_generation) return 1;
}

return 0;
}
Expand Down

0 comments on commit 3ea02fc

Please sign in to comment.