[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAP-5=fUGbT8=spY=e6NPJvf_+Ct6VksFzWM6Eybf=gst_J=Xmw@mail.gmail.com>
Date: Mon, 20 Mar 2023 13:48:38 -0700
From: Ian Rogers <irogers@...gle.com>
To: "Bernhard M. Wiedemann" <bwiedemann@...e.de>,
Ben Hutchings <benh@...ian.org>
Cc: Arnaldo Carvalho de Melo <acme@...nel.org>,
linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] perf jevents: Sort list of input files
On Mon, Mar 20, 2023 at 1:19 PM Bernhard M. Wiedemann
<bwiedemann@...e.de> wrote:
>
> 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@...e.de>
> CC: Ian Rogers <irogers@...gle.com>
> ---
> tools/perf/pmu-events/jevents.py | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
Thanks Bernhard,
I think this may already be addressed by sorting prior to output:
https://lore.kernel.org/r/20220812230949.683239-5-irogers@google.com
Could you confirm?
Thanks,
Ian
>
> diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py
> index 2bcd07ce609f..f06e1abac7c7 100755
> --- a/tools/perf/pmu-events/jevents.py
> +++ b/tools/perf/pmu-events/jevents.py
> @@ -381,10 +381,13 @@ def read_json_events(path: str, topic: str) -> Sequence[JsonEvent]:
>
> return events
>
> +def sorted_scandir(path: str) -> list[os.DirEntry]:
> + return sorted(os.scandir(path), key=lambda e: e.name)
> +
> def preprocess_arch_std_files(archpath: str) -> None:
> """Read in all architecture standard events."""
> global _arch_std_events
> - for item in os.scandir(archpath):
> + for item in sorted_scandir(archpath):
> if item.is_file() and item.name.endswith('.json'):
> for event in read_json_events(item.path, topic=''):
> if event.name:
> @@ -497,7 +500,7 @@ def preprocess_one_file(parents: Sequence[str], item: os.DirEntry) -> None:
> def process_one_file(parents: Sequence[str], item: os.DirEntry) -> None:
> """Process a JSON file during the main walk."""
> def is_leaf_dir(path: str) -> bool:
> - for item in os.scandir(path):
> + for item in sorted_scandir(path):
> if item.is_dir():
> return False
> return True
> @@ -889,7 +892,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_scandir(path):
> 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('/'):
> @@ -930,7 +933,7 @@ struct compact_pmu_event {
>
> """)
> archs = []
> - for item in os.scandir(_args.starting_dir):
> + for item in sorted_scandir(_args.starting_dir):
> if not item.is_dir():
> continue
> if item.name == _args.arch or _args.arch == 'all' or item.name == 'test':
> --
> 2.35.3
>
Powered by blists - more mailing lists