From patchwork Wed Jun 28 10:29:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13295536 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 593A2EB64D7 for ; Wed, 28 Jun 2023 10:31: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: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=sBlzffcAouJnJeBgEP24KomGGjXuPj3bmvc2iVB0ZFQ=; b=XvnDxzglNg8Q/4 yOFXkA8kJ3posdegTt7uNH2gdexcb8Ym4uZXBGL2/YE0rEA7KPaanCHHwXDOhgGpSwemNNppLFyyh NrjVwZLTLMPsxNGF/CNH2/gUqHoRY+GYFtJyQ+/moFxXNzQAquWMmJwPsjnWvAMboJTgS7BtMKFY7 HcUdtnOS/JVAQgSQm5dOm7DcsvKoJNL5wICYi6dcOhPJ2G0t3k2G4/qmij+MTBjBLJ9SSzzhiKffd v8GlOJuLKK6aZtV/CFuvDgWosUUeF8BuMPXTjxtMVtXRJA3PkybwRj0DEyF68iHC8VVPf9jyeABeW w86N6tMJCJSmHCdCg1TQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qESSA-00FMOR-1s; Wed, 28 Jun 2023 10:31:14 +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-00FMJb-22 for linux-arm-kernel@lists.infradead.org; Wed, 28 Jun 2023 10:31:11 +0000 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35S8xh4R015057; Wed, 28 Jun 2023 10:30:28 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=PEVT2ccVAFCMYWm0TDtQk9WFjV/CqEY2pr7Ru3lw+PQ=; b=35GP3eVVztIBnkSU63DGnSSjC2TWZ+B+67L/VzpGjbCLnt5v9ADWvyAJ2obU2C7dcK5u tswvF+kQ3MdOGrhH97RyclIHheFH/IUtUw7xTY6sVp/02UVyj9Euek8rrvpkkRBiKfQM FTIJssE806itUtZgZMNCPrZl7ORtPtpHB7rW0dWsPJjIvicBDzD9XG3Omfc6qr8hMW+/ hfu9Fx8/Y5I5YEuOO1ESN+oT13bZldYgMiKjSi0c5a8jUnR6y1KPqt20oUsCq7N5P3tw IQGCGMe9q/kORHFBfLCskdtC1tk5gVWUKPtghoQYFNIzSJBeaO95otCgw3/OuXVswfwc 9g== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rds1u73hq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Jun 2023 10:30:28 +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 35S99Hlm008566; Wed, 28 Jun 2023 10:30:27 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-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Jun 2023 10:30:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i/xvAVuXu+V53JcZOmNln42gyKBziev+KikGaFRthd/owqArn2smcfYeVNMolazBB42wEFSDDhsRsf9ONWpjm2/lgVbOhYx5CyfpE4ruMh1aQAWwiZtU48n2KVQO3ONkNtxK98HpcWvF5AZLBcJMp2NScXevXe9vplUVIbKimrda1Sxk1AOQ1zPCok3dAo8pg0XU7Oym+JZVO4e6Qewa12N2nT2uE6AK7eSYQi1nh5uMsj6wnxO0l9/YAN4uE81iJdfYgYhyHCc9iASwHHUjKOf1NPkYCZvcy6Eo+AooMG4vGAzgn+d6iGlpw4U72IyUaj9GNGqaYhSLuyHvTGW+oQ== 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=PEVT2ccVAFCMYWm0TDtQk9WFjV/CqEY2pr7Ru3lw+PQ=; b=PHUQIWJO6IrCNQt4/1dh0PacPVb9Hb1kZdI9jcMBzU+UrvmQYoCkKj4vR69Wqu6bJVftYan/wGfJWFMsTxIB01ru+PtkqNtA+Ywy8zk1WzQVHjYb2hwlrSJh+CMcrhJFbc+ocz3qK3hx05DNyj2s69e2mI7+KnX1ty7jY4UCS3mHTc0qOq3lUp0y7NBpaJlInVaPk82dgEukrmtcNDI6m7Q6vhLx9s1o5M9/c3tZq1SCZI/710JPCcpzU+3yqOKieSomAcP2LQ/v6zlNjt+5CwZeUe8sgvnuDwakoqn5+ilEXbOb2OxmBEzSfAXsqwTxSNQtTqhmx5M9/wDxWiqhkQ== 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=PEVT2ccVAFCMYWm0TDtQk9WFjV/CqEY2pr7Ru3lw+PQ=; b=OGajmE5oE0CtfKOxdlcH3KTd3mQxOGStLDn3eEBqx3qCJssOM0PrZRLHIG5aK9MyXODeL1B+yyB/ehV4hNfZ2R71iYCZLbwXKyZYIouWrqDxxePz+f96HrgPpej153fG32nwZfBlHaJIRFGvDG6BYTHtDiDpnmyJ1gV+N9unXA4= 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:25 +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:25 +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 8/9] perf metrics: Stop metricgroup__add_metric_sys_event_iter if already matched Date: Wed, 28 Jun 2023 10:29:48 +0000 Message-Id: <20230628102949.2598096-9-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: SN7PR04CA0014.namprd04.prod.outlook.com (2603:10b6:806:f2::19) 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: 7c5bf042-b36b-4087-71e8-08db77c2af98 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fsOgcAAZZ5EiAc+AuA5IDCO2GGx4UTWs455sQqFgAVh4ojBfHdA3qYIkO+4p8Git05Z8a9Ldcw5qoWRG7FZ+eQ/YfCcUfK6bj1wK4BjaJ1jsKTLoj89Do+Ix1AORGMzOA+Eut1m5U/H4R7I2laZP4coIg4NLYiZa3IdpBhBVbPGje+1P8v6MxW9JhfTZbSi7oRCSXiiAGI4QHXnzECtfe7PB45fr8ITGoXXOClBqsOR0JtXV0UWxYhqqD0hUAtyuxWzyeUvsyLguDGeSSSMp6v/uoqHZgoSCiYxEbPQkG8RDVZiMQBE2FNyH+tjoKhqjKyTTPGKLwT4I5hUf24B/TQ1hf2pLST0AEJ1uDDqDV3bFNGe49A5Ajt72h3ir7uqrex7wAql8EL9vUsVcaUGm5D9UDKI7AQqs/6j7xp4SkMp4CO3Jk5dGtu0upiZPe5F36bZrniYRoO2303jroHZ9qQRr7/qkZFh0vAPmtEogHi0g8LT0OJNdcbiU5H/j4qbHPCzswLE2yOpdei379fU+B0e0LzEMt8AMXXbVyJE0zRBz1vKI3QWurWXo7yLfv1lXGCOOnO7vn7Sm43zmd9p3XfO9cRjpYkhuPsH8binnfHgygQfv1Uhe6OaoAp1N2IFe 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: KDjkATjDLnngiCZNhsunJJKxDzkcA2zdtEf3aCaQs0k/yN4Z+V0xoY/eac8t2848kg32UCvLscteazkJrkH2o7NUztKFP1C1Av/cN+UiiFlE8GgBBLh77ydh60UlTf2PoGB9Lp+lrZTr8OSEsboZx6S/1CpZi+5PYyio5jrP4RUlnWHUGeEogkzbG1nYkmQSc4zUZ2NSfocn22+1qXzw9mFA34yH15BiYi7uzZojhHeaO5damKQ15mpUgL9+ksQIsyWlDdtrXUdYQPxPdnX74+6miS6go3S3y7m+6nL8DvyARo6ChZJn43BE6llB9rO4tQGVTF2/BkUWvLSfmDq9Y7DhwefddsYgNx9tyI9cU/6TdNfRh2G1fe/xAh+g9G/2wz8hV5Vp40jC1NWov919ybgw+FuDXL75+AUjLdLarI5MysADjP8Jn/l3B2dw6X5ZMmYaaCxEm/6pfDW+LGbgOnlEtg1ZXtgbGRwvRablWfQkYjVCflRqek66UzPhAHdW0xVH4cEIo5WnCglePgxEVtTraDj846/0vRyJXx9eKprI8mj1Yn6OfKRnvXiBn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w06S9D/bwcZcdsyrEy/6q+b+Z0k/FhCgzadubPw6zXgsHDcCtInC5Qep/S5jf4Fp1lwkqQlwuDLTVr1ZP59Zw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7c5bf042-b36b-4087-71e8-08db77c2af98 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:25.7416 (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: KF94Hx0OlX+V8qkGSqnZXoxh0kt/zHusGTnSCWtsiy5MYa3sutFvtp4Xf3YoG9d+aGW2nZevc6LxbYZ0jbsADw== 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-GUID: sV_MZ5DQjufshANt_ayECoJEMxGxIdbL X-Proofpoint-ORIG-GUID: sV_MZ5DQjufshANt_ayECoJEMxGxIdbL X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230628_033107_839080_ED03FD54 X-CRM114-Status: GOOD ( 17.79 ) 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 Functions like pmu_for_each_sys_event() may be inefficient, as we only stop itering for an error. Often when itering, we may want to stop early as we already found what we're looking for. Return 1 in metricgroup__add_metric_sys_event_iter() when we want to stop. Nobody checks the error code from callers anyway - those are pmu_metrics_table_for_each_metric() -> metricgroup__add_metric_sys_event_iter() and pmu_for_each_sys_metric() -> metricgroup__sys_event_iter() -> metricgroup__add_metric_sys_event_iter(). Signed-off-by: John Garry --- tools/perf/util/metricgroup.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c index 111ad4e3eb6b..c045b111db84 100644 --- a/tools/perf/util/metricgroup.c +++ b/tools/perf/util/metricgroup.c @@ -1130,7 +1130,12 @@ static int metricgroup__add_metric_sys_event_iter(const struct pmu_metric *pm, out: *(d->ret) = ret; - return ret; + /* + * Return 1 as we don't want to iter any more, as either: + * a. We found a match + * b. We tried to add a metric, which errored + */ + return 1; } /**