From patchwork Mon Oct 14 10:58:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13834684 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B0CFD1A443 for ; Mon, 14 Oct 2024 11:00:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D465C6B009F; Mon, 14 Oct 2024 07:00:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CF77F6B00A0; Mon, 14 Oct 2024 07:00:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B98836B00A1; Mon, 14 Oct 2024 07:00:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 9B07F6B009F for ; Mon, 14 Oct 2024 07:00:19 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 67144120D4A for ; Mon, 14 Oct 2024 11:00:12 +0000 (UTC) X-FDA: 82671913632.15.76AB2D6 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf09.hostedemail.com (Postfix) with ESMTP id 00C7914000B for ; Mon, 14 Oct 2024 11:00:12 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=none; spf=pass (imf09.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1728903475; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9GjRzzDOoiNCAX5UvCNi+d9DYFyCOtMmFOQ33Q8ONIw=; b=Pa2xIIXFJYi4AHrjF40MPj9TovkRzVaOdpxssesvp1pmoddT5ZHwQeNtshWZfR1tQoR7zi nnX2UphPCOzKhVERMxFxjIKDk8UvmAW+yJQPUQnyi+fRMB2wygNstQyaJc3UdH3tTOyopD fHdteiPJSSWKD4fnH1W6Q3k3zt67iFE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728903475; a=rsa-sha256; cv=none; b=1Br+23bv70lgi+enUBiD3EIpA+FwYex/afiyzCAiYyRNyIVCbP/sOzaO1IJSbky2ngVR13 8/DEMsMPGnCA9pE+p/GjhjQirtzBa2NdJYD6Dz9hoV1vToiu4KqzxS40MSlMCa1Tzqmb9m H8Z+YkrvM3S1W2W8gIWr8zvCZR6SGn4= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=none; spf=pass (imf09.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 89DBA168F; Mon, 14 Oct 2024 04:00:46 -0700 (PDT) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.27]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6B5403F51B; Mon, 14 Oct 2024 04:00:14 -0700 (PDT) From: Ryan Roberts To: Andrew Morton , Anshuman Khandual , Ard Biesheuvel , Catalin Marinas , David Hildenbrand , Greg Marsden , Ivan Ivanov , Kalesh Singh , Marc Zyngier , Mark Rutland , Matthias Brugger , Miroslav Benes , Will Deacon Cc: Ryan Roberts , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-perf-users@vger.kernel.org Subject: [RFC PATCH v1 16/57] perf: Remove PAGE_SIZE compile-time constant assumption Date: Mon, 14 Oct 2024 11:58:23 +0100 Message-ID: <20241014105912.3207374-16-ryan.roberts@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241014105912.3207374-1-ryan.roberts@arm.com> References: <20241014105514.3206191-1-ryan.roberts@arm.com> <20241014105912.3207374-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Stat-Signature: 4ih8h5zod1zfg3doi6ogp516afb66ftg X-Rspamd-Queue-Id: 00C7914000B X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1728903612-625756 X-HE-Meta: U2FsdGVkX1+TQNX/5Vt3B2JvK93v2RUzEVoE3XOZaajR5gJybON6DFHpxlRInaagFcU7w5+blFDTTGfXklW9wyX9DbXnuiupZOVuCpgr43JSOI8FaD/S6DaMhCd1OkJ9EGmVAJPmbeEuvNZpdVV0f/Ic8styJ+Mai1kCpnkN1s9GQk6x3tCtnkxv9O4hwbgFyPL458+uQLCRMS1hZfw1VEPnYUbNdhyZwQBq3UxTMXuvnyYlbhi/Ys/wyHjw63oH5fsDJENwwoI8v3A5lZ4K6wixMumprK9lRy025zFI0PYAC5LwfmEDeIa8STEh/meq9T2FOYxaBUml7sL8tooMmkKTCAoDkY0Hw+cf+tEQe+uLZRZx34K8DLv8LvrRJlZI4JTu07wYaYyTv5ZA313IoNc50oFU63ou3FfjH1lup4hNaj1oWa9nCcX6jm6zgotZXD+UTIBBP8lm/XezntWQo1oPlHLT4UPshhZRpx5kNlidFN+Z/75G6GTXMFwY2r4WdZwjN77pl/3ub2eplT06oDdeo9GfC4oiYrLWzCR3YAOEZklfD75doAmxWG6rdScChRhZPlj+7QZpXPDFuk3pCxqt7XbTI1h8vzccSXBn85PADfHcUqvouY104nLbserZTJCZuIDSZd6qN79K2MEBB2OkY3/0xWnWBbBrn7fOg9+3jWdRuGMkDVL8G4S+d8WS3y99RibxxVIZSKG62dQdfhBqKayC7My9RiUaDjx564paHhGTO4vbc5aRt6ij7k02YZ2i/paBwn1ZRsm2xINNZG7GYjl8dEu10gcC04xNnNQBVHNjhF3cmy+BtlUo59KlRj/sKMjernlU32R345SB+J/wmdRetNNaSvfqXBhIUvMg7vuWjokYapZukFjAtMITp/cbjTuhK/s6jLkskEbdJsv0evFz2sJBkUzcU592EucoTw+2fIMEBb+mfazUixLf21QabDnDfbYaCvP7dIz 3mvSR18P hZ4fY2WwMehrQNonQsYUeGWhqaLFeNFmY1PZTVE+EpDlhxibvQRTBKUyUtFU9+KJS8v9NV3usl6FlPGunzr4nqAGdoiTj7mg2DpwzuE4BwbnEDGOe62Jg3XRvIjy2N8dPyXzZ2wuiuZcDct+OUqPBhbJSI3mMWf/MHJ0tfPoy568Hg4gbCTQTEree47d54hiFfcW2shMYjFMcoBCMT1TvbzzJTmS0u0kK1cfQ X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: To prepare for supporting boot-time page size selection, refactor code to remove assumptions about PAGE_SIZE being compile-time constant. Code intended to be equivalent when compile-time page size is active. Refactor a BUILD_BUG_ON() so that we test against the limit; _format is invariant to page size so testing it is no bigger than the minimum supported size is sufficient. Wrap global variables that are initialized with PAGE_SIZE derived values using DEFINE_GLOBAL_PAGE_SIZE_VAR() so their initialization can be deferred for boot-time page size builds. Signed-off-by: Ryan Roberts --- ***NOTE*** Any confused maintainers may want to read the cover note here for context: https://lore.kernel.org/all/20241014105514.3206191-1-ryan.roberts@arm.com/ include/linux/perf_event.h | 2 +- kernel/events/core.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index 1a8942277ddad..b7972155f93eb 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -1872,7 +1872,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 8a6c6bbcd658a..81149663ab7d8 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -419,7 +419,7 @@ static struct kmem_cache *perf_event_cache; int sysctl_perf_event_paranoid __read_mostly = 2; /* Minimum for 512 kiB + 1 user control page */ -int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */ +__DEFINE_GLOBAL_PAGE_SIZE_VAR(int, sysctl_perf_event_mlock, __read_mostly, 512 + (PAGE_SIZE / 1024)); /* 'free' kiB per user */ /* * max perf event sample rate