From patchwork Thu Dec 30 07:20:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 12701287 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4D39EC433EF for ; Thu, 30 Dec 2021 07:41:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=aYHc8JNSkuPEP6nD3vI3zt4INtY0uswgWdXplZoIuuk=; b=CwFNz1GpDst8VwZJfzjG94JWzi dNXEr9a26YGqpfHzKGqJOrLPAFn0tgHh8IFQsyQFWcAg63pyFB3dG83cTteHoa7dv2k4SgntARxon C0W2hxTR1sGRtwDVXzGNDUeJM70V0KhVJtzVBd1Y07dujj1sBsARvfFtuIpLL6WV2rEN+92AxX1nS Mo5kZHVgmyIIqjeH9qmz6/7nizj9wFYB8CNAwDJYk1TUVp9rTsAGkjsxN2FuSRuq8O9oiCqmEmJwC NbaHry/fJ7Lpjpk8Hoc2/tP0YtgwpyRBs4QpwM2xYevZNGpaTJviZIRcwjnQzoh24Ybm31751Bqju A+9ufr+Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n2q2L-003qVW-AM; Thu, 30 Dec 2021 07:39:46 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n2pks-003juE-3F for linux-arm-kernel@lists.infradead.org; Thu, 30 Dec 2021 07:21:43 +0000 Received: by mail-yb1-xb49.google.com with SMTP id c132-20020a251c8a000000b0060c39ab7d36so23100507ybc.12 for ; Wed, 29 Dec 2021 23:21:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=MyX41obsfTbklj5mP7URo6KOdoHhcEiYJDRkMl7AGdI=; b=LObQmT9LTPmbnq9p8gFeTKDRdvi+Xxhm9mKW2yrrqr1LRU3ZF6WGa7V0yeYNIS4Zry NUTNYXdHzrCU3oIbpmoNuJHFNr8Ng0dX7xOg93LGT7MCK6h/96Cb/j9IY+PIU9aRHKqG Vd4GwDaAeVv5FiPnEQdwhSoi6xjxrVFv8uMNcl8/J7FTXqfpE5FmcRHU8FN5OHHDM+4P G7UD8KHB8IRx7wC/Yfq+TYH84JU57Qn7AuwtwCkL0ZGonCLpbr3xAHaLNus6twfEffHk 7tADUxWwhCVTT2OFimaZSXicJDYt8hRNHsXofd8Bv5vB7CCTcsobzpPmZ5N4uwLbrsZF sP8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=MyX41obsfTbklj5mP7URo6KOdoHhcEiYJDRkMl7AGdI=; b=rkmQFIB0FO7RX15V80I7mVlR55Re7kxAY/Z/OqcK6SYgtTzlXIy3KZUAwZb0mjAJA5 ja0pR0tG4HEnEwhjwD1YQevcyVLbH4MxpNSHTealEC8usCQsvdD/osplB0+SbEfx8kM9 q0AcKJJ99hqFdg1k4rjMScU43RwTFgCBYm/ynphkRmstBSITIvFJmr9ZeJZr6nrge0z2 ZHI6DkfDJH5H1qGztlCAXr5fvTR/UCmrO1yzqGeOqhL3WumwqMt4xLbbUNwb3zzgvhFg xBuenHBViKGbsxFDqcXTARjySviAmnqQx1opJQA1cywW0UR9KvByPmbaRDJoFVc3VZ8G bXKg== X-Gm-Message-State: AOAM5325QZQMcpc22CI0Rbi10zRSGndIexlbX+ruiIZAzyNCbtMGUBcs NhgwPInL5eLkRVCYYTtiHXSq4qfW6qJV X-Google-Smtp-Source: ABdhPJxRg4qJJebeV7CpE9vROn1liGtbz9yh2zMu7YKeoig64yqoc+FZQDgbYrhwZMJdAyp1bR9sXlKR/2Ee X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:31c4:9539:dba1:a82b]) (user=irogers job=sendgmr) by 2002:a25:7dc2:: with SMTP id y185mr35577232ybc.352.1640848900528; Wed, 29 Dec 2021 23:21:40 -0800 (PST) Date: Wed, 29 Dec 2021 23:20:07 -0800 In-Reply-To: <20211230072030.302559-1-irogers@google.com> Message-Id: <20211230072030.302559-27-irogers@google.com> Mime-Version: 1.0 References: <20211230072030.302559-1-irogers@google.com> X-Mailer: git-send-email 2.34.1.448.ga2b2bfdf31-goog Subject: [PATCH v3 25/48] perf stat-display: Avoid use of core for CPU. From: Ian Rogers To: Andi Kleen , Jiri Olsa , Namhyung Kim , John Garry , Kajol Jain , "Paul A . Clarke" , Arnaldo Carvalho de Melo , Riccardo Mancini , Kan Liang , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Vineet Singh , James Clark , Mathieu Poirier , Suzuki K Poulose , Mike Leach , Leo Yan , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, zhengjun.xing@intel.com Cc: eranian@google.com, Ian Rogers X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211229_232142_193199_14A27243 X-CRM114-Status: GOOD ( 15.17 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Correct use of cpumap index in print_no_aggr_metric. Signed-off-by: Ian Rogers --- tools/perf/util/stat-display.c | 45 +++++++++++++++++----------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index 870b1db71fbc..f48d1678861c 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -120,11 +120,10 @@ static void aggr_printout(struct perf_stat_config *config, id.die, config->csv_output ? 0 : -3, id.core, config->csv_sep); - } else if (id.core > -1) { + } else if (id.cpu > -1) { fprintf(config->output, "CPU%*d%s", config->csv_output ? 0 : -7, - evsel__cpus(evsel)->map[id.core], - config->csv_sep); + id.cpu, config->csv_sep); } break; case AGGR_THREAD: @@ -334,7 +333,7 @@ static int first_shadow_cpu(struct perf_stat_config *config, int cpu, idx; if (config->aggr_mode == AGGR_NONE) - return id->core; + return id->cpu; if (!config->aggr_get_id) return 0; @@ -697,10 +696,9 @@ static void print_counter_aggrdata(struct perf_stat_config *config, fprintf(output, "%s", prefix); uval = val * counter->scale; - if (cpu != -1) { - id = aggr_cpu_id__empty(); - id.core = cpu; - } + if (cpu != -1) + id = aggr_cpu_id__cpu(cpu, /*data=*/NULL); + printout(config, id, nr, counter, uval, prefix, run, ena, 1.0, &rt_stat); if (!metric_only) @@ -911,8 +909,7 @@ static void print_counter(struct perf_stat_config *config, fprintf(output, "%s", prefix); uval = val * counter->scale; - id = aggr_cpu_id__empty(); - id.core = cpu; + id = aggr_cpu_id__cpu(cpu, /*data=*/NULL); printout(config, id, 0, counter, uval, prefix, run, ena, 1.0, &rt_stat); @@ -924,29 +921,31 @@ static void print_no_aggr_metric(struct perf_stat_config *config, struct evlist *evlist, char *prefix) { - int cpu; - int nrcpus = 0; - struct evsel *counter; - u64 ena, run, val; - double uval; - struct aggr_cpu_id id; + int all_idx, cpu; - nrcpus = evlist->core.cpus->nr; - for (cpu = 0; cpu < nrcpus; cpu++) { + perf_cpu_map__for_each_cpu(cpu, all_idx, evlist->core.cpus) { + struct evsel *counter; bool first = true; if (prefix) fputs(prefix, config->output); evlist__for_each_entry(evlist, counter) { - id = aggr_cpu_id__empty(); - id.core = cpu; + u64 ena, run, val; + double uval; + struct aggr_cpu_id id; + int counter_idx = perf_cpu_map__idx(evsel__cpus(counter), cpu); + + if (counter_idx < 0) + continue; + + id = aggr_cpu_id__cpu(cpu, /*data=*/NULL); if (first) { aggr_printout(config, counter, id, 0); first = false; } - val = perf_counts(counter->counts, cpu, 0)->val; - ena = perf_counts(counter->counts, cpu, 0)->ena; - run = perf_counts(counter->counts, cpu, 0)->run; + val = perf_counts(counter->counts, counter_idx, 0)->val; + ena = perf_counts(counter->counts, counter_idx, 0)->ena; + run = perf_counts(counter->counts, counter_idx, 0)->run; uval = val * counter->scale; printout(config, id, 0, counter, uval, prefix,