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 62B68C77B73 for ; Fri, 26 May 2023 21:55:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244152AbjEZVzE (ORCPT ); Fri, 26 May 2023 17:55:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244141AbjEZVyp (ORCPT ); Fri, 26 May 2023 17:54:45 -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 93B261BB for ; Fri, 26 May 2023 14:54:33 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-bacfa4ef059so2814363276.2 for ; Fri, 26 May 2023 14:54:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1685138072; x=1687730072; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=Augb3j/jljgyjV1KGpr82Z0gyjkQotdR/6uQepIkE7U=; b=2kB3hJaQUgcEcaVDXNq/fd3gWdE2bSBqcIL0t1IGnwV28LbcccROJklvngJeFV4DSq DufbTJ6/obrK8AhJrpMqL+XNuQmA06Avd4EHY87ZAOSlNYz3P8jqh8ujdXyqvxWOD6oT HVHoOwHoHvlyWmr/ArSlJeVgBFTbnUVTL6MW00xvMB349pRYplMeGvpg1Nm965u1sBid efvKaDXKZrijDyU9jIyvnlcEoeV5Dj2yo8ZtLt9ewIiMR6ZD+5WmT7YMIkSAyBr6QIbX dl4kDKcouAq6ZfyDZjGoSUDivoA53h8d8tr2otGAoSiVcHTTDFqyvRrvZdX0w1EdZ74T O48g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685138072; x=1687730072; 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=Augb3j/jljgyjV1KGpr82Z0gyjkQotdR/6uQepIkE7U=; b=E4R3gAus+ZXoUBjNdQOyudQAvvu2DMu4eLfdLtY5SBi8zvixREvm9moqw/tgCseJmL NZEPwG4SRNuQEKSJboBjzGSYN0Zhzl1T/Vu6wFyzeNncqTEbzd1pj9rXqWUljPG3694J muemDCTe7JNYcOBL9bXLKHTHC3urSIcookQX91BXqak95yIzs4PJBV2hnYkDurjvkQPX awkKtu/mfszmD7ruxJfiMMD+GV4dMeC19CSg0f7C3ZstkBMUTD7MvmsBKKg3zdD0aW/5 NuPkl20GHFChE4PNeyNVU1D0F1VmxIb5QeXNfdcPWUkwwPsVe92QjIFekodbijWGhKTa Z3vg== X-Gm-Message-State: AC+VfDy1ZvgqBlDSjJ8Jx6Lg316uNVukSM7lwV42yp3DH3FNaL5EXnz/ e6/SSIGYE9IUsAQ7xzlsLQYQmjep3e7c X-Google-Smtp-Source: ACHHUZ5Nc508/25y5ajVWer0jZNeXKoT9lajVUzrqi2/BXoSY3vyyg0yHWgTWVWgkvFow+yWC1Tg5DfwgH5c X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:3b4e:312c:644:a642]) (user=irogers job=sendgmr) by 2002:a25:d690:0:b0:bad:4bb:c440 with SMTP id n138-20020a25d690000000b00bad04bbc440mr1706799ybg.10.1685138072366; Fri, 26 May 2023 14:54:32 -0700 (PDT) Date: Fri, 26 May 2023 14:53:43 -0700 In-Reply-To: <20230526215410.2435674-1-irogers@google.com> Message-Id: <20230526215410.2435674-9-irogers@google.com> Mime-Version: 1.0 References: <20230526215410.2435674-1-irogers@google.com> X-Mailer: git-send-email 2.41.0.rc0.172.g3f132b7071-goog Subject: [PATCH v4 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-kernel@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 Reviewed-by: Kan Liang --- 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.41.0.rc0.172.g3f132b7071-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 B85C3C77B73 for ; Fri, 26 May 2023 22:41:24 +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=eP7n1Xueaf40s06sVBYQOe5DqIBnMW8ux06CQluWCeQ=; b=gPf9kNBEE1F/Mj qsODsS7TNMI/WEjwgYSWZfkWPPbBjygkd7eRcgLG567hK+bdoFi44lUUiv2UE6OHWCEInv3W5PHLa 8pmR/9E7J6mu9FQB8+uVSBpqm6LOJ+zRGmYkAsyF2zv4nPoYknQcIRiGxHpJda7yXlWF0CjvAg8rU RXCBrVdux4X1ICl0A9VX/BjNjGXOasHyBqFAnAwHklb9rHrLhJqY0t+UMHZUiXr+0Zc/WXTMmRyPJ DGOFW7UzODo5bafhGNtjCzOkoNpR2MabeEHVN+m0GopI/STAmUiDaycuIvOgRZS95tlD4RO0k8Ay5 z1r8eLag16/6/XOJc9uA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q2g7A-004A5Y-0A; Fri, 26 May 2023 22:40:52 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q2g6n-0049uL-0D for linux-arm-kernel@bombadil.infradead.org; Fri, 26 May 2023 22:40:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:To:From:Subject: References:Mime-Version:Message-Id:In-Reply-To:Date:Sender:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description; bh=Augb3j/jljgyjV1KGpr82Z0gyjkQotdR/6uQepIkE7U=; b=injcUm0IWKQL5Xc6zT8CH3njN+ fJCHHVvKPt7Vu4xn0UQfjxpmCjMPUE4acbwKKzaczv6NYRGjXIdGBDJFhpz3OA0LV8T0UmYC1vPSe /7lCuBeL1qOwPK6EPLDPWIrPXwnadQPmDKmHGLoEDEmsu0DKPg4c7jVVVYsgSPMC0FdYIHTGZicIG 8oeuGVRLLN0FkH1ruQkc41QHn+VmTB6ZkuDTuHCvN3eGYC+WgI8KSO3xvytWGc38vatP0LVvzxhPi ajyZQioHptkTjFAoIWvap6Hi2d4K6iGADD7MPN//AUlB1k09E40Eww2mOUjw1feasJNWqh7Py1k+Q UQRnFNGw==; Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q2fON-007ipM-10 for linux-arm-kernel@lists.infradead.org; Fri, 26 May 2023 21:54:37 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-ba88ec544ddso2824403276.1 for ; Fri, 26 May 2023 14:54:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1685138072; x=1687730072; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=Augb3j/jljgyjV1KGpr82Z0gyjkQotdR/6uQepIkE7U=; b=2kB3hJaQUgcEcaVDXNq/fd3gWdE2bSBqcIL0t1IGnwV28LbcccROJklvngJeFV4DSq DufbTJ6/obrK8AhJrpMqL+XNuQmA06Avd4EHY87ZAOSlNYz3P8jqh8ujdXyqvxWOD6oT HVHoOwHoHvlyWmr/ArSlJeVgBFTbnUVTL6MW00xvMB349pRYplMeGvpg1Nm965u1sBid efvKaDXKZrijDyU9jIyvnlcEoeV5Dj2yo8ZtLt9ewIiMR6ZD+5WmT7YMIkSAyBr6QIbX dl4kDKcouAq6ZfyDZjGoSUDivoA53h8d8tr2otGAoSiVcHTTDFqyvRrvZdX0w1EdZ74T O48g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685138072; x=1687730072; 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=Augb3j/jljgyjV1KGpr82Z0gyjkQotdR/6uQepIkE7U=; b=hYzfem6TqGRJtg7nio8HfdPCBJhhEdO+o8uOMCx8vlecms4KuQynjEMkcYkaI/hv2f 5oBpmvDlTPg2ZqeBw9uuHcn9JifHNUHJvD6AdgBQbPKRNCBGgkEEGOMj9j1YIYoC2kBe lrjoBYjSKmVKrC6yZG7P0TWwrXwBQpIoQSCDo/f0ZEpMo0ZXtzmyMjSUzYtvcTEJEGMd Yj/4ZKR4ywTLs/rAOtv3J4CTxA4urYc0tKuPw0TfeGNwC5g+G/QgqVqLMzlJfu3iYB/f B4qWbP19UO8M9Ag6iHHnWj6gInSkPzhGdxVZZVt468vxOKbIoVkm1VjBwHhloZngAfqs lztA== X-Gm-Message-State: AC+VfDys15VkvwBd3qvaZBjqWsvEUy+IRuz42OWmhsbIUQrmGcrRf8Cw wD1dnFgvvFl/7SLKElIII0TF8Ceq47kU X-Google-Smtp-Source: ACHHUZ5Nc508/25y5ajVWer0jZNeXKoT9lajVUzrqi2/BXoSY3vyyg0yHWgTWVWgkvFow+yWC1Tg5DfwgH5c X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:3b4e:312c:644:a642]) (user=irogers job=sendgmr) by 2002:a25:d690:0:b0:bad:4bb:c440 with SMTP id n138-20020a25d690000000b00bad04bbc440mr1706799ybg.10.1685138072366; Fri, 26 May 2023 14:54:32 -0700 (PDT) Date: Fri, 26 May 2023 14:53:43 -0700 In-Reply-To: <20230526215410.2435674-1-irogers@google.com> Message-Id: <20230526215410.2435674-9-irogers@google.com> Mime-Version: 1.0 References: <20230526215410.2435674-1-irogers@google.com> X-Mailer: git-send-email 2.41.0.rc0.172.g3f132b7071-goog Subject: [PATCH v4 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-20230526_225435_460011_98EF2CEE X-CRM114-Status: GOOD ( 16.91 ) 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 Reviewed-by: Kan Liang --- 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.41.0.rc0.172.g3f132b7071-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel