From patchwork Thu Dec 23 07:44:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 12697980 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 BBA76C4332F for ; Thu, 23 Dec 2021 07:48:25 +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=8JdOnq16I2bdoVUCjtlQbmcMLHRAlaYVd16OLNfClzg=; b=aKcmX6BBqsfU1spjoC5v01qyWK 2kzrKaDFCh+yr60dJfChJ3lH//XUsDhB4qUy0RRAj7jPNWvMi3XZgikvUtBnBJYpy0+4K4TtL8Kft IDNVbR1prWBvno6ab/nK68J7hWVHunyeKSC+EeFa6NO1+kdolnyUnC5LGvwN1QCpfdezK/YW3d1yV xPtsSsRpyYI+UBd5U3CAjvvdTyEymKV1MpWKpQvM4r2Rzg7VHHaiWzbFjyfHVdZm5jEr+4tmnaQS2 lluibV7PscuRZroZdhBbFC/Ifl8ZWe3SWRUmEin7VpWhAB4NqpB5Bis93z1cP+YnqucLLwuYNQkmJ 8C/rLlHg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n0IoL-00Bzdo-9X; Thu, 23 Dec 2021 07:46:49 +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 1n0Inp-00BzOb-J3 for linux-arm-kernel@lists.infradead.org; Thu, 23 Dec 2021 07:46:18 +0000 Received: by mail-yb1-xb49.google.com with SMTP id l75-20020a25254e000000b005f763be2fecso8693550ybl.7 for ; Wed, 22 Dec 2021 23:46:16 -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=jOgZ+dsJ80gHSAYy1PEpxKlsT1rqOZcGXpM1p4DxDhE=; b=ALf5lK2Ov9iU0BCplEQ5qzLZD7goP9VK6FnyebpGcOLPQu3jXAT/OSi3DRcgeN1fco jwkPOMuiD1cTWg2Ad0l2cmneh3EFHLIOv69P162DKV7OWumzO8IsF2aAr6to7l7qZnPe 6XnF1x6GRmW2GIcUd75SIUH/pyZ0pm+Y+TFkldWmTVIJ60iz+T1Ywc4wb7nHTSYmaAad 1zFjWy9/eBiWNX2hjiHlYE/vCmM2q3qcYrdnBD9R/En8VltJoH7wN2kjCIdAFIOxKrYp +bZyXBaC8R8aY3bPJWxaIuQfcRZPwz14V5P9VKxfa4jrg0CzPjtuf0cqebNdgcYHTq5H 73wg== 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=jOgZ+dsJ80gHSAYy1PEpxKlsT1rqOZcGXpM1p4DxDhE=; b=y1yFxNyP3302xmBavOrMVgzw4LiUSPEycXVC0HOiMhy0CihakvXg70hLnPinRAZFyY M/Q4P4xpKLSiF6rTDRIMmh87+vvS/oR8wY/nuYfqGTjDEJI5g1/uAhDkcRvUUm7stZ5U sXNxHDIkQWPcSSh4BN449yBNAFgdp2km07Y2Kzcu1vPhKv+1EZlgz2t422kUCpwXJJMr w6r4Al/y6FFzS/REIP/Wx69bzdpdnFBpzMlZ+fwzxCfxpsGWjImyCtj/8A5nguzjuCAA T4v3Lk8ZxdIbD1Q4id7Uz/6xvphyDQ+QwLltVVTg8XJzQfpABZ7xkokIRA4JIKFVSS+C /Qpg== X-Gm-Message-State: AOAM530jcpYZEil/JZBu7huGdR5lRZSv0lmZl698Iaobp0kaWSBDpY5W ZQ/UXNQ0Nx4ARsVg7/0sNx1nWW65IBcg X-Google-Smtp-Source: ABdhPJxfqk1AW2t7CvhGLgWlWdGHvdajhUDHd3O9XpcDl32AG8vbZ3Z1T8RUrnMO7UiDO8j9a3C8qoAvj20/ X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:4fef:90ff:589d:24ca]) (user=irogers job=sendgmr) by 2002:a25:bfd2:: with SMTP id q18mr1882341ybm.542.1640245575752; Wed, 22 Dec 2021 23:46:15 -0800 (PST) Date: Wed, 22 Dec 2021 23:44:56 -0800 In-Reply-To: <20211223074541.3318938-1-irogers@google.com> Message-Id: <20211223074541.3318938-4-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 03/48] perf stat: Correct aggregation CPU map 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_234617_654444_C3BB27B3 X-CRM114-Status: GOOD ( 14.19 ) 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 Switch the perf_cpu_map in aggr_update_shadow from the evlist to the counter's cpu map, so the index is appropriate. This addresses a problem where uncore counts, with a cpumap like: $ cat /sys/devices/uncore_imc_0/cpumask 0,18 Don't aggregate counts in CPUs based on the index of those values in the cpumap (0 and 1) but on the actual CPU (0 and 18). Thereby correcting metric calculations in per-socket mode for counters without a full cpumask. On a SkylakeX with a tweaked DRAM_BW_Use metric, to remove unnecessary scaling, this gives: Before: $ /perf stat --per-socket -M DRAM_BW_Use -I 1000 1.001102293 S0 1 27.01 MiB uncore_imc/cas_count_write/ # 103.00 DRAM_BW_Use 1.001102293 S0 1 30.22 MiB uncore_imc/cas_count_read/ 1.001102293 S0 1 1,001,102,293 ns duration_time 1.001102293 S1 1 20.10 MiB uncore_imc/cas_count_write/ # 0.00 DRAM_BW_Use 1.001102293 S1 1 32.74 MiB uncore_imc/cas_count_read/ 1.001102293 S1 0 ns duration_time 2.003517973 S0 1 83.04 MiB uncore_imc/cas_count_write/ # 920.00 DRAM_BW_Use 2.003517973 S0 1 145.95 MiB uncore_imc/cas_count_read/ 2.003517973 S0 1 1,002,415,680 ns duration_time 2.003517973 S1 1 302.45 MiB uncore_imc/cas_count_write/ # 0.00 DRAM_BW_Use 2.003517973 S1 1 290.99 MiB uncore_imc/cas_count_read/ 2.003517973 S1 0 ns duration_time After: $ perf stat --per-socket -M DRAM_BW_Use -I 1000 1.001080840 S0 1 24.96 MiB uncore_imc/cas_count_write/ # 54.00 DRAM_BW_Use 1.001080840 S0 1 33.64 MiB uncore_imc/cas_count_read/ 1.001080840 S0 1 1,001,080,840 ns duration_time 1.001080840 S1 1 42.43 MiB uncore_imc/cas_count_write/ # 84.00 DRAM_BW_Use 1.001080840 S1 1 47.05 MiB uncore_imc/cas_count_read/ 1.001080840 S1 0 ns duration_time Signed-off-by: Ian Rogers --- tools/perf/util/stat-display.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index 588601000f3f..b0fa81ffce61 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -526,7 +526,7 @@ static void aggr_update_shadow(struct perf_stat_config *config, evlist__for_each_entry(evlist, counter) { val = 0; for (cpu = 0; cpu < evsel__nr_cpus(counter); cpu++) { - s2 = config->aggr_get_id(config, evlist->core.cpus, cpu); + s2 = config->aggr_get_id(config, evsel__cpus(counter), cpu); if (!cpu_map__compare_aggr_cpu_id(s2, id)) continue; val += perf_counts(counter->counts, cpu, 0)->val;