Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp8128280rwb; Wed, 23 Nov 2022 16:06:47 -0800 (PST) X-Google-Smtp-Source: AA0mqf4dkO9SepnomVJY7FS1sDGQjRF4W73ECawWkFJjRzzV1gmqhAsE8KPTjY0e4t/JnJT4+vYZ X-Received: by 2002:aa7:c407:0:b0:46a:81d8:f4 with SMTP id j7-20020aa7c407000000b0046a81d800f4mr422751edq.421.1669248407166; Wed, 23 Nov 2022 16:06:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669248407; cv=none; d=google.com; s=arc-20160816; b=Lx0VDh5Shr5Hfbrq6IAZt40LYDOwbbzh08KvskAKx0/JJvq5LHY9Z4RkC9VAFKb8VM eeYKYqjXDdMyKqcvR9b3qq84hRhGbHmg2Q8L9SoCVAPYF+/d9aK1ffFV1DClWPROUj4Z 2IRfP9IYEFdJOO4gwW/kViP9AK6T8nnlR2dkj7QSyGkTkA23auPYm804gniP/BkcapSb VuNdJuYG76PHfKbfh13R9Rg3S7tVf6nSWSGjP6VgaXESVstp0bTPVNO9Uf8XNupN52Sa J4bFrQNB6bLcuktqYjotJjBW5W7uy3Fn5jgPSEFdUskKdwaDNBUrKs3/iUKP0wJGeH9T ilKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=chKYKremI8l82yLQBleCjCfCnE6ikjwksdBvNeUY2BY=; b=1EDeTaSjakvOfobdutQ3yJ9/kuf8xxvfFa1isTk5Ef1SEJG7hnam4Ts123Dkcr+hT0 +kVvB4kBDS/RAjbzP/5ljJM+mUPX55GIDoWJTswKb6zrIYTt98t7bW6aVNcyPBZG6BQ8 mlKx2zFekITJptsW2MPHcy9a1FX1yK7ouh04T3bw2NGgTizfRUdktee9U/QgXslZA2JA TkQekukdpBNmiJ7ZrwSoXEj47grkVND/6myFKkMaKUdSGjYTlhZYLtQti30Cn7uwGeyi 1WLfHuKjV/1SEcs3DzsLVeYY6hTkpUZNZkjfjaR0RePgdye3HA3sE5ZWjoqXEmfyJzIf PFLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=F2H0b8sb; 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 g6-20020a056402428600b0045fc837677csi525531edc.450.2022.11.23.16.06.25; Wed, 23 Nov 2022 16:06:47 -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=@google.com header.s=20210112 header.b=F2H0b8sb; 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 S229675AbiKWXZc (ORCPT + 88 others); Wed, 23 Nov 2022 18:25:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229896AbiKWXZ1 (ORCPT ); Wed, 23 Nov 2022 18:25:27 -0500 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8656110902 for ; Wed, 23 Nov 2022 15:25:26 -0800 (PST) Received: by mail-wr1-x430.google.com with SMTP id z4so16474wrr.3 for ; Wed, 23 Nov 2022 15:25:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=chKYKremI8l82yLQBleCjCfCnE6ikjwksdBvNeUY2BY=; b=F2H0b8sbV3VuxorK3eUw56iopjhu2K4/r/sIVLjgacR+sPFVdX4Va4sie9GQFuKMBy UWagscDfZGav1T6v9KGGJZ5XYna09Or3U4adG7YIbnW/+8bQyoXeSnAvrFt6r2A4Znvn sUSvfFPjiW2xANP7aUBCn+k95uKy3FEMnzfVJYhU1oH+hWpRYGf+El4UhLj7EmgJNoIM lFHQWqjwVpTGoRuQKofShYE7P85nbYHFIC3g6Xsiy9lH828GrOLshouScZLw9QbO+4dS 2quHGRqIQJbbIL+GkSxCfVrGRzh5G17O+4PG2DVukvA7F31Pq3KEeeRv8DACZkRrKejJ hMWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=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=chKYKremI8l82yLQBleCjCfCnE6ikjwksdBvNeUY2BY=; b=1WDTAwN7xNj/fIdvySJK/za9kjYTZkVLKaT4ltXy6RDXOWbjhmIucc89kVb4VZfyYW wkLjQ2dEzysShpGH6btghFiOIMnfu0cU+Y9Z/8Vn0E2I52YMO0+x2Rtzv6UzUSVQL3Gt kAothHmkZxuZzUPMBxOOyVIDi7COFHPpsEm1C9rZQbdjZkvLD1/LMqNdPXXJLsSwJR7I KD1lC8GpdutkGYZH/ZOF2gag8yjmW6U5atwsFxlrjgBhCrLKOB5xl9IezWPeoa9sBcCl 82PLshxTd1UHVIA+oc9X3SspCNFwSwVpbkp3TXaMXp5MtA1dEh+tqGE0BHFCQkM9vnaQ ylvQ== X-Gm-Message-State: ANoB5pm7h6G4eZQ/DHBsvp2UcjtEiCxuv5KYXrXv6O43Ut98OpNBRdRX Vf+rsIvabF9RUTb1CX+f2kGo1YeyhFBY2vYqnOdH9w== X-Received: by 2002:adf:f6cc:0:b0:228:dd1d:8a42 with SMTP id y12-20020adff6cc000000b00228dd1d8a42mr7212105wrp.375.1669245924985; Wed, 23 Nov 2022 15:25:24 -0800 (PST) MIME-Version: 1.0 References: <20221123180208.2068936-1-namhyung@kernel.org> <20221123180208.2068936-10-namhyung@kernel.org> In-Reply-To: <20221123180208.2068936-10-namhyung@kernel.org> From: Ian Rogers Date: Wed, 23 Nov 2022 15:25:12 -0800 Message-ID: Subject: Re: [PATCH 09/15] perf stat: Pass struct outstate to print_metric_begin() To: Namhyung Kim Cc: Arnaldo Carvalho de Melo , Jiri Olsa , Ingo Molnar , Peter Zijlstra , LKML , Adrian Hunter , linux-perf-users@vger.kernel.org, Kan Liang , Zhengjun Xing , James Clark , Athira Jajeev Content-Type: text/plain; charset="UTF-8" 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, 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, Nov 23, 2022 at 10:02 AM Namhyung Kim wrote: > > 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 Thanks, Ian > --- > 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); > } > -- > 2.38.1.584.g0f3c55d4c2-goog >