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>
Sat, 6 Feb 2021 08:23:52 +0000 (08:23 +0000)
commitc4fdb7bc2a6fda01516f70c8d6e5eab8ba5ec5ff
treecc7cbe42c2d16907474f34f24937c711289594ad
parentb6e5eab3127529c3d6c2fa0ca2c824930aab4182
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