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 F19C4C7EE31 for ; Wed, 24 May 2023 22:19:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237435AbjEXWTT (ORCPT ); Wed, 24 May 2023 18:19:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237042AbjEXWTC (ORCPT ); Wed, 24 May 2023 18:19:02 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E98CE4B for ; Wed, 24 May 2023 15:18:54 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-ba8338f20bdso1890837276.0 for ; Wed, 24 May 2023 15:18:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1684966733; x=1687558733; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=SukIuxaoO84Z2N5/tbMdB22CiO94rsJEEkavNjO0alo=; b=xXvaZIob15m9BhOyeJ9ui08mh6OJC4bT99hRIPeTVXfrpP9xnsmelHY2dmsb/wpag7 iAP7Mr9NjMYUHMX+QBUES3Zs0sZbYQd7aQtdyvx2FgPosw0ylDPSM1dpP4c9t4eVhKIU r4LC7cq0a/H1w4jinqvYIGdxX2oV6/A1eWQqLpQTNvfCXMjWfC5qMGjSj0tKOGcCqN6j 8Y10IA0Tz3UjGDnkT/QDm6jWgiRugZekRKdmFofLPZW4RLGxVF6C/w/x7a6YmYRgrYdm wLZAtQjICcSnF7CMAHqYiwYUb71Yk66ERw/eV92ByLIrwFu8mQzvIILwukoVPnjhhHrQ 5T8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684966733; x=1687558733; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=SukIuxaoO84Z2N5/tbMdB22CiO94rsJEEkavNjO0alo=; b=JbZ+893ctsRXkYnFl/HDIZFjz927O42DhXk1n5dLCuzmc6gbJG3VtMcOk6wmuRPIHV imrS6uQTRPwdtr6EdOtaZTmZm51g/XqiYFyJG3ayya9UwUxbZRIIJVF29jzZgIbRoDpt hkNTOkdfPwlg2Jw0mCXPylgRPQ3jSZh2AZ2NLxmv0aN2mLnQpy179u5Hgzy8OGiNObkr KIXwm2gl1iUcXkUnWnf8cYb3qb+XAkWaJ9NbLqrsBs6AIiwrrIWfn08izafNBVH6mae5 Xtbfc9vmfu6shiqULBM4Vo+rhHQuKpldMxEdzBnAkvCcPE1WC3S+tDAM1TBiaU7qlL1u YqWA== X-Gm-Message-State: AC+VfDwklPCC/i4wuJL22LCW+4cQVZjS4526TduT3d/VR+Hvncay/Z15 1jWnecJM6D8CMz6KxJzeGeF/7mLS0wBR X-Google-Smtp-Source: ACHHUZ6kUC+/b7eqs9c4jxHPTriyXHDKWHvZph0q2o9wc+IPQrpvP9irpFnHBysM//pLtj5KTw1TYrleX6Ji X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:7aa7:3d2d:76ae:8e96]) (user=irogers job=sendgmr) by 2002:a25:6b06:0:b0:ba8:97f8:620f with SMTP id g6-20020a256b06000000b00ba897f8620fmr756124ybc.8.1684966733649; Wed, 24 May 2023 15:18:53 -0700 (PDT) Date: Wed, 24 May 2023 15:18:04 -0700 In-Reply-To: <20230524221831.1741381-1-irogers@google.com> Message-Id: <20230524221831.1741381-9-irogers@google.com> Mime-Version: 1.0 References: <20230524221831.1741381-1-irogers@google.com> X-Mailer: git-send-email 2.40.1.698.g37aff9b760-goog Subject: [PATCH v3 08/35] perf pmu: Add CPU map for "cpu" PMUs From: Ian Rogers To: Suzuki K Poulose , Mike Leach , Leo Yan , John Garry , Will Deacon , James Clark , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Kajol Jain , Jing Zhang , Kan Liang , Zhengjun Xing , Ravi Bangoria , Madhavan Srinivasan , Athira Rajeev , Ming Wang , Huacai Chen , Sandipan Das , Dmitrii Dolgov <9erthalion6@gmail.com>, Sean Christopherson , Ali Saidi , Rob Herring , Thomas Richter , Kang Minchul , linux-kernel@vger.kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-perf-users@vger.kernel.org A typical "cpu" PMU has no "cpus" or "cpumask" file meaning the CPU map is set to NULL, which also encodes an empty CPU map. Update pmu_cpumask so that if the "cpu" PMU fails to load a CPU map, use a default of all online PMUs. Remove const from cpu_map__online for the sake of reference counting. Signed-off-by: Ian Rogers --- tools/perf/util/cpumap.c | 4 ++-- tools/perf/util/cpumap.h | 4 ++-- tools/perf/util/pmu.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c index 75d9c73e0184..75c5bed37805 100644 --- a/tools/perf/util/cpumap.c +++ b/tools/perf/util/cpumap.c @@ -663,9 +663,9 @@ size_t cpu_map__snprint_mask(struct perf_cpu_map *map, char *buf, size_t size) return ptr - buf; } -const struct perf_cpu_map *cpu_map__online(void) /* thread unsafe */ +struct perf_cpu_map *cpu_map__online(void) /* thread unsafe */ { - static const struct perf_cpu_map *online = NULL; + static struct perf_cpu_map *online; if (!online) online = perf_cpu_map__new(NULL); /* from /sys/devices/system/cpu/online */ diff --git a/tools/perf/util/cpumap.h b/tools/perf/util/cpumap.h index e3426541e0aa..05201b31810c 100644 --- a/tools/perf/util/cpumap.h +++ b/tools/perf/util/cpumap.h @@ -48,7 +48,7 @@ struct perf_cpu_map *cpu_map__new_data(const struct perf_record_cpu_map_data *da size_t cpu_map__snprint(struct perf_cpu_map *map, char *buf, size_t size); size_t cpu_map__snprint_mask(struct perf_cpu_map *map, char *buf, size_t size); size_t cpu_map__fprintf(struct perf_cpu_map *map, FILE *fp); -const struct perf_cpu_map *cpu_map__online(void); /* thread unsafe */ +struct perf_cpu_map *cpu_map__online(void); /* thread unsafe */ int cpu__setup_cpunode_map(void); @@ -59,7 +59,7 @@ struct perf_cpu cpu__max_present_cpu(void); /** * cpu_map__is_dummy - Events associated with a pid, rather than a CPU, use a single dummy map with an entry of -1. */ -static inline bool cpu_map__is_dummy(struct perf_cpu_map *cpus) +static inline bool cpu_map__is_dummy(const struct perf_cpu_map *cpus) { return perf_cpu_map__nr(cpus) == 1 && perf_cpu_map__cpu(cpus, 0).cpu == -1; } diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index e8c0762c311a..d992f5242d99 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -610,7 +610,7 @@ static struct perf_cpu_map *pmu_cpumask(int dirfd, const char *name) return cpus; } - return NULL; + return !strcmp(name, "cpu") ? perf_cpu_map__get(cpu_map__online()) : NULL; } static bool pmu_is_uncore(int dirfd, const char *name) -- 2.40.1.698.g37aff9b760-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 27343C77B7C for ; Wed, 24 May 2023 23:20:28 +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:To:From:Subject:References:Mime-Version :Message-Id:In-Reply-To:Date:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=GLsSQ+4MsTXqYWYxtyIHdCsZ4gL7kRIH13c8AAqTOCA=; b=40Ud93EFV3OJK5 kFmy/ulWAEJBtPTAZDosxAWf+vplh4nzMSesNkxMMgxyOuPUDVPDha/oHr7AL130p3A56q9xwwG+K XmDPawUggxG0XmWCI0+Nimsc+WN590FW0NoNgyhf51X80uZ5Y76nIZv6aX4m0ZPzYU/oWaChAY+/f 70/N+Dm1zY+d19gk0/MBqG2rKzDvBjenC9OuSSQ4mT/w7hz4H4/8bhqwRSYQ1GufHtmCys1OJtJs0 JMj9DVdTtSNZkT5ZmH2wNGqhkuN8J9qo8pJ/5x09X4hP6q9dWNVqeDxPO1TuS2VjMESA0c0okoGfr OuE0+W0o/Qp/CYNhVsuQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q1xmG-00Ev8c-2g; Wed, 24 May 2023 23:20:20 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q1woo-00EmiQ-2K for linux-arm-kernel@lists.infradead.org; Wed, 24 May 2023 22:18:55 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-babb78a3daaso1870733276.1 for ; Wed, 24 May 2023 15:18:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1684966733; x=1687558733; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=SukIuxaoO84Z2N5/tbMdB22CiO94rsJEEkavNjO0alo=; b=xXvaZIob15m9BhOyeJ9ui08mh6OJC4bT99hRIPeTVXfrpP9xnsmelHY2dmsb/wpag7 iAP7Mr9NjMYUHMX+QBUES3Zs0sZbYQd7aQtdyvx2FgPosw0ylDPSM1dpP4c9t4eVhKIU r4LC7cq0a/H1w4jinqvYIGdxX2oV6/A1eWQqLpQTNvfCXMjWfC5qMGjSj0tKOGcCqN6j 8Y10IA0Tz3UjGDnkT/QDm6jWgiRugZekRKdmFofLPZW4RLGxVF6C/w/x7a6YmYRgrYdm wLZAtQjICcSnF7CMAHqYiwYUb71Yk66ERw/eV92ByLIrwFu8mQzvIILwukoVPnjhhHrQ 5T8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684966733; x=1687558733; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=SukIuxaoO84Z2N5/tbMdB22CiO94rsJEEkavNjO0alo=; b=SrvCy5FoS2kTRrPzEaAblhidt+p6dPNYi7D9FluftZOLhpzXds3qMJUInKkVbrWuA9 AuQvSJr9ulEnVBZa8F5Rox+N0UipNMKXvbeTesj9Q03Oa4u3hi8H6IDOIaegscgnrKrd EYAdv3wG1oCDW17HqNTjGfTBCh9gCqc/rsynKCR9mw4kvLArGqs2URCeFazQrWDmvRlv nFzDJMQ0M+kCAkTTRKZeNmKdgcFvJ13tlphMPlN+OppMF6BxX3/R2aFla/3hDVGAKyQX lHOPh4/kckwqW+t9PPuf76ohMTWXeL2WuyYdoODfN5bOCstYa3RAEkaecauRFo1LftY0 +WSg== X-Gm-Message-State: AC+VfDwqPbVJ8jjpzwoLsB1zO52NGnfo+fCJ5W8x/yStHZPOglS8lYP1 Q7ES0141lhz3VmB8pZZz53XnPa08scij X-Google-Smtp-Source: ACHHUZ6kUC+/b7eqs9c4jxHPTriyXHDKWHvZph0q2o9wc+IPQrpvP9irpFnHBysM//pLtj5KTw1TYrleX6Ji X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:7aa7:3d2d:76ae:8e96]) (user=irogers job=sendgmr) by 2002:a25:6b06:0:b0:ba8:97f8:620f with SMTP id g6-20020a256b06000000b00ba897f8620fmr756124ybc.8.1684966733649; Wed, 24 May 2023 15:18:53 -0700 (PDT) Date: Wed, 24 May 2023 15:18:04 -0700 In-Reply-To: <20230524221831.1741381-1-irogers@google.com> Message-Id: <20230524221831.1741381-9-irogers@google.com> Mime-Version: 1.0 References: <20230524221831.1741381-1-irogers@google.com> X-Mailer: git-send-email 2.40.1.698.g37aff9b760-goog Subject: [PATCH v3 08/35] perf pmu: Add CPU map for "cpu" PMUs From: Ian Rogers To: Suzuki K Poulose , Mike Leach , Leo Yan , John Garry , Will Deacon , James Clark , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Kajol Jain , Jing Zhang , Kan Liang , Zhengjun Xing , Ravi Bangoria , Madhavan Srinivasan , Athira Rajeev , Ming Wang , Huacai Chen , Sandipan Das , Dmitrii Dolgov <9erthalion6@gmail.com>, Sean Christopherson , Ali Saidi , Rob Herring , Thomas Richter , Kang Minchul , linux-kernel@vger.kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230524_151854_761714_BE01F094 X-CRM114-Status: GOOD ( 17.35 ) 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 A typical "cpu" PMU has no "cpus" or "cpumask" file meaning the CPU map is set to NULL, which also encodes an empty CPU map. Update pmu_cpumask so that if the "cpu" PMU fails to load a CPU map, use a default of all online PMUs. Remove const from cpu_map__online for the sake of reference counting. Signed-off-by: Ian Rogers --- tools/perf/util/cpumap.c | 4 ++-- tools/perf/util/cpumap.h | 4 ++-- tools/perf/util/pmu.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c index 75d9c73e0184..75c5bed37805 100644 --- a/tools/perf/util/cpumap.c +++ b/tools/perf/util/cpumap.c @@ -663,9 +663,9 @@ size_t cpu_map__snprint_mask(struct perf_cpu_map *map, char *buf, size_t size) return ptr - buf; } -const struct perf_cpu_map *cpu_map__online(void) /* thread unsafe */ +struct perf_cpu_map *cpu_map__online(void) /* thread unsafe */ { - static const struct perf_cpu_map *online = NULL; + static struct perf_cpu_map *online; if (!online) online = perf_cpu_map__new(NULL); /* from /sys/devices/system/cpu/online */ diff --git a/tools/perf/util/cpumap.h b/tools/perf/util/cpumap.h index e3426541e0aa..05201b31810c 100644 --- a/tools/perf/util/cpumap.h +++ b/tools/perf/util/cpumap.h @@ -48,7 +48,7 @@ struct perf_cpu_map *cpu_map__new_data(const struct perf_record_cpu_map_data *da size_t cpu_map__snprint(struct perf_cpu_map *map, char *buf, size_t size); size_t cpu_map__snprint_mask(struct perf_cpu_map *map, char *buf, size_t size); size_t cpu_map__fprintf(struct perf_cpu_map *map, FILE *fp); -const struct perf_cpu_map *cpu_map__online(void); /* thread unsafe */ +struct perf_cpu_map *cpu_map__online(void); /* thread unsafe */ int cpu__setup_cpunode_map(void); @@ -59,7 +59,7 @@ struct perf_cpu cpu__max_present_cpu(void); /** * cpu_map__is_dummy - Events associated with a pid, rather than a CPU, use a single dummy map with an entry of -1. */ -static inline bool cpu_map__is_dummy(struct perf_cpu_map *cpus) +static inline bool cpu_map__is_dummy(const struct perf_cpu_map *cpus) { return perf_cpu_map__nr(cpus) == 1 && perf_cpu_map__cpu(cpus, 0).cpu == -1; } diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index e8c0762c311a..d992f5242d99 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -610,7 +610,7 @@ static struct perf_cpu_map *pmu_cpumask(int dirfd, const char *name) return cpus; } - return NULL; + return !strcmp(name, "cpu") ? perf_cpu_map__get(cpu_map__online()) : NULL; } static bool pmu_is_uncore(int dirfd, const char *name) -- 2.40.1.698.g37aff9b760-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel