lkml.org 
[lkml]   [2023]   [May]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    Subject[PATCH v4 17/35] perf pmu: Rewrite perf_pmu__has_hybrid to avoid list
    From
    Rather than list empty on perf_pmu__hybrid_pmus, detect if any core
    PMUs match the hybrid name. Computed values held in statics to avoid
    recomputation.

    Signed-off-by: Ian Rogers <irogers@google.com>
    Reviewed-by: Kan Liang <kan.liang@linux.intel.com>
    ---
    tools/perf/util/pmu.c | 16 +++++++++++-----
    1 file changed, 11 insertions(+), 5 deletions(-)

    diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
    index 83c7eeb8abea..5a7bfbf621d0 100644
    --- a/tools/perf/util/pmu.c
    +++ b/tools/perf/util/pmu.c
    @@ -60,8 +60,6 @@ struct perf_pmu_format {
    struct list_head list;
    };

    -static bool hybrid_scanned;
    -
    static struct perf_pmu *perf_pmu__find2(int dirfd, const char *name);

    /*
    @@ -2013,12 +2011,20 @@ void perf_pmu__warn_invalid_config(struct perf_pmu *pmu, __u64 config,

    bool perf_pmu__has_hybrid(void)
    {
    + static bool hybrid_scanned, has_hybrid;
    +
    if (!hybrid_scanned) {
    + struct perf_pmu *pmu = NULL;
    +
    + while ((pmu = perf_pmu__scan(pmu)) != NULL) {
    + if (pmu->is_core && is_pmu_hybrid(pmu->name)) {
    + has_hybrid = true;
    + break;
    + }
    + }
    hybrid_scanned = true;
    - perf_pmu__scan(NULL);
    }
    -
    - return !list_empty(&perf_pmu__hybrid_pmus);
    + return has_hybrid;
    }

    int perf_pmu__match(char *pattern, char *name, char *tok)
    --
    2.41.0.rc0.172.g3f132b7071-goog
    \
     
     \ /
      Last update: 2023-05-26 23:56    [W:4.109 / U:0.136 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site