From patchwork Wed Mar 3 15:22:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 12114465 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A585C433DB for ; Wed, 3 Mar 2021 22:55:04 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A841E64EF9 for ; Wed, 3 Mar 2021 22:55:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A841E64EF9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=U4jlWcgjC1erbZ87GrPiU3YXZJ3M2E0E6YRiaPnwD4E=; b=YDomIe7dg5QUpcttvUZP6FcVF ke9nVLcl52qTd51Sskhs7zhECU2c0IpYYETuwz/xD6gw89p5gkDOO8UtCR0Cf09YpUqmjPwNxy4z2 qc17y2w4wNlLDVg3tP7fd7Tup7ulIBkKDmuddpugwI/vrb7kvsSSpFm7i6y1dmzOMWZtr3uKpF+B6 LbADLFpCq5QIOwifKcWRyW/48Tbb/BTdLpke32L4UtRmKQcPx8Op89h8lOax0CjErXyp3etME7i/c edd0IYLXBCSUfyS8QR69jnQEdQUr8bmK4a3WvB18a3N7/kCQtxfy/btIUVs0dBgssNTy3tfAviBdd 2g7m3iu9w==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHaLx-006okn-VL; Wed, 03 Mar 2021 22:52:26 +0000 Received: from szxga04-in.huawei.com ([45.249.212.190]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHTOp-005Ncs-Ra for linux-arm-kernel@lists.infradead.org; Wed, 03 Mar 2021 15:26:58 +0000 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4DrHqV5DbZz16G08; Wed, 3 Mar 2021 23:24:54 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.498.0; Wed, 3 Mar 2021 23:26:27 +0800 From: John Garry To: , , , , , , , , , CC: , , , , , , , John Garry Subject: [PATCH 1/5] perf metricgroup: Support printing metrics for arm64 Date: Wed, 3 Mar 2021 23:22:14 +0800 Message-ID: <1614784938-27080-2-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1614784938-27080-1-git-send-email-john.garry@huawei.com> References: <1614784938-27080-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] X-CFilter-Loop: Reflected 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 Calling perf_pmu__find_map(NULL) returns the cpumap for the common CPU PMU. However arm64 supports heterogeneous-CPU based systems, and so there may be no common CPU PMU. As such, perf_pmu__find_map(NULL) returns NULL for arm64. To support printing metrics for arm64, iterate through all PMUs, looking for a CPU PMU, and use the cpumap there for determining supported metrics. For heterogeneous systems (like arm big.LITTLE), supporting metrics has potential challenges, like not all CPUs in a system not supporting a specific metric event. So just don't support it for now. Signed-off-by: John Garry --- tools/perf/util/metricgroup.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c index 26c990e32378..9a2a23093961 100644 --- a/tools/perf/util/metricgroup.c +++ b/tools/perf/util/metricgroup.c @@ -6,6 +6,7 @@ /* Manage metrics and groups of metrics from JSON files */ #include "metricgroup.h" +#include "cpumap.h" #include "debug.h" #include "evlist.h" #include "evsel.h" @@ -615,10 +616,31 @@ static int metricgroup__print_sys_event_iter(struct pmu_event *pe, void *data) d->details, d->groups, d->metriclist); } +static struct pmu_events_map *find_cpumap(void) +{ + struct perf_pmu *pmu = NULL; + + while ((pmu = perf_pmu__scan(pmu))) { + if (!is_pmu_core(pmu->name)) + continue; + + /* + * The cpumap should cover all CPUs. Otherwise, some CPUs may + * not support some events or have different event IDs. + */ + if (pmu->cpus && pmu->cpus->nr != cpu__max_cpu()) + return NULL; + + return perf_pmu__find_map(pmu); + } + + return NULL; +} + void metricgroup__print(bool metrics, bool metricgroups, char *filter, bool raw, bool details) { - struct pmu_events_map *map = perf_pmu__find_map(NULL); + struct pmu_events_map *map = find_cpumap(); struct pmu_event *pe; int i; struct rblist groups;