From patchwork Wed Jun 28 10:29:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13295534 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 DAF6AEB64D7 for ; Wed, 28 Jun 2023 10:31:41 +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: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=+T59BB54FiFNPPmEbmEe+9fLt69QfxDDq8JY4WqIvmA=; b=BBLZxOOF+AsnmX HuJlvZnvCqSGCKAfDQZ78QBKkqwwBxUcpli2MqXC9i5iJ7Wd0+QwM2qFLdmUeoiTguXhtxD0QWnQQ 5Grz0duA13sep0bZgdy2nOdNYDK+ZsPZP5tACVq2bHhS2GKMinZperua25cavUILlM2njSvB8sL+u +pOoSVrH6Iq6S/rmEW6tvsDdvVTqIEglEU/mZMHMY8unNmlAqiuyREVEok0WMVavoWIsbv5i1Mtgt i0K5P3D9M1KbYomgWNwXDhqptWUvAPoL5G1L1XeCLS4igFLYT2u/a8hFartMLCZ7wmyJzSkhc4Bod SnFVw2oznTnYfYHz6cQg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qESSB-00FMOm-0M; Wed, 28 Jun 2023 10:31:15 +0000 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qESS3-00FMJX-1D for linux-arm-kernel@lists.infradead.org; Wed, 28 Jun 2023 10:31:11 +0000 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35S8xqMM006641; Wed, 28 Jun 2023 10:30:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=r4qM/ngLrfPnqWi0Fb1fg1fq9WWVMk1a99HUIWr0bPA=; b=efZYaYsPICHwJk8oq0Fvu+EWh82/OPUo4CsIAx0A+WvgZUojtWOWCBv7szHcDUDP/uJt Db0kai/z2HnoaZdTTuRcy5bwpadVJFfnc1cojXnaeN6wLTJ/NTv+z1d0LovWBGQ2ldUU sIMwjOWFmZDSjtPBW3J8gJGneBFiTiMFGWDbOIEj/bRrm8RewSQNv3G0262oimfyMi2V iyqK/ZzAgrdKTn8vRl5vMXE9a/rUY0ff4Iqt1cDqX7fMABPDIaSPorMEdW7coBmbHQ7D C6gg/0GnJbKvR8suQEFODJsy19NFLwRd3xL0IjC3dBF+o5AAxaOTA44GWLO6k7No8DBL 4g== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rdq30y9nn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Jun 2023 10:30:19 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 35S9EXdP008565; Wed, 28 Jun 2023 10:30:19 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2173.outbound.protection.outlook.com [104.47.55.173]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3rdpx5tra2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Jun 2023 10:30:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nCHSCU0yMl4HeUK8boLvqCVa5PVV22fXcj0GmYAew4W7OsP96/e1ayM0o7RgqgnqVWvQU17EpwYVQ8wgf587dTBULfZFtFPUiwyDI26zUFTzJtvY4J2VQHwRTY7mEt5qOb0bgy2IYsCnPJiNhUdVffrJCbJUwSw3n/7lJJIzDX78HO9iwU3h/e0wcmaQznar8dl+t9im7JG65NLXgaz0UhJ01KiiRE/2HraBvm8uX4AAHeTeXp4SKWUjA+ZgpcU3TDzWajZO6M3PIuxgQF/dyGwVKWLXyaRfRfmFkquMa+ZVfyXVlXya/fCdA++OTivqRjggjw8+34Io0DjcChkuMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=r4qM/ngLrfPnqWi0Fb1fg1fq9WWVMk1a99HUIWr0bPA=; b=aQVdUcNtL+gzozKzoIGsf6QG7aeKWenLUNuNIxzsq/oT1wm4+37+f2JOa10/4GTvd4jst5p26e86yn2rlJcZgp9alQ6kxFsfCg9NYNL8NieIY3NPHAO4pFWg9FCcx7Gi+PhitdhBndp35/Eywev5kI1ph5LN48vca260ZVZTIRlfziM33rx/VU41OlkSu68ZkUDtiq+gCN4KqojVM/DUt5TNfAyZebssnPy2eREEByjzDdp+nK8xtWkybxCJPX4gyMu6h0eYu7QkFLNcF564cVHViL6RQcc54Zeoz2QsT8oe0DxgBZ+QMHFpcl9pcFbL/y+XjsjcXZuvMRGRrhbApA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=r4qM/ngLrfPnqWi0Fb1fg1fq9WWVMk1a99HUIWr0bPA=; b=EHFh6jKluoG0b5qu0usDHKtSbLJXfS3LDfM+d+qDZdtCCAPrL6NfNKxU5ykEwshgsPEgQlYrDKu77qNLUzVzEDVjS3GXdbZd1OEb65+5Rga34PmoV0j0brRiD5Ej7Oe9EdWLQvlcsxGyGi/2rmwnCjM/j3zK1qcx2QXLQz2AMW4= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by SA2PR10MB4715.namprd10.prod.outlook.com (2603:10b6:806:fb::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.24; Wed, 28 Jun 2023 10:30:16 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::e38:5b81:b87f:c1eb]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::e38:5b81:b87f:c1eb%7]) with mapi id 15.20.6521.023; Wed, 28 Jun 2023 10:30:16 +0000 From: John Garry To: acme@kernel.org, irogers@google.com, namhyung@kernel.org, jolsa@kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, renyu.zj@linux.alibaba.com, shangxiaojing@huawei.com, zhangshaokun@hisilicon.com, qiangqing.zhang@nxp.com, kjain@linux.ibm.com, kan.liang@linux.intel.com, John Garry Subject: [PATCH RFC 3/9] perf metrics: Pass cpu and sys tables to metricgroup__add_metric() Date: Wed, 28 Jun 2023 10:29:43 +0000 Message-Id: <20230628102949.2598096-4-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230628102949.2598096-1-john.g.garry@oracle.com> References: <20230628102949.2598096-1-john.g.garry@oracle.com> X-ClientProxiedBy: SJ0P220CA0009.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:41b::25) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|SA2PR10MB4715:EE_ X-MS-Office365-Filtering-Correlation-Id: 4dd79a60-3229-4fe6-0601-08db77c2aa1a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 80lcX4R12gaweELdcsNAFJ0V2BwUqPBm57HZ2AHY2lAabgxmFx0znFPdyGE00RpS986TvjiThU6rs7ShUo+uSXecxnyE5R+GuDzcom2Uj3VF83PThBy9lxuK5P86UFJjaig/KiGBhi9jMDAyOKx8RriV/XLIA8EMugkN/v5/LE0/vEnhUDQigdVB3bi+OnLQisDNnkphAxYFlqRqrXk01QTznJC96uxSoT+/6USJGu7Ad40g31tuKKmpN3bDFnp/M29eMej6JgRUFKf9M+GV9E1PjANFoco0OeyPmrDiS63VQ+eTjzBoad56K9IQlZCZ4brNu7l4XXO7zRh7ZomCOwluhKaOYG+1i5A9zjjYvNZoLqbG8nvZSdbMr80pwpwQSkOHQGfIicgNcfAU3tHcWxAhugXWZzUv4BR8sPD9MkE0/4pGr5+KyzgKGb5+Sg7Qu9xUuXXvTmYA2YceDJyeRJV00S7DF8KouThcUCHv/0vkpGEEFKqcOXlt7/N+D+gQ/xDJ8yCz1T2Cwt1x7E2YuocPeFVNwb75+pX7H/95fwUi/8k4rDUBZKQMGQe1Lov48EkiDiiquguU6eHYNp89iibFplB+5kVIxB5iFVenjBBxT6B0uDlnU+riYwukzUdv X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(366004)(39860400002)(396003)(346002)(376002)(136003)(451199021)(38100700002)(83380400001)(103116003)(36756003)(86362001)(478600001)(6666004)(6486002)(2616005)(8936002)(316002)(66946007)(8676002)(41300700001)(66556008)(4326008)(66476007)(107886003)(1076003)(6512007)(6506007)(26005)(186003)(7416002)(5660300002)(2906002)(101420200003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: MZUFrd359r1ckDq76oy+/DuK+rnV+UVDEnxFbpRBaPjwLT47Fn7ZDSfGRc8x2q4XeJF3HHxSKWOHVxWrcTi3xXTdTsqQU26aC3Y+ltySnQX/DqWdcplq1XN/ydhXJJUlJYloRoPpzTtlRCBDLifpuAUAILakvvpEsXje9LV7X96+GOr0Jpy8cgr4KvgqwHytc0xLY2tLS3mz9RDwKIjW1uwclvvRA4XBRW4oM36ppAtltrsBMDtQ7Oe4pel7wT0WLFT3e6/6gnHegFvEI7YCuWxjpe590a0ZGyHsFm6Dv+Sl47A7A8D9zslI0Z4oJoccjdxv3lgngBTFjuRESj8aKkbxAOS6bYn5PdTgy7fBvKZ13fhWUY5E7CUe+eqUuRN+kTww/YbvZZGSgEEH0aXiZe9kI6oPCL4jytUcdZ/jeHRxmMX5Mn7Wh3sM1i+2kWM//VWRcQqY0E+1+JrdEqKZcWK7wj/NorWJfDdrFNxXZoYgaN/Rp7y69O8XnfLv7AaC4hxwYnpe+sr4ezqUIUUYL3r0qKnDkHb7LR+xe6aX5NDMGjP49HExZzs3wqEcRp9Eq8qkfZ3s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tn9YmZmwaONRxZjtUGEr08FntRC23lxD5gCNPnHZ7z++lZqro4bwo5vflaHnmf+Bayk+Xz+Qu9wQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4dd79a60-3229-4fe6-0601-08db77c2aa1a X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jun 2023 10:30:16.6011 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: PZ5qs0KYNVmPWWsBomVW5MGgZTFGDaV/Fx2fjg6JZZBp7VjfEv7aAOQEt5EzDDGVN0uf3bjvK2tFq4rbgLVcwA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR10MB4715 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-28_06,2023-06-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 malwarescore=0 suspectscore=0 spamscore=0 bulkscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306280092 X-Proofpoint-ORIG-GUID: Zh1faJHjqPMjsUabR94QPohG6tcK1dPI X-Proofpoint-GUID: Zh1faJHjqPMjsUabR94QPohG6tcK1dPI X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230628_033107_824364_219EE234 X-CRM114-Status: GOOD ( 21.36 ) 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 The current @table arg may be a CPU metric table or a sys metric table. There is no point in searching the CPU metric table for a sys metric, and vice versa, so pass separate pointers When sys metric table is passed, this would mean that we are in self-test mode. In this mode, the host system cannot match events in the metric expression as the associated PMUs may not be present. As such, just try add the metric, see metricgroup__add_metric_sys_event_iter(). Signed-off-by: John Garry --- tools/perf/tests/expand-cgroup.c | 2 +- tools/perf/tests/parse-metric.c | 2 +- tools/perf/tests/pmu-events.c | 29 +++++++++++++++----- tools/perf/util/metricgroup.c | 45 +++++++++++++++++++++++--------- tools/perf/util/metricgroup.h | 3 ++- 5 files changed, 59 insertions(+), 22 deletions(-) diff --git a/tools/perf/tests/expand-cgroup.c b/tools/perf/tests/expand-cgroup.c index 9c1a1f18db75..50e128ddb474 100644 --- a/tools/perf/tests/expand-cgroup.c +++ b/tools/perf/tests/expand-cgroup.c @@ -187,7 +187,7 @@ static int expand_metric_events(void) rblist__init(&metric_events); pme_test = find_core_metrics_table("testarch", "testcpu"); - ret = metricgroup__parse_groups_test(evlist, pme_test, metric_str, &metric_events); + ret = metricgroup__parse_groups_test(evlist, pme_test, NULL, metric_str, &metric_events); if (ret < 0) { pr_debug("failed to parse '%s' metric\n", metric_str); goto out; diff --git a/tools/perf/tests/parse-metric.c b/tools/perf/tests/parse-metric.c index 2c28fb50dc24..e146f1193294 100644 --- a/tools/perf/tests/parse-metric.c +++ b/tools/perf/tests/parse-metric.c @@ -95,7 +95,7 @@ static int __compute_metric(const char *name, struct value *vals, /* Parse the metric into metric_events list. */ pme_test = find_core_metrics_table("testarch", "testcpu"); - err = metricgroup__parse_groups_test(evlist, pme_test, name, + err = metricgroup__parse_groups_test(evlist, pme_test, NULL, name, &metric_events); if (err) goto out; diff --git a/tools/perf/tests/pmu-events.c b/tools/perf/tests/pmu-events.c index 64383fc34ef1..de571fd11cd7 100644 --- a/tools/perf/tests/pmu-events.c +++ b/tools/perf/tests/pmu-events.c @@ -798,9 +798,9 @@ struct metric { struct metric_ref metric_ref; }; -static int test__parsing_callback(const struct pmu_metric *pm, +static int _test__parsing_callback(const struct pmu_metric *pm, const struct pmu_metrics_table *table, - void *data) + void *data, bool is_cpu_table) { int *failures = data; int k; @@ -811,6 +811,8 @@ static int test__parsing_callback(const struct pmu_metric *pm, .nr_entries = 0, }; int err = 0; + const struct pmu_metrics_table *cpu_table = is_cpu_table ? table : NULL; + const struct pmu_metrics_table *sys_table = is_cpu_table ? NULL : table; if (!pm->metric_expr) return 0; @@ -834,7 +836,8 @@ static int test__parsing_callback(const struct pmu_metric *pm, perf_evlist__set_maps(&evlist->core, cpus, NULL); - err = metricgroup__parse_groups_test(evlist, table, pm->metric_name, &metric_events); + err = metricgroup__parse_groups_test(evlist, cpu_table, sys_table, + pm->metric_name, &metric_events); if (err) { if (!strcmp(pm->metric_name, "M1") || !strcmp(pm->metric_name, "M2") || !strcmp(pm->metric_name, "M3")) { @@ -890,13 +893,27 @@ static int test__parsing_callback(const struct pmu_metric *pm, return err; } -static int test__parsing(struct test_suite *test __maybe_unused, +static int test__parsing_callback_cpu(const struct pmu_metric *pm, + const struct pmu_metrics_table *table, + void *data) +{ + return _test__parsing_callback(pm, table, data, true); +} + +static int test__parsing_callback_sys(const struct pmu_metric *pm, + const struct pmu_metrics_table *table, + void *data) +{ + return _test__parsing_callback(pm, table, data, false); +} + +static __maybe_unused int test__parsing(struct test_suite *test __maybe_unused, int subtest __maybe_unused) { int failures = 0; - pmu_for_each_core_metric(test__parsing_callback, &failures); - pmu_for_each_sys_metric(test__parsing_callback, &failures); + pmu_for_each_core_metric(test__parsing_callback_cpu, &failures); + pmu_for_each_sys_metric(test__parsing_callback_sys, &failures); return failures == 0 ? TEST_OK : TEST_FAIL; } diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c index 8d2ac2513530..520436fbe99d 100644 --- a/tools/perf/util/metricgroup.c +++ b/tools/perf/util/metricgroup.c @@ -1232,13 +1232,14 @@ static int metricgroup__add_metric(const char *pmu, const char *metric_name, con const char *user_requested_cpu_list, bool system_wide, struct list_head *metric_list, - const struct pmu_metrics_table *table) + const struct pmu_metrics_table *cpu_table, + const struct pmu_metrics_table *sys_table) { LIST_HEAD(list); int ret; bool has_match = false; - { + if (cpu_table) { struct metricgroup__add_metric_data data = { .list = &list, .pmu = pmu, @@ -1254,7 +1255,7 @@ static int metricgroup__add_metric(const char *pmu, const char *metric_name, con * Iterate over all metrics seeing if metric matches either the * name or group. When it does add the metric to the list. */ - ret = pmu_metrics_table_for_each_metric(table, metricgroup__add_metric_callback, + ret = pmu_metrics_table_for_each_metric(cpu_table, metricgroup__add_metric_callback, &data); if (ret) goto out; @@ -1267,7 +1268,21 @@ static int metricgroup__add_metric(const char *pmu, const char *metric_name, con goto out; } - { + if (sys_table) { + struct metricgroup_add_iter_data data = { + .metric_list = &list, + .pmu = pmu, + .metric_name = metric_name, + .modifier = modifier, + .metric_no_group = metric_no_group, + .user_requested_cpu_list = user_requested_cpu_list, + .system_wide = system_wide, + .has_match = &has_match, + .ret = &ret, + }; + pmu_metrics_table_for_each_metric(sys_table, + metricgroup__add_metric_sys_event_iter, &data); + } else { struct metricgroup_iter_data data = { .fn = metricgroup__add_metric_sys_event_iter, .data = (void *) &(struct metricgroup_add_iter_data) { @@ -1320,7 +1335,8 @@ static int metricgroup__add_metric_list(const char *pmu, const char *list, bool metric_no_threshold, const char *user_requested_cpu_list, bool system_wide, struct list_head *metric_list, - const struct pmu_metrics_table *table) + const struct pmu_metrics_table *cpu_table, + const struct pmu_metrics_table *sys_table) { char *list_itr, *list_copy, *metric_name, *modifier; int ret, count = 0; @@ -1338,7 +1354,8 @@ static int metricgroup__add_metric_list(const char *pmu, const char *list, ret = metricgroup__add_metric(pmu, metric_name, modifier, metric_no_group, metric_no_threshold, user_requested_cpu_list, - system_wide, metric_list, table); + system_wide, metric_list, cpu_table, + sys_table); if (ret == -EINVAL) pr_err("Cannot find metric or group `%s'\n", metric_name); @@ -1534,7 +1551,8 @@ static int parse_groups(struct evlist *perf_evlist, bool system_wide, struct perf_pmu *fake_pmu, struct rblist *metric_events_list, - const struct pmu_metrics_table *table) + const struct pmu_metrics_table *cpu_table, + const struct pmu_metrics_table *sys_table) { struct evlist *combined_evlist = NULL; LIST_HEAD(metric_list); @@ -1547,7 +1565,7 @@ static int parse_groups(struct evlist *perf_evlist, metricgroup__rblist_init(metric_events_list); ret = metricgroup__add_metric_list(pmu, str, metric_no_group, metric_no_threshold, user_requested_cpu_list, - system_wide, &metric_list, table); + system_wide, &metric_list, cpu_table, sys_table); if (ret) goto out; @@ -1697,18 +1715,19 @@ int metricgroup__parse_groups(struct evlist *perf_evlist, bool system_wide, struct rblist *metric_events) { - const struct pmu_metrics_table *table = pmu_metrics_table__find(); + const struct pmu_metrics_table *cpu_table = pmu_metrics_table__find(); - if (!table) + if (!cpu_table) return -EINVAL; return parse_groups(perf_evlist, pmu, str, metric_no_group, metric_no_merge, metric_no_threshold, user_requested_cpu_list, system_wide, - /*fake_pmu=*/NULL, metric_events, table); + /*fake_pmu=*/NULL, metric_events, cpu_table, NULL); } int metricgroup__parse_groups_test(struct evlist *evlist, - const struct pmu_metrics_table *table, + const struct pmu_metrics_table *cpu_table, + const struct pmu_metrics_table *sys_table, const char *str, struct rblist *metric_events) { @@ -1718,7 +1737,7 @@ int metricgroup__parse_groups_test(struct evlist *evlist, /*metric_no_threshold=*/false, /*user_requested_cpu_list=*/NULL, /*system_wide=*/false, - &perf_pmu__fake, metric_events, table); + &perf_pmu__fake, metric_events, cpu_table, sys_table); } struct metricgroup__has_metric_data { diff --git a/tools/perf/util/metricgroup.h b/tools/perf/util/metricgroup.h index d5325c6ec8e1..b5f0d598eaec 100644 --- a/tools/perf/util/metricgroup.h +++ b/tools/perf/util/metricgroup.h @@ -79,7 +79,8 @@ int metricgroup__parse_groups(struct evlist *perf_evlist, bool system_wide, struct rblist *metric_events); int metricgroup__parse_groups_test(struct evlist *evlist, - const struct pmu_metrics_table *table, + const struct pmu_metrics_table *cpu_table, + const struct pmu_metrics_table *sys_table, const char *str, struct rblist *metric_events);