From patchwork Fri Apr 8 03:56:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 12806034 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 1F86BC433EF for ; Fri, 8 Apr 2022 03:58:19 +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:Mime-Version: Message-Id:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=QJAKKGwijbu3ka2wQt4CT5SbcrMAycPJJ8A9u3FS9+g=; b=IO0 wHehnh9ZrfG0Zwd+ee93ClSa5YAZOra5tmKqu4O1c3kKwCEKdZ7AU/AEA7nLVXwkI0Aou872Ft0KM Y2KSMafVjnpz3BQpL0G7yhhfqVCSIXM308SnZqinBSFxs3yCrUuKAa4LjB9iqQcxEGzt+jwnJ9bcg 7Gj4EjkxXE1+6R00kvoW4i8KQImzmQPfrmtOT294gHaWEu6rV32uRv30nQNrGHKgncZuMDpfLCrym 9xihL5CKLnWxtzeuoqws6GxPN4hZl4vX39bj14XNq3tl7X5YHJSSS2a9JGKwbBFlF1PAHY4bdnk4A rTUFfSQDpMkAzS47QJJevZFRVe9OQOg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ncfjZ-00EpP4-53; Fri, 08 Apr 2022 03:56:29 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ncfjV-00EpN0-4m for linux-arm-kernel@lists.infradead.org; Fri, 08 Apr 2022 03:56:26 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-2eb2bc9018aso65599717b3.18 for ; Thu, 07 Apr 2022 20:56:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=HxFczrqsspWyPdqTCif/D0IhzdUHRDLBzRRwTlKUif4=; b=OpAiXGIhVTB/vTq+PHCL6R254gERCairQa9Ci41IeF1qLemf8XiEknJyK9Qj6Xs1GW K7WpgXr2EA17KLl/s4ujXAp5fKXj6Xw078lOQwj1Q/BY5uq1kQT3b5ejYkJ5qqHiW0yK aDjMN+hXma8v/A4lyggTad1UeC6FgVVVHzWbdfdzsvOb6vgvpXjsWygNGHBdBmop+AaA o6CBjt20f1W7sJ77QjxsdVH8SloKdX922qn7sb64nBoukV1FFCcXuLm3tuKG+CljIAAM mrt8cwt9D7X4gb1te5BnaS2qFjU3ZU6zqtUtJ3ij0eCLxZzpHO3OZoc+19JMxnnvTBOG EHcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=HxFczrqsspWyPdqTCif/D0IhzdUHRDLBzRRwTlKUif4=; b=nqL5HI4bACuLO8n5L5DEomI+2lfjJ4kvK+GH60Z7ueeuaeRuMm4HYQmoHUe9OXLnVD 0QnZJtMHux9d636juLJE8kF6sQZXrmQV0SKEFxdHYTzVfazaphPcFDpWNq7OcIIfHS0y zXdfUeVYtfkX07NaHtpnUYmSFbsekk6D9vPfF415GIQKDPHDdEr3HKRlZ4SYuGPUeTQ3 bQFFRJPc1/7DLM6gVx1yfLP1/kAZWkL44JfNjrqpON0itFgq9qHVHNVFLrUAgvADkOaa NCo39FHtBL9u4Cp4mcoyD+Rz8Q6fGJ4WZvfJob9GVMRKwPnjJDQthFZYswo7twPrNiYz 8HwQ== X-Gm-Message-State: AOAM533O9fbshimiM4vA2LVP63eUBNDao448yf9qWFnCPTg+zxUTlqEV wjGEbaD4qcA66wq9x5ebz9nBW7F03E4x X-Google-Smtp-Source: ABdhPJxGss2gEVXU1qEfZ8LDHdcCgN0sHB3FaIVikPe2VRhZW0mD6pgY0SGsZRVMI8prYHhp9fSSBvfka1ac X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:560:aa27:649e:a07d]) (user=irogers job=sendgmr) by 2002:a25:dad1:0:b0:634:63aa:6ec2 with SMTP id n200-20020a25dad1000000b0063463aa6ec2mr12250168ybf.159.1649390181920; Thu, 07 Apr 2022 20:56:21 -0700 (PDT) Date: Thu, 7 Apr 2022 20:56:11 -0700 Message-Id: <20220408035616.1356953-1-irogers@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.35.1.1178.g4f1659d476-goog Subject: [PATCH v3 0/5] Make evlist CPUs more accurate 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-20220407_205625_226146_68C27FE9 X-CRM114-Status: GOOD ( 14.79 ) 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 evlist has all_cpus, computed to be the merge of all evsel CPU maps, and cpus. cpus may contain more CPUs than all_cpus, as by default cpus holds all online CPUs whilst all_cpus holds the merge/union from evsels. For an uncore event there may just be 1 CPU per socket, which will be a far smaller CPU map than all online CPUs. The v1 patches changed cpus to be called user_requested_cpus, to reflect their potential user specified nature. The user_requested_cpus are set to be the current value intersected with all_cpus, so that user_requested_cpus is always a subset of all_cpus. This fixes printing code for metrics so that unnecessary blank lines aren't printed. To make the intersect function perform well, a perf_cpu_map__is_subset function is added. While adding this function, the v2 patches also used it in perf_cpu_map__merge to avoid creating a new CPU map for some currently missed patterns. The reference counts for these functions is simplified as discussed here: https://lore.kernel.org/lkml/YkdOpJDnknrOPq2t@kernel.org/ but this means users of perf_cpu_map__merge must now do a put on the 1st argument. v2. Reorders the "Avoid segv" patch and makes other adjustments suggested by Arnaldo Carvalho de Melo . v3. Modify reference count behaviour for merge and intersect. Add intersect tests and tidy thee cpu map tests suite. Ian Rogers (5): perf cpumap: Don't decrement refcnt on args to merge perf tests: Additional cpumap merge tests perf cpumap: Add intersect function. perf evlist: Respect all_cpus when setting user_requested_cpus perf test: Combine cpu map tests into 1 suite tools/lib/perf/cpumap.c | 46 ++++++++++++++--- tools/lib/perf/evlist.c | 6 ++- tools/lib/perf/include/perf/cpumap.h | 2 + tools/perf/tests/builtin-test.c | 4 +- tools/perf/tests/cpumap.c | 74 +++++++++++++++++++++++++--- tools/perf/tests/tests.h | 4 +- tools/perf/util/evlist.c | 7 +++ 7 files changed, 120 insertions(+), 23 deletions(-)