From: Eric Curtin <ericcurtin17@gmail.com>
To: linux-arm-kernel@lists.infradead.org
Cc: Ryan Roberts <ryan.roberts@arm.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
James Clark <james.clark@linaro.org>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [RFC PATCH v2 11/43] perf/core: Handle a boot-time PAGE_SIZE in format attrs and mlock
Date: Tue, 1 Dec 2026 01:51:43 +0000 [thread overview]
Message-ID: <20261201015240.1017259-12-ericcurtin17@gmail.com> (raw)
In-Reply-To: <20261201015240.1017259-1-ericcurtin17@gmail.com>
From: Ryan Roberts <ryan.roberts@arm.com>
With boot-time page size selection PAGE_SIZE is not a compile-time
constant.
In the PMU_FORMAT_ATTR() show function, compare sizeof(_format) against
PAGE_SIZE_MIN in BUILD_BUG_ON(). The format string does not depend on
the page size, so checking it fits the smallest page is sufficient.
Define sysctl_perf_event_mlock, whose default is derived from PAGE_SIZE,
with DEFINE_GLOBAL_PAGE_SIZE_VAR_ATTR() so that it is initialised at
boot for boot-time page size builds.
No functional change for compile-time page sizes.
Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
Signed-off-by: Eric Curtin <eric.curtin@docker.com>
(cherry picked from commit 6e83c7d00396aa8d86ae2a50b6f7ce156c01d7cc)
---
include/linux/perf_event.h | 2 +-
kernel/events/core.c | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index b52348eca6ef..e09498c9379e 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -2098,7 +2098,7 @@ _name##_show(struct device *dev, \
struct device_attribute *attr, \
char *page) \
{ \
- BUILD_BUG_ON(sizeof(_format) >= PAGE_SIZE); \
+ BUILD_BUG_ON(sizeof(_format) >= PAGE_SIZE_MIN); \
return sprintf(page, _format "\n"); \
} \
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 4ab3919ac78e..41c372980e0c 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -496,7 +496,8 @@ static __always_inline bool is_guest_mediated_pmu_loaded(void)
int sysctl_perf_event_paranoid __read_mostly = 2;
/* Minimum for 512 kiB + 1 user control page. 'free' kiB per user. */
-static int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024);
+static DEFINE_GLOBAL_PAGE_SIZE_VAR_ATTR(int, sysctl_perf_event_mlock, __read_mostly,
+ 512 + (PAGE_SIZE / 1024));
/*
* max perf event sample rate
next prev parent reply other threads:[~2026-12-01 1:53 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 1:51 [RFC PATCH v2 00/43] Boot-time page size selection for arm64 (core) Eric Curtin
2026-12-01 1:51 ` [RFC PATCH v2 01/43] mm: Add macros ahead of supporting boot-time page size selection Eric Curtin
2026-12-01 1:51 ` [RFC PATCH v2 02/43] vmlinux.lds: Align page-aligned sections to PAGE_SIZE_MAX Eric Curtin
2026-12-01 1:51 ` [RFC PATCH v2 05/43] mm: Avoid split pmd ptl if pmd level is run-time folded Eric Curtin
2026-12-01 1:51 ` [RFC PATCH v2 06/43] mm/vmstat: Use THREAD_SIZE_MAX for the KSTACK_* counters Eric Curtin
2026-12-01 1:51 ` [RFC PATCH v2 07/43] fork: Permit boot-time THREAD_SIZE determination Eric Curtin
2026-12-01 1:51 ` Eric Curtin [this message]
2026-12-01 1:51 ` [RFC PATCH v2 16/43] arm64: Introduce macros required for boot-time page size selection Eric Curtin
2026-12-01 1:51 ` [RFC PATCH v2 21/43] arm64: Test PAGE_SIZE instead of CONFIG_ARM64_*K_PAGES Eric Curtin
2026-12-01 1:52 ` [RFC PATCH v2 37/43] vdso: Lay out the data pages in VDSO_PAGE_SIZE units Eric Curtin
2026-12-01 1:52 ` [RFC PATCH v2 39/43] crash: Size the vmcoreinfo page array for the smallest page size Eric Curtin
2026-12-01 1:52 ` [RFC PATCH v2 41/43] exit: Use THREAD_SIZE_MAX for lowest_to_date Eric Curtin
2026-12-01 1:52 ` [RFC PATCH v2 42/43] tracing: Use PAGE_SIZE_MIN/MAX in the uprobe check and undefsyms page Eric Curtin
2026-12-01 1:52 ` [RFC PATCH v2 43/43] arm64: Enable boot-time page size selection Eric Curtin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261201015240.1017259-12-ericcurtin17@gmail.com \
--to=ericcurtin17@gmail.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=ryan.roberts@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®