• Ian Rogers's avatar
    perf pmus: Make PMU alias name loading lazy · b1f05622
    Ian Rogers authored
    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).
    Signed-off-by: default avatarIan Rogers <irogers@google.com>
    Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
    Cc: Ravi Bangoria <ravi.bangoria@amd.com>
    Cc: James Clark <james.clark@arm.com>
    Cc: Leo Yan <leo.yan@linaro.org>
    Cc: Kan Liang <kan.liang@linux.intel.com>
    Link: https://lore.kernel.org/r/20230925062323.840799-1-irogers@google.comSigned-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
    b1f05622
pmu.c 1.01 KB