Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2496223rwb; Mon, 3 Oct 2022 01:19:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5kUmeC4NHhV41n5YEyq++3X26nZY6w1/E61NkW2kcLtuRM8GCnbGfHlIIySuHd0diyjZIt X-Received: by 2002:a17:902:7102:b0:17f:3da:f18c with SMTP id a2-20020a170902710200b0017f03daf18cmr5498058pll.24.1664785153753; Mon, 03 Oct 2022 01:19:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664785153; cv=none; d=google.com; s=arc-20160816; b=Po9dytGrd5KD4d0ZWFxLzu8hlUK5XLipv+82IZzG/tkCxjf8q5vaWUpqQOGAETsNXN jgfOKvsRgEZeXr1GaUXgCz5xd++KGt5+2uEwVKgRMTIJJtniuiCiiHnh3Hm4bzqH+KCK l7Ty8S+ga6nESKKcK8ID4AqJc+KshFwbvwrsjbT87/FPuwakG8MKtKQ5Ql27Idq5GziY 4OSTlXYgXr+3J+EqFThW9kgohvh3OYv6ropONtSMftuSH1bC407CvrCBvicMw5zTBDCp v7jAUxFj1RZX5/YUcbqZ5XAjK0YdilZG9/SJ+BU42CoXni4x9nBswWdBbtt1HgRpkAxv 0tnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qxRjAOH1hddaLHqFM0ekTycig071e8WkPsgT2jQzaXg=; b=wzB6TiHyj3P2+cM3Hs80DltsopYnNC4r4K972YwrOMGLA+UddTnQWppyv9m9abLKNr w0FjE/kP4DJ9VyRp9igGsJ9VfOoQjWwr8hFWI1oVPLU8JamjZo9guz+SSIi50fK7gQr0 cpZzio5sYlGbcRqipyK0DqeJPG9X2+9cClyj0MTpK4Qio95ddoj2o+sTfmeDLvbvDxVr BdtXCVuFfFFDN8aBTs9CoRkOGEOgH+S2OmBXd1xEVQFevOTFyhgYHNeEXr1pW3O0vQyV Zg+8IvIvGdpdpSC2eSYX6S49nLBiZd4z31Fru+zEXxeeuf0Han6T5DUuP7XOavdGDRld FERA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zi2ApA0R; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j10-20020a63e74a000000b0043aebb63fc7si10260918pgk.301.2022.10.03.01.19.02; Mon, 03 Oct 2022 01:19:13 -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=@linuxfoundation.org header.s=korg header.b=zi2ApA0R; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231518AbiJCHfJ (ORCPT + 99 others); Mon, 3 Oct 2022 03:35:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231476AbiJCHdV (ORCPT ); Mon, 3 Oct 2022 03:33:21 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E1994F640; Mon, 3 Oct 2022 00:21:16 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id AD601B80E7D; Mon, 3 Oct 2022 07:19:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02249C433C1; Mon, 3 Oct 2022 07:19:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781580; bh=hcALJk6w4RJCnEaUh4SaKtByjsv5qo91nSSo7OY8+j8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zi2ApA0RrwAcEPGy+gAH4lvQt6elVKE5VLaAwc+qmzkCN9g6sutajCo4PSMCDoRmY oG2Lys7DcsB3oVjGWBjCR3JXuiMawkJLLFNyEx+MQCNrnDm5eiIFQP/zVffqlSR1sp g2Gyvcq6/ABzh+9byHPEPKrc8uVQSBdqt5r3N/Vc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ian Rogers , Andi Kleen , Adrian Hunter , Alexander Antonov , Alexander Shishkin , Andrew Kilroy , Andrew Morton , Changbin Du , Denys Zagorui , Fabian Hemmer , Felix Fietkau , Heiko Carstens , Ingo Molnar , Jacob Keller , Jiapeng Chong , Jin Yao , Jiri Olsa , Joakim Zhang , John Garry , Kajol Jain , Kan Liang , Kees Kook , Mark Rutland , Namhyung Kim , Nicholas Fraser , Nick Desaulniers , Paul Clarke , Peter Zijlstra , Riccardo Mancini , Sami Tolvanen , ShihCheng Tu , Song Liu , Stephane Eranian , Sumanth Korikkar , Thomas Richter , Wan Jiabing , Zhen Lei , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.15 72/83] perf metric: Only add a referenced metric once Date: Mon, 3 Oct 2022 09:11:37 +0200 Message-Id: <20221003070723.796603884@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070721.971297651@linuxfoundation.org> References: <20221003070721.971297651@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 From: Ian Rogers [ Upstream commit a3de76903dd0786a8661e9e6eb9054a7519e10e7 ] If a metric references other metrics then the same other metrics may be referenced more than once, but the events and metric ref are only needed once. An example of this is in tests/parse-metric.c where DCache_L2_Hits references the metric DCache_L2_All_Hits twice, once directly and once through DCache_L2_All. Signed-off-by: Ian Rogers Acked-by: Andi Kleen Cc: Adrian Hunter Cc: Alexander Antonov Cc: Alexander Shishkin Cc: Andrew Kilroy Cc: Andrew Morton Cc: Changbin Du Cc: Denys Zagorui Cc: Fabian Hemmer Cc: Felix Fietkau Cc: Heiko Carstens Cc: Ingo Molnar Cc: Jacob Keller Cc: Jiapeng Chong Cc: Jin Yao Cc: Jiri Olsa Cc: Joakim Zhang Cc: John Garry Cc: Kajol Jain Cc: Kan Liang Cc: Kees Kook Cc: Mark Rutland Cc: Namhyung Kim Cc: Nicholas Fraser Cc: Nick Desaulniers Cc: Paul Clarke Cc: Peter Zijlstra Cc: Riccardo Mancini Cc: Sami Tolvanen Cc: ShihCheng Tu Cc: Song Liu Cc: Stephane Eranian Cc: Sumanth Korikkar Cc: Thomas Richter Cc: Wan Jiabing Cc: Zhen Lei Link: https://lore.kernel.org/r/20211015172132.1162559-9-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo Stable-dep-of: 71c86cda750b ("perf parse-events: Remove "not supported" hybrid cache events") Signed-off-by: Sasha Levin --- tools/perf/util/metricgroup.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c index 2dc2a0dcf846..ec8195f1ab50 100644 --- a/tools/perf/util/metricgroup.c +++ b/tools/perf/util/metricgroup.c @@ -836,12 +836,18 @@ static int __add_metric(struct list_head *metric_list, *mp = m; } else { /* - * We got here for the referenced metric, via the - * recursive metricgroup__add_metric call, add - * it to the parent group. + * This metric was referenced in a metric higher in the + * tree. Check if the same metric is already resolved in the + * metric_refs list. */ m = *mp; + list_for_each_entry(ref, &m->metric_refs, list) { + if (!strcmp(pe->metric_name, ref->metric_name)) + return 0; + } + + /*Add the new referenced metric to the pare the parent group. */ ref = malloc(sizeof(*ref)); if (!ref) return -ENOMEM; -- 2.35.1