From b2df7b8ea902c861da90399aa8dc7f6fd18ec0b8 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Sun, 25 Aug 2019 13:49:41 +0100 Subject: [PATCH] tools/perf: pmu-events: Fix reproducibility Forwarded: https://lore.kernel.org/lkml/20190825131329.naqzd5kwg7mw5d3f@decadent.org.uk/T/#u jevents.py enumerates 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, sort the entries returned by os.scandir() before processing them. References: https://tests.reproducible-builds.org/debian/dbdtxt/bullseye/i386/linux_4.19.37-6.diffoscope.txt.gz Signed-off-by: Ben Hutchings Gbp-Pq: Topic bugfix/all Gbp-Pq: Name tools-perf-pmu-events-fix-reproducibility.patch --- tools/perf/pmu-events/jevents.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py index 0daa3e00752..96c7ea04013 100755 --- a/tools/perf/pmu-events/jevents.py +++ b/tools/perf/pmu-events/jevents.py @@ -663,7 +663,7 @@ def main() -> None: def ftw(path: str, parents: Sequence[str], action: Callable[[Sequence[str], os.DirEntry], None]) -> None: """Replicate the directory/file walking behavior of C's file tree walk.""" - for item in os.scandir(path): + for item in sorted(os.scandir(path), key=(lambda item: item.name)): action(parents, item) if item.is_dir(): ftw(item.path, parents + [item.name], action) -- 2.30.2