From patchwork Thu Dec 23 07:45:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 12698012 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 84B80C433EF for ; Thu, 23 Dec 2021 08:12:26 +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=q39dwAGFCE5jqgcBfRzo6I3CnVrX/+WSKBpQYCZsqVw=; b=a3ZPoZdBVNdrcrzmx2Hf5oxi6w CPc8w48tMlibmTztLOMoazFnkT9QKuZS2Y+31alXYefgOhkcHd5Q18rsGDg4GJFGh7/aLkNwZSor0 7BwRjMLSzTqqBzs0sfMdVHlmXBUArEH3T3/FvF6GAPAnmFaz9lnATou++pEXrKoBdHe3UDXV2mnuB q34jDsqdwiXfuub25DSUQOPkXNWFXuo6NQIVjlzbSvpPO3wOsiXH5D06YW0ucFUv2bMhJ8SJcGFlf 3Jq7CXBt/Oc/zEBXhBrPPAQfaWkrOPx5Lb1+bNdMFELaxBgE+h3dWYRjazr2DdEX45qyIq8D7U8Ch IzC7DWuQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n0JBW-00C8jQ-Sg; Thu, 23 Dec 2021 08:10:47 +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 1n0Ioy-00Bzz5-Ee for linux-arm-kernel@lists.infradead.org; Thu, 23 Dec 2021 07:47:29 +0000 Received: by mail-yb1-xb49.google.com with SMTP id r18-20020a25ac52000000b005c9047c420bso8731250ybd.4 for ; Wed, 22 Dec 2021 23:47:27 -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=5tVJzNTPrT5Mz019UGpMqh4/y+iJ54XVPfgHv8yLcW0=; b=TQyU/YpVCjIz2BUqO2jBW/aSe8SJJ8OhQe20TBnnnPqLK1vyy6hwJqBFl3KfwmlYdF kD8Yp3uDQNG55m7ttdUsfgTh8YBvFgmISS0eQOzVZuCs3MCyQ6FwIRN2GEJMsnZO2+y/ B/6sX6cO+5HDmbyv5nFF1nn+IJEXKPnTy5G3fNKJP3peVoN+dU3OdYCVo3LEKCM/adaI mKYh9jZwDzP1lcdT/R6LTuzVqw4QwPsQ23imyiDTX7JWhGl1ckosjrz5t61r7O31brcT TLM1yiQYq2u+SX3cObKOaTaHRcVmysUTAIWeZUSOT86CUn8i4H+kDPOgudioV70LLyPu HyKA== 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=5tVJzNTPrT5Mz019UGpMqh4/y+iJ54XVPfgHv8yLcW0=; b=XYpu3DHjMebS4re6ccJB8hngNHUO/5go5y2bJCwnJvCImQ5WQKuTqy+k4E++UwXdIN JuW4WdhUqxrD9gYbElSfRiEEf6cUtAIH/89lYKvHFDexXs5/PD65Fy1Vc0cT/JBuLCJO VYQerSKxExzgEddOr82pWJS+coed+dg87GZdWNxXiDVDCB4g5frwBN1k3gvAimE4UKFw LmA07rhR35Af18DW2gC9oRoHfSa/Ek+kYYS0p4fPcGOWGK19CQ0qFoDihwGt68H8yKcQ 7cvncakoPTq2GYwCb1qN1m5Z/tV0Qqu0pcZRGC+xPpbQ8hBIwnRSThLPycAeDmtHa2P7 4lvQ== X-Gm-Message-State: AOAM533VVJq2z9FgU/Yj3Evfl0kf52BL0+852qFxb6WyGp1Jt3EAXE4o 8ImEznMd/YHpxykmz6LLEehSmWkcrzdP X-Google-Smtp-Source: ABdhPJyftWeLHeEAE1+KjGOdTuxDKZVxQ6Lm+rFn/DSubwAQ+QTEgxV94xTRIHGTQT/w4ZG4G93EWVCQd/mW X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:4fef:90ff:589d:24ca]) (user=irogers job=sendgmr) by 2002:a25:504d:: with SMTP id e74mr1602226ybb.685.1640245647040; Wed, 22 Dec 2021 23:47:27 -0800 (PST) Date: Wed, 22 Dec 2021 23:45:24 -0800 In-Reply-To: <20211223074541.3318938-1-irogers@google.com> Message-Id: <20211223074541.3318938-32-irogers@google.com> Mime-Version: 1.0 References: <20211223074541.3318938-1-irogers@google.com> X-Mailer: git-send-email 2.34.1.307.g9b7440fafd-goog Subject: [PATCH v2 31/48] perf stat: Use perf_cpu_map__for_each_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 Cc: eranian@google.com, Ian Rogers X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211222_234728_537996_D950C5BD X-CRM114-Status: GOOD ( 13.34 ) 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 in print_counter where an index was being used as a cpu. Signed-off-by: Ian Rogers --- tools/perf/util/stat-display.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index 4f93591aaa76..9be74e907352 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -4,6 +4,7 @@ #include #include #include +#include #include "color.h" #include "counts.h" #include "evlist.h" @@ -732,7 +733,7 @@ static void print_aggr(struct perf_stat_config *config, evlist__for_each_entry(evlist, counter) { print_counter_aggrdata(config, counter, s, prefix, metric_only, - &first, -1); + &first, /*cpu=*/-1); } if (metric_only) fputc('\n', output); @@ -893,11 +894,11 @@ static void print_counter(struct perf_stat_config *config, FILE *output = config->output; u64 ena, run, val; double uval; - int cpu; + int idx, cpu; struct aggr_cpu_id id; - for (cpu = 0; cpu < evsel__nr_cpus(counter); cpu++) { - struct aggr_data ad = { .cpu_map_idx = cpu }; + perf_cpu_map__for_each_cpu(cpu, idx, evsel__cpus(counter)) { + struct aggr_data ad = { .cpu_map_idx = idx }; if (!collect_data(config, counter, counter_cb, &ad)) return; @@ -921,10 +922,9 @@ static void print_no_aggr_metric(struct perf_stat_config *config, struct evlist *evlist, char *prefix) { - int cpu, nrcpus; + 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; @@ -1249,7 +1249,7 @@ static void print_percore(struct perf_stat_config *config, print_counter_aggrdata(config, counter, s, prefix, metric_only, - &first, -1); + &first, /*cpu=*/-1); } if (metric_only)