From patchwork Fri May 26 21:53:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13257419 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 E01EDC77B7C for ; Fri, 26 May 2023 23:05:52 +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=qkT6Co0r/9ht22DVGqiBy3JRlFeWBz1Ca/xIHKBNwL8=; b=n0l1r7QpNJHU/O nxpIIdKC3SA6kxmkXcAW4PuwDq7ogXkQNHyXyDXA6UWpa3Qyg2kdf4tTF3ZaEAeThasUJksrGWtf8 241l6oKsiIiP6cvAh8MOuG/ZV7gfDHIaO8IyaB0gNC0J00lFNJz4AGx3wqI7aBCNzRp0uAIeWJ0kN yvOXFY6hIoNJr0PbpJyOENCqOlbQ4H9U6Ql6V0wKh4X03hfVTr6N1T65nUB6TVpOoxtjT4m7nL+BT ZcatF0PaZQrMOlFMug2DHH6OyT3OcVkhB2bUn0mRBqNh0CsnKJeWgPyTvWmDCy7LaGCvctTK1sBOS 3UJYMPV+KnP3nx9hYnuA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q2gVC-004Eos-35; Fri, 26 May 2023 23:05:42 +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 1q2fOG-004304-2R for linux-arm-kernel@lists.infradead.org; Fri, 26 May 2023 21:54:30 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-bad1c8dce48so1839526276.0 for ; Fri, 26 May 2023 14:54:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1685138067; x=1687730067; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=5JqGxN6yla1ONavwrAlpvOZ5bTLHXY2jrhduxUQXwek=; b=4W2Y2G9aOa6y160FTO6lssRsF9BLENDx7N+3hV6iFo6ESKfNXczbaXvi5HhvCzWJlE d7T90b2MVqhrZvLb3hJpADfx2YTojrQPWsVUnUGW+YJ2TcyMgioQRwN1j4UawOTs7C67 NKQ9aNzm14VLQ81S67IDsxnjSzckX3uox3M7RJcr7vcLYzMjYg5j+1+ekCVkTMmFiMRM WCFnZfI9q/QdQHeIDLOsSm3yrZYMnPGTlPk3EAa3C+ECkp3R0+5GfRKSsFwvHXmrpRvP 5hTZObnazL4F/jIdrJYsSIASl1Xc5w82pnFAbzLXPd3F0fUw6oTev4ZT77AeiMKRFvYp a/ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685138067; x=1687730067; 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=5JqGxN6yla1ONavwrAlpvOZ5bTLHXY2jrhduxUQXwek=; b=To6k4yuUkQNG1QpN8WGjH/B+4dofF51Sd3xa8aQqQj72iiN8k5ws9v4y/px+je9zr7 8KJMwftwdM43PlXmquzcVZ0Lrge2u1TbuZ9yZ/Mn1+KPqHh0ZyJ7swNapHsym+oIo9vB Iy5Ua6Y5WTeUnU0anW8pJ627GMjLL8mmztlRqEd51BOjkzmdqjyg3QTLuu/jhsF37L6i lWw62vPv3558Wp27UfvoH0KvCmdslXzUdDuyi99B11QAnPIfvNk9LwC4yWqDesbl3bKc MRS4482AYkpMEPR6smVvkyk+yVYzUlKABuqMCCgzpmC7MGWC37yBeoDSDYq1ZTU5zxte WQMg== X-Gm-Message-State: AC+VfDyzGyTeS/jikwoNvMRt3UBEclA9xpJ8pgM6ND9Ef3ZcX6zgaCUS CbVubc+aAKnxEtlXX/P3Y19scM1DEVsd X-Google-Smtp-Source: ACHHUZ4NkuCULCa9RiO/6RfdQOF6aXh9H6urfdbhxjTo4KF9yDZrJ0iNVVbETH4SZHe4kabZR8Ki9OxLWHZM X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:3b4e:312c:644:a642]) (user=irogers job=sendgmr) by 2002:a05:6902:1206:b0:bac:f387:735b with SMTP id s6-20020a056902120600b00bacf387735bmr1234158ybu.13.1685138067659; Fri, 26 May 2023 14:54:27 -0700 (PDT) Date: Fri, 26 May 2023 14:53:41 -0700 In-Reply-To: <20230526215410.2435674-1-irogers@google.com> Message-Id: <20230526215410.2435674-7-irogers@google.com> Mime-Version: 1.0 References: <20230526215410.2435674-1-irogers@google.com> X-Mailer: git-send-email 2.41.0.rc0.172.g3f132b7071-goog Subject: [PATCH v4 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-20230526_145428_797904_F14ECC0E X-CRM114-Status: GOOD ( 14.89 ) 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 Reviewed-by: Kan Liang --- 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.