From patchwork Wed Jun 28 10:29:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13295542 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 1EB68EB64DA for ; Wed, 28 Jun 2023 10:32:26 +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=xi+f8N3BZMo9Nwswta71hITYvQmeGOo2zMXqrPXjK6M=; b=LoKjSYAgqEI4y+ avT/CXKobXHedI26BSx+Qg2qYn9td43COYdf5ViL+wUdh+8OksHGZRVp7B+ehta/TOdxJgwH8tftp rtHBWI0uSCegDJm8kYnecBGrMEV5j2Bi/wFJi3coJzLkbcXaKw37BOoUz4NX4I3bbg/gmnLT88/m8 xcBaWaCE00uQ8EKm+sIzKBE6srh1vabK0pGr2M1ukMjMueBRCpXqMhNet9pdXZiWhOb6sj3M6NZJT qKbSiRuVKKy6yoY9ZyZCmJavHAs3scfpeRW68wDG9j1KZWha6GoqiSgWDiWL22bErRpwjQ4OCDFJQ hnmtskg8DJ9sfri6Zd4A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qESSn-00FMbW-2Y; Wed, 28 Jun 2023 10:31:53 +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 1qESSO-00FMJo-0k for linux-arm-kernel@lists.infradead.org; Wed, 28 Jun 2023 10:31:29 +0000 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35S902kw031526; Wed, 28 Jun 2023 10:30:27 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=ebfd71yKQLFHnsDikp7a41Tk95DNc4aJaNTDvEr9Yc0=; b=WGoIUOjxKozvlf88OLtO1IjMTXfKs75Lt4x9akLdRzPm/SZIOhv5YTZuLy3HiegPH8vt EYoTQxLN7ZwLAMiJnS0csee0IJ8+23qAS9i1rfHvkcr6Ev5m9dpqQJ6LTnLwJq7s6ZSx O6DgH7xM+gjUGxq9krtKwG3ppKaAD0Ai9mebCLgR9l7M4jMQt21cQ4Z0iZtJdWm83zkc val1BbomKy3ur+024HgkWXSBT4HF6OFkbH8XC14POVKv5WZnPqXsuOORklp6tOyrs3LO LLBTwW1ewavqOjIuUT0l9D1tUTnOiXCwyAAqtnqxykarZoJbhtb6tyO1tfZQ9sl4q16t hg== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rdrca6xxg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Jun 2023 10:30:27 +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 35S99Hll008566; Wed, 28 Jun 2023 10:30:26 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2169.outbound.protection.outlook.com [104.47.55.169]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3rdpx5trjr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Jun 2023 10:30:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZWYuZKzZwtrFPzjfSddMy2iQW0ksM72z79euXeTy07H8vu/i/LaBpeNnk9RvaBlQsLXlnwp/gOHkcv9/PdF4lPyCjlX41v352CdG8o6e8POSSmwdq3rMA+mHLZ1E99bTeV1paaBPy9gG+fItdhN1BXbwri9HZ4nBkEUnHPZlTYVFFqOBBdVlZX7AaCTOuRovDdLQ3DR5sUxLlftmJLYpHJYP/+hNM07tVycssO0grgxDAu/AZlHcS63TiBAmqTANzhh6AruoARbYTMheTYAaq8UNOZwhiE7E0Zm4v3P1BtlIlSiU1AmdceFQhrccKSlF2VddSI8YjhfY5HSrDCm+sw== 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=ebfd71yKQLFHnsDikp7a41Tk95DNc4aJaNTDvEr9Yc0=; b=bbdCprA6DVzYo7BznKGZSdfra11VlpAThalf6zW9S7JZ+52ZYk4eRxlN5u18Ys+NCb7dGFUG6L5ciaqp7fTtUHhc60yHBssg83nMU6WXdiFvzm4yW8m7icsSRcg8Mz2oea8LL1FKBi+sWUxEoH3uPKv07ZSSpppzbpmsfC+WQROWc+lPMuKMOGf8EYpDJrWEGs+xerKtKeQ9+m8WspRtpEogQd35GH6Nldol9IHFwAAGDIjbDvq1mhbYc+cCmqrjgfKKxhy00wf/hHVnk7IiC5fDTw2loocID6GBbgbe3zJINtGL0igaEgeFLvAAx/M+QeMtbpdREOsqyY3PJALVOA== 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=ebfd71yKQLFHnsDikp7a41Tk95DNc4aJaNTDvEr9Yc0=; b=wpCoh+JrEiJ8yLdZ/+lnIa6OusXjlxMVdtvUqYiUpmlXKcmvSQC/pGoBqzeIv0e5GZ9UipWVn36okDASCGBI+kmAzp/1XFgvYbAtvkVZOMA3qOr6Il57oVnIVbatLXVWduQTAv7GX9DgW3hiC7MjMW7DNbI/np8BFJngMFwl+WU= 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:24 +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:24 +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 7/9] perf metrics: Test metric match in metricgroup__sys_event_iter() Date: Wed, 28 Jun 2023 10:29:47 +0000 Message-Id: <20230628102949.2598096-8-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: SN7PR04CA0001.namprd04.prod.outlook.com (2603:10b6:806:f2::6) 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: 615a051a-bfc7-4e2f-100d-08db77c2aeaa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gP+d1f3O/iCqeNl3tGnKD2FgBctinCcJjYmxC9Q1G3VZF8k31latnUUsFXjK1hdIbtOkjw2wr4YMJDQLKnYlQDC6Azra721xbSLfa9Nq1xJ4cvHmFPt57ytK50h+JGurOMa1kZKE43bUGk7G2a5CsDX2dlvBGMt0Y5O9s1vpVyr/7/+5MSmjNYBp3yI3DnJwnQni6+RLrMcx1znPjIKVkmVgehrPjuCURfN1ybHlUPbkCnIdW31aYngpWULLO108W5U0l5ESHeQ8Zdwa4N2LBfxNuD/uEYusHeXeOXRlsk7l1BsdAwLCjQYjo89FCFI/zpRXv6innXaPTonABO/h1/gxtkylU1XOJn0qK5RngPTg6CjTOuh9r5egb5eXf0QY72ttA5XJAF9CkxgRK/y+hisxc7X9n+jgNs/aijUV3YSsJ8zYqFAAJ4P1sBg+eJAqk0eCBVxLo1JOLjsReg2sk3AtjhUz9SbCCnlyHtHWkYBtx4+sRVZzPANT/DrvYJsS6T2Ks1mTbbtiHloK/d8QtVTbpWWlRpK9FB0Bh6FEVkXViPkdtBXqlvpu6VNABbaQAabMJHDLfwKXmeXCX7+QzvWXH3wugJ2YQ6QcxyCgMKX2swLUNIU3C9Sevktcra18 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)(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: wIkbc5TyMd3vbHVTJNH17gamLsFt6oR78jR9Mv28VVW7IPVMXQNDgM6S9/+xG/dES1yAND7Qz+BgGxxlFbpqO4+sD62aaS5PUZbTTxCDNIE2aF7+GF/r0NtjsxmVDzgCQ1GwVH7/lwo+1E3asoRFOZR50lrXoon6XcZTc1LkzKXyG/JMxzMX1jDHtlDjwRgC+kSZ9P8tJtyup1OB/nGDJ2S8KhFUBJnggv1/OXXJll8nLjWnCySiFpkxBL0A87LQGnO5AV7iDDp6q0u1B+FbTxi0DGabsD6BGZlcxEMn1Q8IXqMFaZ9jm8uuoYYrWjVkzJ8WESs/IJGJoASw+CTm8O8cY7Kb/oHOOjeNcNW730PkHRc6p0jYEa9QD94O9Vw7Q2/9FMWSpimk29ZuzlpBDthPlzB4bU9xR1h/iTfI3KUttJxQjx2jRB95GMJ/gDea2V1mY/sPf3GWHiLnICtmRLjrf6kIhINwBIqtmRTXVmWlzNi/jbdaoZizOyHA3CQI0FSf7Ri5TbcWMF0xpJkiXlFWwAycNa3jS3fnbpalSkRxtnGPoQsUTk3+WNQvNritzT/XTRxCWHmpi66IhY3FmmXGEt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rIXbaO24aFIk966VO/a6hLHqIInr76wFe4KFdq/w3G6H4gOI2bmZA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 615a051a-bfc7-4e2f-100d-08db77c2aeaa 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:24.1952 (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: e3RkOsZAMf6Qovo0PdOwahXVl4M/+lCRzknjaWF0fedEYAubV+5UVTwvRxx2rdpfPbH+eAzeZz2Tch7Ek3tjPQ== 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: YhVXq7N5nomKoj0gmvWcbcft69A6U4nM X-Proofpoint-GUID: YhVXq7N5nomKoj0gmvWcbcft69A6U4nM X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230628_033128_278317_BABBFD2F X-CRM114-Status: GOOD ( 21.67 ) 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 When we add a metric in metricgroup__add_metric(), we first iter through all metrics in each table from pmu_sys_event_tables tables and call metricgroup_sys_metric_supported() to test whether we support that metric. The second step is to call metricgroup__add_metric_sys_event_iter() -> match_pm_metric() to check if this is actually the metric we're looking for. It would be better before calling metricgroup_sys_metric_supported() at all to first test whether we're interested in that metric. Add metricgroup_iter_data.metric_name, which will be set when we're looking for a specific metric in the iter, and check for that in metricgroup__sys_event_iter(). In a way this duplicates the metricgroup__add_metric_sys_event_iter() -> match_pm_metric() check, but that is needed for other cases. Signed-off-by: John Garry --- tools/perf/util/metricgroup.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c index 6be410363099..111ad4e3eb6b 100644 --- a/tools/perf/util/metricgroup.c +++ b/tools/perf/util/metricgroup.c @@ -483,6 +483,7 @@ static int metricgroup__add_to_mep_groups(const struct pmu_metric *pm, struct metricgroup_iter_data { pmu_metric_iter_fn fn; + const char *metric_name; void *data; }; @@ -495,6 +496,10 @@ static int metricgroup__sys_event_iter(const struct pmu_metric *pm, { struct metricgroup_iter_data *d = data; + /* We may be only interested in a specific metric */ + if (d->metric_name && strcasecmp(d->metric_name, pm->metric_name)) + return 0; + if (metricgroup_sys_metric_supported(pm, table)) return d->fn(pm, table, d->data); @@ -1291,6 +1296,7 @@ static int metricgroup__add_metric(const char *pmu, const char *metric_name, con .has_match = &has_match, .ret = &ret, }, + .metric_name = metric_name, }; pmu_for_each_sys_metric(metricgroup__sys_event_iter, &data);