From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E12B8C433F5 for ; Mon, 28 Mar 2022 06:25:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238434AbiC1G0y (ORCPT ); Mon, 28 Mar 2022 02:26:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238452AbiC1G0V (ORCPT ); Mon, 28 Mar 2022 02:26:21 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B005522D3 for ; Sun, 27 Mar 2022 23:24:33 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-2e642be1a51so109966827b3.21 for ; Sun, 27 Mar 2022 23:24:33 -0700 (PDT) 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=9DdBX2SnvA0xmL5taueohrnj4hozmwadyqsEuZMg/sA=; b=JExcflpahLFCp46tCO+bVKhfqtpGsdrFCJs+A4n7LEj0S0oyM28aQpiH9N2I4o3EFq qv6yOpmEB4FHmzEJDFtrlj5POsxwk7ymhkoAZGKLNsnrUMmG7PhVKT+rNPkl7WrEnsRG r+DGYQwjH6ShFQ0BJbAPo3ulaNKd7bAJJW2F8mb0pcjRDO3zlwYg6zLaYLbBc17pLs+e 1PgB6LDqxrfexhWFD9UWMtQIlMqoh3dCxy7XUyejsjPNhj1KacYCvXPRwTBhF+BOCrYj K0AonuWZtGaodLfoc3NG1ln7v73zS22G4J7e++zg1bmud/pqhRfzzj1pMmNSlD2pY85i UZsw== 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=9DdBX2SnvA0xmL5taueohrnj4hozmwadyqsEuZMg/sA=; b=qg6viFJx8BTLrAmFgbiztWGj12Z0jnvaX6dXv9jIsYO8oZv2a6yYhe8LuWZ128xnVf oUm4qVH9QJaXHEa0PjNF4kFJA1hDeMEP4hOjXAzLbrppKtv5I51p5ya2PU4I0SIrdRtp 4pwiAQOUg+dVPgT1GZqWANDFUUoLA50tJIxqnA+3OhGyU7fLOf4OrabQmlCU6fz6W4YI Sk+ejecZao3zQ7+MqEMrw0o3njBd95zrfIi5Lj1a2Bi+r+7rKpB6FkIq6A9vsF2+qf5L jSBi9Nf2noSrZ/kVwkjexKOLnjBlJjzgBmBe129NtYqTBkpwKcAe8No2OfPIQljGQrLz cUEA== X-Gm-Message-State: AOAM531sylaUIQnQeTWcUUD+xO+uaxkXW08Y3eXowUWpVyBQZthYa5j+ km3oP1d1ME+44uR3H0/dK6sNOMWNzqvT X-Google-Smtp-Source: ABdhPJxPf/g6psmSnbUpwgPJRs5+zV2W469Tco/QieQGsDIBSkUvRLgEjG1Y+RiHh3KzGowWDsrlmJTLCwDJ X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:ef08:ed1b:261f:77fa]) (user=irogers job=sendgmr) by 2002:a25:ec08:0:b0:633:9106:b10b with SMTP id j8-20020a25ec08000000b006339106b10bmr22130772ybh.62.1648448672235; Sun, 27 Mar 2022 23:24:32 -0700 (PDT) Date: Sun, 27 Mar 2022 23:24:14 -0700 In-Reply-To: <20220328062414.1893550-1-irogers@google.com> Message-Id: <20220328062414.1893550-6-irogers@google.com> Mime-Version: 1.0 References: <20220328062414.1893550-1-irogers@google.com> X-Mailer: git-send-email 2.35.1.1021.g381101b075-goog Subject: [PATCH 5/5] perf evlist: Respect all_cpus when setting user_cpus From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Mathieu Poirier , Suzuki K Poulose , Mike Leach , Leo Yan , John Garry , Will Deacon , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Kajol Jain , James Clark , German Gomez , Adrian Hunter , Riccardo Mancini , Andi Kleen , Alexey Bayduraev , Alexander Antonov , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, bpf@vger.kernel.org Cc: Stephane Eranian , Ian Rogers Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If all_cpus is calculated it represents the merge/union of all evsel cpu maps. By default user_cpus is computed to be the online CPUs. For uncore events, it is often the case currently that all_cpus is a subset of user_cpus. Metrics printed without aggregation and with metric-only, in print_no_aggr_metric, iterate over user_cpus assuming every CPU has a metric to print. For each CPU the prefix is printed, but then if the evsel's cpus doesn't contain anything you get an empty line like the following on a SkylakeX: ``` $ perf stat -A -M DRAM_BW_Use -a --metric-only -I 1000 1.000453137 CPU0 0.00 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 CPU18 0.00 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 2.003717143 CPU0 0.00 ... ``` While it is possible to be lazier in printing the prefix and trailing newline, having user_cpus not be a subset of all_cpus is preferential so that wasted work isn't done elsewhere user_cpus is used. The change modifies user_cpus to be the intersection of user specified CPUs, or default all online CPUs, with the CPUs computed through the merge of all evsel cpu maps. New behavior: ``` $ perf stat -A -M DRAM_BW_Use -a --metric-only -I 1000 1.001086325 CPU0 0.00 1.001086325 CPU18 0.00 2.003671291 CPU0 0.00 2.003671291 CPU18 0.00 ... ``` Signed-off-by: Ian Rogers --- tools/perf/util/evlist.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index d335fb713f5e..91bbb66b7e9a 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -1036,6 +1036,8 @@ int evlist__create_maps(struct evlist *evlist, struct target *target) if (!cpus) goto out_delete_threads; + if (evlist->core.all_cpus) + cpus = perf_cpu_map__intersect(cpus, evlist->core.all_cpus); evlist->core.has_user_cpus = !!target->cpu_list && !target->hybrid; perf_evlist__set_maps(&evlist->core, cpus, threads); -- 2.35.1.1021.g381101b075-goog From mboxrd@z Thu Jan 1 00:00:00 1970 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 28B87C433F5 for ; Mon, 28 Mar 2022 06:26:49 +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=nzkPBPlJM22MS2c9eR4pUbK5VkIrHAoCHlWLXi9l0wU=; b=VuTLA6irjACOKZeQftWahPyTaW bTQVaBH3uhclH7PwmPo8g5Rpdc2pCLUAN7GMlkdxxAnyiqPyEVxbKI9SPU8xgSRRsrzwfYnn7KSrF fee4nWd+8qRTYhbncDQWf+P/RnXkKs8oy+V1vYszG0Ia3wQeKZT9l23Cb46Bm2XhlNqLBZi8OrJyK H5dJ7zCriWBZgVLfVLWqd5M+biUI1G3Vo7cFMWVxLmzbnEi+FqQS7cIFmlB/JlXQjgYly77DizijP Sko7vuVdBNLPeMhaFZ2RHHGSCLQYCNKmhdF5XcbskOQFmi/9T0JPhmfJqFEHegNBmcqM+S6osfOg+ dxGL3bpA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nYion-007TLJ-FZ; Mon, 28 Mar 2022 06:25:33 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nYinp-007Swa-O1 for linux-arm-kernel@lists.infradead.org; Mon, 28 Mar 2022 06:24:35 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-2e5a3c1384cso110771397b3.4 for ; Sun, 27 Mar 2022 23:24:32 -0700 (PDT) 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=9DdBX2SnvA0xmL5taueohrnj4hozmwadyqsEuZMg/sA=; b=JExcflpahLFCp46tCO+bVKhfqtpGsdrFCJs+A4n7LEj0S0oyM28aQpiH9N2I4o3EFq qv6yOpmEB4FHmzEJDFtrlj5POsxwk7ymhkoAZGKLNsnrUMmG7PhVKT+rNPkl7WrEnsRG r+DGYQwjH6ShFQ0BJbAPo3ulaNKd7bAJJW2F8mb0pcjRDO3zlwYg6zLaYLbBc17pLs+e 1PgB6LDqxrfexhWFD9UWMtQIlMqoh3dCxy7XUyejsjPNhj1KacYCvXPRwTBhF+BOCrYj K0AonuWZtGaodLfoc3NG1ln7v73zS22G4J7e++zg1bmud/pqhRfzzj1pMmNSlD2pY85i UZsw== 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=9DdBX2SnvA0xmL5taueohrnj4hozmwadyqsEuZMg/sA=; b=ljmOyzkHXjhpxTuUDM8E6TnhZ/Vg2/NcI4XUbIBexRLMJ+E2trvwBFUdlNX6lU1ngG ++GBJnfFQrVvm2w0bBjb7hicS0WIrqeWrWYwZz34c8DbaKmj7rirl0KOzXA195ewV1sM Sx9j6cRbFjxaw8278XkeY+6mtz+c3qOADqeAMwJorRYozhdsLK/27ajxaiqMycOuCwqf 3BDgxOLVAIlXEIpI4bOeVm8lbsP9hCHh5RcFAOFhRU/NXuoKMMAXnpMPPQbyCdNpgqQX vUBUHVMdlFsy6FS7gsjdzJAKqrelIwF4piSwmIxqUQ7OZQt/jidL+BAULn9r3W3t1V5D wWtg== X-Gm-Message-State: AOAM5318qJoCwIjfPqsEH5dDpeHlJEaVjaD6sHDM3jin4cvMDK2uSC9H WxaWx1cU1TfOK+VnGAtOsKDWqgPRVzo4 X-Google-Smtp-Source: ABdhPJxPf/g6psmSnbUpwgPJRs5+zV2W469Tco/QieQGsDIBSkUvRLgEjG1Y+RiHh3KzGowWDsrlmJTLCwDJ X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:ef08:ed1b:261f:77fa]) (user=irogers job=sendgmr) by 2002:a25:ec08:0:b0:633:9106:b10b with SMTP id j8-20020a25ec08000000b006339106b10bmr22130772ybh.62.1648448672235; Sun, 27 Mar 2022 23:24:32 -0700 (PDT) Date: Sun, 27 Mar 2022 23:24:14 -0700 In-Reply-To: <20220328062414.1893550-1-irogers@google.com> Message-Id: <20220328062414.1893550-6-irogers@google.com> Mime-Version: 1.0 References: <20220328062414.1893550-1-irogers@google.com> X-Mailer: git-send-email 2.35.1.1021.g381101b075-goog Subject: [PATCH 5/5] perf evlist: Respect all_cpus when setting user_cpus From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Mathieu Poirier , Suzuki K Poulose , Mike Leach , Leo Yan , John Garry , Will Deacon , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Kajol Jain , James Clark , German Gomez , Adrian Hunter , Riccardo Mancini , Andi Kleen , Alexey Bayduraev , Alexander Antonov , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, bpf@vger.kernel.org Cc: Stephane Eranian , Ian Rogers X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220327_232433_823830_4C0B3AA1 X-CRM114-Status: GOOD ( 14.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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org If all_cpus is calculated it represents the merge/union of all evsel cpu maps. By default user_cpus is computed to be the online CPUs. For uncore events, it is often the case currently that all_cpus is a subset of user_cpus. Metrics printed without aggregation and with metric-only, in print_no_aggr_metric, iterate over user_cpus assuming every CPU has a metric to print. For each CPU the prefix is printed, but then if the evsel's cpus doesn't contain anything you get an empty line like the following on a SkylakeX: ``` $ perf stat -A -M DRAM_BW_Use -a --metric-only -I 1000 1.000453137 CPU0 0.00 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 CPU18 0.00 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 1.000453137 2.003717143 CPU0 0.00 ... ``` While it is possible to be lazier in printing the prefix and trailing newline, having user_cpus not be a subset of all_cpus is preferential so that wasted work isn't done elsewhere user_cpus is used. The change modifies user_cpus to be the intersection of user specified CPUs, or default all online CPUs, with the CPUs computed through the merge of all evsel cpu maps. New behavior: ``` $ perf stat -A -M DRAM_BW_Use -a --metric-only -I 1000 1.001086325 CPU0 0.00 1.001086325 CPU18 0.00 2.003671291 CPU0 0.00 2.003671291 CPU18 0.00 ... ``` Signed-off-by: Ian Rogers --- tools/perf/util/evlist.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index d335fb713f5e..91bbb66b7e9a 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -1036,6 +1036,8 @@ int evlist__create_maps(struct evlist *evlist, struct target *target) if (!cpus) goto out_delete_threads; + if (evlist->core.all_cpus) + cpus = perf_cpu_map__intersect(cpus, evlist->core.all_cpus); evlist->core.has_user_cpus = !!target->cpu_list && !target->hybrid; perf_evlist__set_maps(&evlist->core, cpus, threads); -- 2.35.1.1021.g381101b075-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel