Re: [PATCH v1] perf pmus: Make PMU alias name loading lazy
From: Namhyung Kim
Date: Tue Oct 03 2023 - 00:11:04 EST
On Wed, Sep 27, 2023 at 10:19 PM Ian Rogers <irogers@xxxxxxxxxx> wrote:
>
> On Wed, Sep 27, 2023 at 10:00 PM Namhyung Kim <namhyung@xxxxxxxxxx> wrote:
> >
> > Hi Ian,
> >
> > On Sun, Sep 24, 2023 at 11:24 PM Ian Rogers <irogers@xxxxxxxxxx> wrote:
> > >
> > > PMU alias names were computed when the first perf_pmu is created,
> > > scanning all PMUs in event sources for a file called alias that
> > > generally doesn't exist. Switch to trying to load the file when all
> > > PMU related files are loaded in lookup. This would cause a PMU name
> > > lookup of an alias name to fail if no PMUs were loaded, so in that
> > > case all PMUs are loaded and the find repeated. The overhead is
> > > similar but in the (very) general case not all PMUs are scanned for
> > > the alias file.
> > >
> > > As the overhead occurs once per invocation it doesn't show in perf
> > > bench internals pmu-scan. On a tigerlake machine, the number of openat
> > > system calls for an event of cpu/cycles/ with perf stat reduces from
> > > 94 to 69 (ie 25 fewer openat calls).
> >
> > I think the pmu-scan bench could show the difference as it
> > calls perf_pmu__destroy() in the loop body. So every call to
> > perf_pmu__scan() should start from nothing, right?
>
> The PMU alias name list was funny. It is/was maintained in the x86
> specific PMU code and the destroy didn't clear the list. This change
> adds an openat to loading a PMU for the alias, so pmu-scan shows a
> very small slow down. However, in the more normal cases we're reducing
> the number of openats by 25%.
I think that's ok. Applied to perf-tools-next, thanks!