From patchwork Wed Nov 23 18:02:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 25114 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2942219wrr; Wed, 23 Nov 2022 10:05:29 -0800 (PST) X-Google-Smtp-Source: AA0mqf4POUK7DF4xLosLm6BFQeHm15JzRwJ0ibokkSdhlAbOrdpDAB1M/wcpbKxQR90tEMJnNIlQ X-Received: by 2002:a2e:8645:0:b0:279:7b24:641c with SMTP id i5-20020a2e8645000000b002797b24641cmr1158370ljj.344.1669226729437; Wed, 23 Nov 2022 10:05:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669226729; cv=none; d=google.com; s=arc-20160816; b=QMbWfAaKW4X05nLKrpuT+MLTb591aB2yQjz4Zx+wehNKiwxBs9pJ5Ns4OE/+CPdYW5 MPGxMqCd5PjmvOAQEROYXyO4URvYRKG+L7mnbi2k2gjbgR3eYDTRkg5yXveifgUw+Sky aIMkzffG8sOZkdACW+H8PeFpWq1juEhKMpUgguV2wi0ip9J46wxw/v99KLNmrhbFKZ11 QRsuU5FAfXXr9XRoqcCk+OU+2buWnrhGIWvzw18OncEf2Wg5hsYPM1b4tLAfjN5p3zF+ UYT52BKmmyyDg2z/Yz2Tq2RnDnctx6y9gBReAvMY18zSLXy5Q2pNhRBeNfSFQqJnhlT0 popw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=gVc+cia53gYtJDOA2aNz2UfR6QciW5fvjNYuKXlTXq4=; b=EkyO4+GitfB0IUrqTimyX+UeOFhRy/fCWq/1/xCgy2fhmz9sh2SSsu+3DJhzXsaHEC rfE5tM1mhtAC9GTtJgDteJNmZCqF69ZNGAbEZhiVcOALJussHAaGt4AFPln4Dic4aZNh x588fRtSMsbWQ7NH+RppPV0Cilq90mIrYw5D1JV0JESaYtVgNyZbwuHrzozhIp/zUtTT kJLJk3JWUDTctjhaPK64rl7Slxs9/pWbyyr2PwBeOl9LoDZ1k7VVwhiyR2g136UTfHn/ L/DqeZiHt03AzOIFSrnkysncb6NYyDezGuYLg2zX2vKFHMlY0Fzz9T/ADt8htHuwDdVm /BFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=CVU4aHfH; 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=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m8-20020a056402430800b0045d27c0ba90si506256edc.577.2022.11.23.10.04.57; Wed, 23 Nov 2022 10:05:29 -0800 (PST) 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=@gmail.com header.s=20210112 header.b=CVU4aHfH; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239357AbiKWSEG (ORCPT + 99 others); Wed, 23 Nov 2022 13:04:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239297AbiKWSCZ (ORCPT ); Wed, 23 Nov 2022 13:02:25 -0500 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5AEA99371F; Wed, 23 Nov 2022 10:02:24 -0800 (PST) Received: by mail-pg1-x52a.google.com with SMTP id 136so17438688pga.1; Wed, 23 Nov 2022 10:02:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=gVc+cia53gYtJDOA2aNz2UfR6QciW5fvjNYuKXlTXq4=; b=CVU4aHfH1HjPYDPbgIAAAamraN9t24VDNKqRMivTDypso3RSvXpqA3MFB9n+mCtog5 pijZ5QdJRp87JBFrf3Ww6F0AdPdDUDr9XlrICyukYBt+leeGh+llI2CUk96OjdUXMfor muKQ3M3l7WA2qLfztGoxphabOD3XeIwhwndqtdgvK93WJrwC5R4WAeVCE8MT6ZUluWc/ j412ZWOTU4++8uCJgkV7FKFjzaHuQZHEHyCW36vBCALmh/QegKRzWY1wYPir0Lr7b5MK WqbqGelDFP6+pYFJCDsP8+s+253mgjQEUO76UnfzQiWU34DBE59z+YlfevnF/+mfcd5z DPDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=gVc+cia53gYtJDOA2aNz2UfR6QciW5fvjNYuKXlTXq4=; b=H/8OSAF0n64w2RWUN4zEXvGKSTiQSzU9iIJm4J7zK3El/ZHeUYq5rcNgxbMRIf/HUp ydVcMJbvbcV4+LlTkacWvVgQjpuvOtEwbX/84n54q7FqFTue5ZswpilmJiRc+Oheei5a BNmyo9ltaSoRck7+zNQ/GGu0Np4lsfA7BRJWof/Sg+iXDCDcHkFOwHuNxIp1xfSlFbIa uVWAFEqh0z09Gpk4vnUGgvbtHvce2U85K3f7rqMBu36xCNLiij89eY0xor+mMjag+c0z SmuQHrA22W+OrsmpU1YB9MpOxZWPLxx6mAR2AkgwWbI5z/lQnic2q5sAiYjYeSIFT4fZ BJVg== X-Gm-Message-State: ANoB5pmfOZzOaxc7TskGKJi9RfxLNqdPXJOuW5JlGmjYr8x5DiE3Ey1G X4QPIHHJ27PSYTqrHMfLw0h8zhRenZs= X-Received: by 2002:a65:638a:0:b0:46f:1261:ab62 with SMTP id h10-20020a65638a000000b0046f1261ab62mr10227094pgv.414.1669226543726; Wed, 23 Nov 2022 10:02:23 -0800 (PST) Received: from balhae.hsd1.ca.comcast.net ([2601:647:6780:a80:c968:76:254b:3790]) by smtp.gmail.com with ESMTPSA id i15-20020a655b8f000000b00470275c8d6dsm10792364pgr.10.2022.11.23.10.02.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Nov 2022 10:02:23 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Kan Liang , Zhengjun Xing , James Clark , Athira Jajeev Subject: [PATCH 09/15] perf stat: Pass struct outstate to print_metric_begin() Date: Wed, 23 Nov 2022 10:02:02 -0800 Message-Id: <20221123180208.2068936-10-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog In-Reply-To: <20221123180208.2068936-1-namhyung@kernel.org> References: <20221123180208.2068936-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750311086958638814?= X-GMAIL-MSGID: =?utf-8?q?1750311086958638814?= It passes prefix and cgroup pointers but the outstate already has them. Let's pass the outstate pointer instead. Signed-off-by: Namhyung Kim Acked-by: Ian Rogers --- tools/perf/util/stat-display.c | 50 +++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index 70aebf359e16..3ed63061d6f8 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -843,8 +843,7 @@ static void print_counter_aggrdata(struct perf_stat_config *config, static void print_metric_begin(struct perf_stat_config *config, struct evlist *evlist, - const char *prefix, int aggr_idx, - struct cgroup *cgrp) + struct outstate *os, int aggr_idx) { struct perf_stat_aggr *aggr; struct aggr_cpu_id id; @@ -853,15 +852,15 @@ static void print_metric_begin(struct perf_stat_config *config, if (!config->metric_only) return; - if (prefix) - fprintf(config->output, "%s", prefix); + if (os->prefix) + fprintf(config->output, "%s", os->prefix); evsel = evlist__first(evlist); id = config->aggr_map->map[aggr_idx]; aggr = &evsel->stats->aggr[aggr_idx]; aggr_printout(config, evsel, id, aggr->nr); - print_cgroup(config, cgrp); + print_cgroup(config, os->cgrp); } static void print_metric_end(struct perf_stat_config *config) @@ -877,6 +876,9 @@ static void print_aggr(struct perf_stat_config *config, const char *prefix) { struct evsel *counter; + struct outstate os = { + .prefix = prefix, + }; int s; if (!config->aggr_map || !config->aggr_get_id) @@ -887,7 +889,7 @@ static void print_aggr(struct perf_stat_config *config, * Without each counter has its own line. */ for (s = 0; s < config->aggr_map->nr; s++) { - print_metric_begin(config, evlist, prefix, s, /*cgrp=*/NULL); + print_metric_begin(config, evlist, &os, s); evlist__for_each_entry(evlist, counter) { if (counter->merged_stat) @@ -904,26 +906,28 @@ static void print_aggr_cgroup(struct perf_stat_config *config, const char *prefix) { struct evsel *counter, *evsel; - struct cgroup *cgrp = NULL; + struct outstate os = { + .prefix = prefix, + }; int s; if (!config->aggr_map || !config->aggr_get_id) return; evlist__for_each_entry(evlist, evsel) { - if (cgrp == evsel->cgrp) + if (os.cgrp == evsel->cgrp) continue; - cgrp = evsel->cgrp; + os.cgrp = evsel->cgrp; for (s = 0; s < config->aggr_map->nr; s++) { - print_metric_begin(config, evlist, prefix, s, cgrp); + print_metric_begin(config, evlist, &os, s); evlist__for_each_entry(evlist, counter) { if (counter->merged_stat) continue; - if (counter->cgrp != cgrp) + if (counter->cgrp != os.cgrp) continue; print_counter_aggrdata(config, counter, s, prefix); @@ -956,6 +960,9 @@ static void print_no_aggr_metric(struct perf_stat_config *config, { int all_idx; struct perf_cpu cpu; + struct outstate os = { + .prefix = prefix, + }; perf_cpu_map__for_each_cpu(cpu, all_idx, evlist->core.user_requested_cpus) { struct evsel *counter; @@ -973,8 +980,7 @@ static void print_no_aggr_metric(struct perf_stat_config *config, id = aggr_cpu_id__cpu(cpu, /*data=*/NULL); if (first) { - print_metric_begin(config, evlist, prefix, - counter_idx, /*cgrp=*/NULL); + print_metric_begin(config, evlist, &os, counter_idx); first = false; } val = ps->aggr[counter_idx].counts.val; @@ -1347,22 +1353,23 @@ static void print_percore(struct perf_stat_config *config, static void print_cgroup_counter(struct perf_stat_config *config, struct evlist *evlist, const char *prefix) { - struct cgroup *cgrp = NULL; struct evsel *counter; + struct outstate os = { + .prefix = prefix, + }; evlist__for_each_entry(evlist, counter) { - if (cgrp != counter->cgrp) { - if (cgrp != NULL) + if (os.cgrp != counter->cgrp) { + if (os.cgrp != NULL) print_metric_end(config); - cgrp = counter->cgrp; - print_metric_begin(config, evlist, prefix, - /*aggr_idx=*/0, cgrp); + os.cgrp = counter->cgrp; + print_metric_begin(config, evlist, &os, /*aggr_idx=*/0); } print_counter(config, counter, prefix); } - if (cgrp) + if (os.cgrp) print_metric_end(config); } @@ -1405,8 +1412,7 @@ void evlist__print_counters(struct evlist *evlist, struct perf_stat_config *conf } else if (config->cgroup_list) { print_cgroup_counter(config, evlist, os.prefix); } else { - print_metric_begin(config, evlist, os.prefix, - /*aggr_idx=*/0, /*cgrp=*/NULL); + print_metric_begin(config, evlist, &os, /*aggr_idx=*/0); evlist__for_each_entry(evlist, counter) { print_counter(config, counter, os.prefix); }