perf dso: Move build_id to dso_id
authorIan Rogers <irogers@google.com>
Thu, 24 Jul 2025 16:32:46 +0000 (09:32 -0700)
committerNamhyung Kim <namhyung@kernel.org>
Fri, 25 Jul 2025 17:37:56 +0000 (10:37 -0700)
commitd9f2ecbc5e47fca7bda7c13cff3b3534b1467b32
treee5e944f16b5bec14ec88a2e49340e7556b820771
parenteee4b66105a6fa3b85fe5260d3791d607570ba95
perf dso: Move build_id to dso_id

The dso_id previously contained the major, minor, inode and inode
generation information from a mmap2 event - the inode generation would
be zero when reading from /proc/pid/maps. The build_id was in the
dso. With build ID mmap2 events these fields wouldn't be initialized
which would largely mean the special empty case where any dso would
match for equality. This isn't desirable as if a dso is replaced we
want the comparison to yield a difference.

To support detecting the difference between DSOs based on build_id,
move the build_id out of the DSO and into the dso_id. The dso_id is
also stored in the DSO so nothing is lost. Capture in the dso_id what
parts have been initialized and rename dso_id__inject to
dso_id__improve_id so that it is clear the dso_id is being improved
upon with additional information. With the build_id in the dso_id, use
memcmp to compare for equality.

Signed-off-by: Ian Rogers <irogers@google.com>
Link: https://lore.kernel.org/r/20250724163302.596743-7-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
14 files changed:
tools/perf/builtin-buildid-list.c
tools/perf/builtin-inject.c
tools/perf/builtin-report.c
tools/perf/include/perf/perf_dlfilter.h
tools/perf/tests/symbols.c
tools/perf/util/build-id.c
tools/perf/util/dso.c
tools/perf/util/dso.h
tools/perf/util/dsos.c
tools/perf/util/machine.c
tools/perf/util/map.c
tools/perf/util/map.h
tools/perf/util/sort.c
tools/perf/util/synthetic-events.c