From patchwork Wed May 24 22:18:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13254641 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 70F2EC7EE33 for ; Wed, 24 May 2023 23:20:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:From:Subject:References:Mime-Version :Message-Id:In-Reply-To:Date:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=+7ryw4qfACKqZdGgI3DeU/iu8ZeN1e3e2aHGnw9bbfA=; b=BBD6RwGD5dy+HY D/FODbVg6Jk6C6cXwVrznrRpk1sgUAGp6/Cec04smxLeyMBxwFleu0r4/AaS8OQSu3Qck7XVih64/ cux+aCUD1MZ0laoKiyRT64HDKGKXUSYeurPcSd2d5ZYhBiOwuDErcw4M8gI1EqNfgs73ad4FIWlfW 05J6F1V1ObIGmkvaIdqJAtBRdV2twXjUvmFp187Sqk1a1yJjiDOJpyL1vFzkGoY6SKynZcORcbgax mmUFrCw1F6TIo1ByGxNF5fmrBEidFL8OXIPDJKCM6R0sfU0ZHlYRvPep8zelesk6N6o5VQNbJExmk EA/3H9LCbjeZ48wO1SjA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q1xmG-00Ev84-0r; Wed, 24 May 2023 23:20:20 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q1woj-00Emmj-2j for linux-arm-kernel@lists.infradead.org; Wed, 24 May 2023 22:18:51 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-babb3528ce5so2693620276.1 for ; Wed, 24 May 2023 15:18:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1684966728; x=1687558728; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=f6ARFnsShab3VUnC8Sy2LkNPFWjyLZdSNydBFV23IFk=; b=WkyS6Afb90FUud0LxsdKmCb0VbkRe9m484H8ADjpO6UNGvuAHVAye0aaglkXIEFVci ckvJxndJzT5yWtkwTLmT1ZRih/WAMKK8iVbl6mGg+Fg9UcBPc2ps+iXFU3RMUCfxMwlA zuKUkJErOORn83lxGeoRqOTkPYzw3QjsrSGo3KVE892ZYbtlt/k4h1936SSVfQxQ+ORC 15y3qDa9T2WnhVp1VIhnOdJ2oNHOIo5ntJhJREFMQ6gHS21QkbzfSlJaKOaHkxxrOVOk 9qW2OOKj3CgzG8OzkC5OhAuj1pMCs6fMC/TQmQX9Kzi2NeoFk9+P3bRLLaKtJBX/3dd6 HbOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684966728; x=1687558728; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=f6ARFnsShab3VUnC8Sy2LkNPFWjyLZdSNydBFV23IFk=; b=I/hAyD6OkW+y46MQQSpUsno8feJ5Crf3Yi4sW0ebZjm13cbiGxX/XP0CGaSqPYR7Jb 6I22HKJHS049+FziH7hsDvJ//TUK//ddUP/Nt8RBujt0b8t7YHM5TLyUmvGJX5KMwxLr 3Rj+wn88l8haN2f0+NuxMS5I97Ivrd4bYP+wY5i/kOI6g9BFk8RUbPqAma6jxCGhpKv6 U/9pcfRlcKtNlGmvZSFO7tWPGYOD9ql5nEGHAxg9DzeedqEb634FqCG24CEPriWRe8Fm fxFnZkGoFZ5SgQaYvABxfVbsFB3D5JptR+isyZpIOqjpKkZ2kSGn56wJ6p8o6zQlMLsp 55zQ== X-Gm-Message-State: AC+VfDwGkXSgqAGLFNfixuADU9MjfExzo68iasTotT/alstW1Owg8GG7 y1DOxcfUdcO/CPUCrff8fiY2u7j70lb4 X-Google-Smtp-Source: ACHHUZ7XBYnZO2uhMGuSnsWVJiC7PL6RhVQiB0SP4HBy2wQ3gSfqdJASvFAp3xt8/SSnxEeIybbl30w+RhCp X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:7aa7:3d2d:76ae:8e96]) (user=irogers job=sendgmr) by 2002:a5b:652:0:b0:ba8:8fad:c19d with SMTP id o18-20020a5b0652000000b00ba88fadc19dmr556589ybq.8.1684966728557; Wed, 24 May 2023 15:18:48 -0700 (PDT) Date: Wed, 24 May 2023 15:18:02 -0700 In-Reply-To: <20230524221831.1741381-1-irogers@google.com> Message-Id: <20230524221831.1741381-7-irogers@google.com> Mime-Version: 1.0 References: <20230524221831.1741381-1-irogers@google.com> X-Mailer: git-send-email 2.40.1.698.g37aff9b760-goog Subject: [PATCH v3 06/35] perf pmu: Add is_core to pmu From: Ian Rogers To: Suzuki K Poulose , Mike Leach , Leo Yan , John Garry , Will Deacon , James Clark , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Kajol Jain , Jing Zhang , Kan Liang , Zhengjun Xing , Ravi Bangoria , Madhavan Srinivasan , Athira Rajeev , Ming Wang , Huacai Chen , Sandipan Das , Dmitrii Dolgov <9erthalion6@gmail.com>, Sean Christopherson , Ali Saidi , Rob Herring , Thomas Richter , Kang Minchul , linux-kernel@vger.kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230524_151849_881171_C0575967 X-CRM114-Status: GOOD ( 15.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Cache is_pmu_core in the pmu to avoid recomputation. Signed-off-by: Ian Rogers --- tools/perf/util/pmu.c | 7 ++++--- tools/perf/util/pmu.h | 7 +++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index 7392cec725bf..e8c0762c311a 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -952,6 +952,7 @@ static struct perf_pmu *pmu_lookup(int dirfd, const char *lookup_name) } pmu->type = type; + pmu->is_core = is_pmu_core(name); pmu->is_uncore = pmu_is_uncore(dirfd, name); if (pmu->is_uncore) pmu->id = pmu_id(name); @@ -1659,12 +1660,12 @@ bool is_pmu_hybrid(const char *name) bool perf_pmu__supports_legacy_cache(const struct perf_pmu *pmu) { - return is_pmu_core(pmu->name); + return pmu->is_core; } bool perf_pmu__supports_wildcard_numeric(const struct perf_pmu *pmu) { - return is_pmu_core(pmu->name); + return pmu->is_core; } bool perf_pmu__auto_merge_stats(const struct perf_pmu *pmu) @@ -1723,7 +1724,7 @@ void print_pmu_events(const struct print_callbacks *print_cb, void *print_state) pmu = NULL; j = 0; while ((pmu = perf_pmu__scan(pmu)) != NULL) { - bool is_cpu = is_pmu_core(pmu->name); + bool is_cpu = pmu->is_core; list_for_each_entry(event, &pmu->aliases, list) { aliases[j].event = event; diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h index f50919f1b34c..96236a79c6fd 100644 --- a/tools/perf/util/pmu.h +++ b/tools/perf/util/pmu.h @@ -59,6 +59,13 @@ struct perf_pmu { * @selectable: Can the PMU name be selected as if it were an event? */ bool selectable; + /** + * @is_core: Is the PMU the core CPU PMU? Determined by the name being + * "cpu" or by the presence of + * /bus/event_source/devices//cpus. There may be >1 core + * PMU on systems like Intel hybrid. + */ + bool is_core; /** * @is_uncore: Is the PMU not within the CPU core? Determined by the * presence of /bus/event_source/devices//cpumask.