tools/perf: pmu-events: Fix reproducibility
authorBen Hutchings <ben@decadent.org.uk>
Sun, 25 Aug 2019 12:49:41 +0000 (13:49 +0100)
committerSalvatore Bonaccorso <carnil@debian.org>
Wed, 9 Feb 2022 08:35:55 +0000 (08:35 +0000)
commit0d5afd3ddd59aff6c35d1a87b18c9ced2a1c328c
tree3be558d0b398c36967f770ed94f2f8b080b66c7b
parenta8811c2af4d95c524933cc0c330bca31429eb57a
tools/perf: pmu-events: Fix reproducibility

Forwarded: https://lore.kernel.org/lkml/20190825131329.naqzd5kwg7mw5d3f@decadent.org.uk/T/#u

jevents.c uses nftw() to enumerate files and outputs the corresponding
C structs in the order they are found.  This makes it sensitive to
directory ordering, so that the perf executable is not reproducible.

To avoid this, store all the files and directories found and then sort
them by their (relative) path.  (This maintains the parent-first
ordering that nftw() promises.)  Then apply the existing callbacks to
them in the sorted order.

Don't both storing the stat buffers as we don't need them.

References: https://tests.reproducible-builds.org/debian/dbdtxt/bullseye/i386/linux_4.19.37-6.diffoscope.txt.gz
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Topic bugfix/all
Gbp-Pq: Name tools-perf-pmu-events-fix-reproducibility.patch
tools/perf/pmu-events/jevents.c