Skip to content

Commit

Permalink
perf jevents: Sort list of input files
Browse files Browse the repository at this point in the history
Without this, pmu-events.c would be generated with variations in
ordering depending on non-deterministic filesystem readdir order.

I tested that pmu-events.c still has the same number of lines and that
perf list output works.

This patch was done while working on reproducible builds for openSUSE,
but also solves issues in Debian [1] and other distributions.

[1] https://tests.reproducible-builds.org/debian/rb-pkg/unstable/i386/linux.html

Signed-off-by: Bernhard M. Wiedemann <bwiedemann@suse.de>
Cc: Ian Rogers <irogers@google.com>
Link: https://lore.kernel.org/r/20230321063032.19804-1-bwiedemann@suse.de
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Bernhard M. Wiedemann authored and Arnaldo Carvalho de Melo committed Mar 21, 2023
1 parent 51b02a9 commit 6362036
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tools/perf/pmu-events/jevents.py
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ def dir_path(path: str) -> str:
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 e: e.name):
if _args.model != 'all' and item.is_dir():
# Check if the model matches one in _args.model.
if len(parents) == _args.model.split(',')[0].count('/'):
Expand Down

0 comments on commit 6362036

Please sign in to comment.