Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2490584rwb; Mon, 3 Oct 2022 01:12:00 -0700 (PDT) X-Google-Smtp-Source: AMsMyM41nxlo0S5lSQrv7J7+BtcsmspmnjljVzjYygtUfj4/Gy4R/uVBtigSTpTMek8r6psZpcSv X-Received: by 2002:a17:90b:3147:b0:203:6eaa:4894 with SMTP id ip7-20020a17090b314700b002036eaa4894mr11108056pjb.230.1664784720318; Mon, 03 Oct 2022 01:12:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664784720; cv=none; d=google.com; s=arc-20160816; b=bHcQdOIFCC/px0XSkguG8iLh9vbLMBcbW73/oSWLf4KGkBVb+kKLReIiYBwZ5uPo/k WOgzptVCSJ56GmQ4ogzQHViurUj3c0dWP+tLTnMosVSk27vasBZfrUpjKn3HGbd/j1yd /oFGjMS4BW8W5phwj4UODsjG2NtQgocjoeqJqxFB47mcbcPWo0je/UKO3u9mOfkfcfEm eFtByCv7XYYHy5fyH8hF1MS5cdSQJTwITM1m4YSBfNkgCzPLYBGW5YybQxlvybTmukRz iifYczmyy8sVi+HKu+z6TaipmDsKSDrCM1AAqAqHCEG71XvpVSA38gCjYjtKDVsrzHPb hM8w== 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=aZ9DEVTc/HTnHUcJHzuo2Hcq/l+QeoiJUct5qBSFOIQ=; b=OYeQAPNALHwMudJ6/OvL6rPxRTirvras6/Yl5c9fhxPqpVNndpum33pLsrFZYgfQx/ 3/VKYAlnKDfxZGP41V7Cdo7Qt53aS14q3Rc5JYe+CZ7Zo+DUeuBwMPzkxmvxbYN6EiJr bN9VZyogsFT5KFbD6o2xs8jahz8KRvULODnjL2Cnba1hR01IB2+48A6zz+tr4VvJgd/J j9MUNJl5QUvowBe74sF4eEmBOOEihK+I84oKx4gcghCQBiL5KpsjeaG93MdtHg8lx0on 5QBq/shjqrUWKTCWhVpzNT+W6dTBXF57WK5/ExU0SCsKQvjNQcAYWMlgmIR+0lK3TzlA 4KSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AmxX4gkJ; 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 v4-20020a63b944000000b0042b85da3a53si10697780pgo.473.2022.10.03.01.11.49; Mon, 03 Oct 2022 01:12:00 -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=AmxX4gkJ; 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 S231414AbiJCHac (ORCPT + 99 others); Mon, 3 Oct 2022 03:30:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231445AbiJCH3J (ORCPT ); Mon, 3 Oct 2022 03:29:09 -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 18D0A2BDD; Mon, 3 Oct 2022 00:19:53 -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 210BAB80E85; Mon, 3 Oct 2022 07:19:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5849FC433D6; Mon, 3 Oct 2022 07:19:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781577; bh=bQOQHFWXu0Y1xHZRrvTz4L2+IME1DPD6dr71obT4YDM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AmxX4gkJME4pKQ6Szs7ZWMB8JhFs5sjMWuM4uxvVbqabO/tJeanVmAjQ1Kw/iITm3 j6F3yn0q4XrqjYlhNvuzXC0hycZ3nyjH5Sdaarf6oHdFrNxOmduSHsxesK0+WxmmLb +cqxQEQqIpjuQu06qcPFoaHzo0ErDyf+dpfSgA4Y= 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 71/83] perf metric: Add documentation and rename a variable. Date: Mon, 3 Oct 2022 09:11:36 +0200 Message-Id: <20221003070723.771956822@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 68074811dfb9529bb7cade0e67d42c7f7bf209e6 ] Documentation to make current functionality clearer. Rename a variable called 'metric' to 'metric_name' as it can be ambiguous as to whether a string is the name of a metric or the expression. 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-7-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 | 59 ++++++++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 5 deletions(-) diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c index 29b747ac31c1..2dc2a0dcf846 100644 --- a/tools/perf/util/metricgroup.c +++ b/tools/perf/util/metricgroup.c @@ -772,13 +772,27 @@ int __weak arch_get_runtimeparam(struct pmu_event *pe __maybe_unused) struct metricgroup_add_iter_data { struct list_head *metric_list; - const char *metric; + const char *metric_name; struct expr_ids *ids; int *ret; bool *has_match; bool metric_no_group; }; +/** + * __add_metric - Add a metric to metric_list. + * @metric_list: The list the metric is added to. + * @pe: The pmu_event containing the metric to be added. + * @metric_no_group: Should events written to events be grouped "{}" or + * global. Grouping is the default but due to multiplexing the + * user may override. + * @runtime: A special argument for the parser only known at runtime. + * @mp: The pointer to a location holding the first metric added to metric + * list. It is initialized here if this is the first metric. + * @parent: The last entry in a linked list of metrics being + * added/resolved. This is maintained to detect recursion. + * @ids: Storage for parent list. + */ static int __add_metric(struct list_head *metric_list, struct pmu_event *pe, bool metric_no_group, @@ -1068,7 +1082,7 @@ static int metricgroup__add_metric_sys_event_iter(struct pmu_event *pe, struct metric *m = NULL; int ret; - if (!match_pe_metric(pe, d->metric)) + if (!match_pe_metric(pe, d->metric_name)) return 0; ret = add_metric(d->metric_list, pe, d->metric_no_group, &m, NULL, d->ids); @@ -1087,7 +1101,22 @@ static int metricgroup__add_metric_sys_event_iter(struct pmu_event *pe, return ret; } -static int metricgroup__add_metric(const char *metric, bool metric_no_group, +/** + * metricgroup__add_metric - Find and add a metric, or a metric group. + * @metric_name: The name of the metric or metric group. For example, "IPC" + * could be the name of a metric and "TopDownL1" the name of a + * metric group. + * @metric_no_group: Should events written to events be grouped "{}" or + * global. Grouping is the default but due to multiplexing the + * user may override. + * @events: an out argument string of events that need to be parsed and + * associated with the metric. For example, the metric "IPC" would + * create an events string like "{instructions,cycles}:W". + * @metric_list: The list that the metric or metric group are added to. + * @map: The map that is searched for metrics, most commonly the table for the + * architecture perf is running upon. + */ +static int metricgroup__add_metric(const char *metric_name, bool metric_no_group, struct strbuf *events, struct list_head *metric_list, struct pmu_events_map *map) @@ -1099,7 +1128,11 @@ static int metricgroup__add_metric(const char *metric, bool metric_no_group, int i, ret; bool has_match = false; - map_for_each_metric(pe, i, map, metric) { + /* + * Iterate over all metrics seeing if metric matches either the name or + * group. When it does add the metric to the list. + */ + map_for_each_metric(pe, i, map, metric_name) { has_match = true; m = NULL; @@ -1122,7 +1155,7 @@ static int metricgroup__add_metric(const char *metric, bool metric_no_group, .fn = metricgroup__add_metric_sys_event_iter, .data = (void *) &(struct metricgroup_add_iter_data) { .metric_list = &list, - .metric = metric, + .metric_name = metric_name, .metric_no_group = metric_no_group, .ids = &ids, .has_match = &has_match, @@ -1161,6 +1194,22 @@ static int metricgroup__add_metric(const char *metric, bool metric_no_group, return ret; } +/** + * metricgroup__add_metric_list - Find and add metrics, or metric groups, + * specified in a list. + * @list: the list of metrics or metric groups. For example, "IPC,CPI,TopDownL1" + * would match the IPC and CPI metrics, and TopDownL1 would match all + * the metrics in the TopDownL1 group. + * @metric_no_group: Should events written to events be grouped "{}" or + * global. Grouping is the default but due to multiplexing the + * user may override. + * @events: an out argument string of events that need to be parsed and + * associated with the metric. For example, the metric "IPC" would + * create an events string like "{instructions,cycles}:W". + * @metric_list: The list that metrics are added to. + * @map: The map that is searched for metrics, most commonly the table for the + * architecture perf is running upon. + */ static int metricgroup__add_metric_list(const char *list, bool metric_no_group, struct strbuf *events, struct list_head *metric_list, -- 2.35.1