Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp22674395rwd; Fri, 30 Jun 2023 11:00:18 -0700 (PDT) X-Google-Smtp-Source: APBJJlHZvKWtPKWoz93iOgPFjWz4aEmoIu5p3IHczPTLOi0VRmmdc7cYbJSoLTs/IKtEz4bYE7Au X-Received: by 2002:a17:90a:5410:b0:263:41ae:8163 with SMTP id z16-20020a17090a541000b0026341ae8163mr2415811pjh.12.1688148017853; Fri, 30 Jun 2023 11:00:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688148017; cv=none; d=google.com; s=arc-20160816; b=XXrWzZIGEEB98bOI+1bRkaxiVQsJPfvHId46Xoy2Rl7S0T0gZWlyuNe/69WPknEMig EEKWsW/c2VPfNVwefSkQjWlreSJOZj1Zjc5IAXvBx1Bdu4RnZkfgw0uJTSoq7UJx8eag FfKlN+v3dO04ufUHB2zlhdnPct+Yd5etiQvD/8w6Bws/nVzu76hXDU5JIymKiElas6BZ PUqNWnzaOYOE7YCrjQmqPS8XLVAYC6tIzvO0NYIdzA4Z2saiqhyjegVix0xmkcjDtKnU ni2wOdGMMKGY5K6Uex+F/kj40dTO9oJJAMGxcUcDP2axxcTBuRJqDl28V6dx1Kg0SlZ3 h4/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=XkFhDjCMVwNhOcO2v4G0EUDJBSzG4xJjBNq5yTT5bH8=; fh=zsO2SHAODKr++euHxjqQGy3RKdaJevamZLDg/d7t6ec=; b=0gZojnys96ieakex+dLJEgZje3YcxpRr2i51VMgreK0yRDLax2KR66Xv4bkF1M0bCx wthRw7jxvQFZCVauqPOzLKvt2/gMsV8s7MEUpPNz161HS1O7R7JtfMHXtDZWDNRiPu0M SRojTjyIcfJlkc4sn5wl2Y/0tWwEE/3AbkqE1STJHQLcF9SwYxwB4Qrx0rayTxPVQ4Fq Bx68cLNUIb0M5L01J7GzvriejgPpwXyRwFb/y2vQXyR4xiAkoLsSj9d4WELbqn4zlneU Jd5nPfGyUjhmEfF9EgYrd5zzohLWo6E2sx43WBI6WArc2OA72JiNQ6URgnUCg1WKlpBs lFlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=R9kyVWaP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a18-20020a17090ad81200b00262cc4177ebsi12540384pjv.160.2023.06.30.11.00.01; Fri, 30 Jun 2023 11:00:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=R9kyVWaP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232730AbjF3RlR (ORCPT + 99 others); Fri, 30 Jun 2023 13:41:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232656AbjF3RlP (ORCPT ); Fri, 30 Jun 2023 13:41:15 -0400 Received: from mail-qt1-x82e.google.com (mail-qt1-x82e.google.com [IPv6:2607:f8b0:4864:20::82e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03C941FE4 for ; Fri, 30 Jun 2023 10:41:15 -0700 (PDT) Received: by mail-qt1-x82e.google.com with SMTP id d75a77b69052e-401d1d967beso25071cf.0 for ; Fri, 30 Jun 2023 10:41:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1688146874; x=1690738874; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=XkFhDjCMVwNhOcO2v4G0EUDJBSzG4xJjBNq5yTT5bH8=; b=R9kyVWaPQlz3WF2q9F+9D2hpAYfGj0DR3fds0AKbRKLxLMUXciVT8FvIpD5ICzbCrS SOUB49q5QDV//Maefm+vq9UcMJmNvxwfwcP/32xR01Uo+1aip1j4ppkQfMLuQM2tAB/B cXczeJaoOjeI13w6N6f49fEHj+4dfObrOhYxEAmwlUlqJFhOzi9DR5p1zIN/rGKHT0zM Zhac8jxSF51wjSxoQGQ+l5HtL26RklLY9AWWKJlx/m6CxIoubQlooJdajCv0aBaGsKPn b+fyTHedj7MnydhPlokC8PZZxK9n7y9bvWCuCTIQm54KAcZRCP3SQJc6P/bHHljHVr4E Yvcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688146874; x=1690738874; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XkFhDjCMVwNhOcO2v4G0EUDJBSzG4xJjBNq5yTT5bH8=; b=Uk/ymtVsFB2CrK/17H0Gnm5jlocZwS1GRsX8FlYxw6y3LTXrNVmxIcx1lT9RRlj0UF +QULgf7VJYmuWLyS7SCrZ8Fx+tZcpJ7wIz7MrJTBM6HJnJvXbsSqPgAmfZWziq2U5EXg RL45/gyBqYswaE/51CsWsveD0hKxgSOrJz5arJAUYLwjiSb4IcGLu93NC56e9DJu3Zca zAcdG9AI7iRMqJSt9JzIxG1bQFW2ik+Qctt3/bbtxnYJjxd2BtRmrWyUHBSy6psyQ34m LMbde3jnQsPKDSbjsjhz03yPv9SYEWDec+BYJ3JecGKFvhWkFMvRDaneDdrSZ/574LC6 4yDw== X-Gm-Message-State: ABy/qLaSTNIR+4uoyXcw80wmRahYqeV4UePwy+zOhoS8QvEglZq4ZZtF gPyTR6eQhXNN4oZw9ScfCMv9GChFE1kxFVAZeh1AVg== X-Received: by 2002:a05:622a:5d4:b0:3e3:8c75:461 with SMTP id d20-20020a05622a05d400b003e38c750461mr7411qtb.6.1688146874051; Fri, 30 Jun 2023 10:41:14 -0700 (PDT) MIME-Version: 1.0 References: <20230628102949.2598096-1-john.g.garry@oracle.com> <20230628102949.2598096-3-john.g.garry@oracle.com> In-Reply-To: <20230628102949.2598096-3-john.g.garry@oracle.com> From: Ian Rogers Date: Fri, 30 Jun 2023 10:41:02 -0700 Message-ID: Subject: Re: [PATCH RFC 2/9] perf metrics: Don't iter sys metrics if we already found a CPU match To: John Garry Cc: acme@kernel.org, namhyung@kernel.org, jolsa@kernel.org, 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 28, 2023 at 3:30=E2=80=AFAM John Garry wrote: > > In metricgroup__add_metric() we still iter the sys metrics if we already > found a match from the CPU table, which is pretty pointless, so don't > bother. > > Signed-off-by: John Garry > --- > tools/perf/util/metricgroup.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.= c > index 4389ccd29fe7..8d2ac2513530 100644 > --- a/tools/perf/util/metricgroup.c > +++ b/tools/perf/util/metricgroup.c > @@ -1261,6 +1261,12 @@ static int metricgroup__add_metric(const char *pmu= , const char *metric_name, con > > has_match =3D data.has_match; > } > + > + if (has_match) { > + ret =3D 0; > + goto out; > + } > + I think this can just be: if (!has_match) However, I'm not sure I agree with the intent of the change. We may have a metric like IPC and want it to apply to all types of CPU, GPU, etc. If we short-cut here then that won't be possible. Thanks, Ian > { > struct metricgroup_iter_data data =3D { > .fn =3D metricgroup__add_metric_sys_event_iter, > @@ -1279,6 +1285,7 @@ static int metricgroup__add_metric(const char *pmu,= const char *metric_name, con > > pmu_for_each_sys_metric(metricgroup__sys_event_iter, &dat= a); > } > + > /* End of pmu events. */ > if (!has_match) > ret =3D -EINVAL; > -- > 2.35.3 >