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: 13834843 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 91C6FD1624B for ; Mon, 14 Oct 2024 11:46:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=9GjRzzDOoiNCAX5UvCNi+d9DYFyCOtMmFOQ33Q8ONIw=; b=X2dKe2LTZBzs8bs9+cvrU6Pq+6 M9StMBUORvPoU8DPA1NLNzz53IDUyYtt6xS2E1J9DrCEW2UEC5A7MS/NWpAGreFi2rFv6M10nrYlw hnVGf8xFGPZetDIZynyxTUxLtRSsW9fVW7uK4wpVUsIUIzNYZ9Flw5SSnJR61QflguCMXs765NJFn +U3mA2ri64KdcK8/msIPTHVWVJHDet7CzFi82k/c6uqOZqeTfmHDRNiL3vxAgefwEbeUwyguDDenz PrIXlC1SI4qMWtRNJqPDfWIgk5pVbneCCgEUNK11aGu1dsuVRMtPFi8QyWiZjWY3j/oJQcRAJCnQK 4T2qwSdw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t0JWd-00000004yeN-1A5O; Mon, 14 Oct 2024 11:46:11 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t0IoD-00000004nku-1D3M for linux-arm-kernel@lists.infradead.org; Mon, 14 Oct 2024 11:00:18 +0000 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241014_040017_406726_2609C2BB X-CRM114-Status: GOOD ( 12.40 ) 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 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