From patchwork Mon Oct 14 10:58:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13834686 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 3FF84D1A443 for ; Mon, 14 Oct 2024 11:00:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C0E556B00A2; Mon, 14 Oct 2024 07:00:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BBF9A6B00A5; Mon, 14 Oct 2024 07:00:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A3A0C6B00A4; Mon, 14 Oct 2024 07:00:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 816B06B00A2 for ; Mon, 14 Oct 2024 07:00:25 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 80BF5140D34 for ; Mon, 14 Oct 2024 11:00:17 +0000 (UTC) X-FDA: 82671913842.21.07A8488 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf03.hostedemail.com (Postfix) with ESMTP id 5AD9E20026 for ; Mon, 14 Oct 2024 11:00:20 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf03.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728903508; a=rsa-sha256; cv=none; b=yN+c7LoNLkNlmuKoFgIaBYfNv6fb4bUng6k94MaZcrecg1QnXBCmu7/kC7IK8/STrBhSKY IFJgc7Nrczn6UbdtbNIid8MdrKAB9IFZZ1b9zcQLAbu6bpz46u0E9osZCwisPwp/nzlQVs eHdSV3W9boi6tEhM337lEuhqjBc5OE0= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf03.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1728903508; 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=WYYsCtIDe3FfCiqGTFtQtqmkCpDu+2cX7LKMS9zkbAc=; b=7m/MH96p7YIK8JDRRSdycRGzSO3Wf9mC+piS7dQ1nj575tyoRwTvgGpODIDuy1DX0iC8hD xqeVXkX/3pZBxDeh1MAVHqJdnOXKMWdkA40ZA1UbGElCH7mp1/2686aNJp2Ua9mnBWENUh HyQBIzmEcnd+AKG+0ZL+rxNSHloU87k= 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 65FA91688; Mon, 14 Oct 2024 04:00:52 -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 09E9C3F51B; Mon, 14 Oct 2024 04:00:19 -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 , Masami Hiramatsu , Matthias Brugger , Miroslav Benes , Steven Rostedt , Will Deacon Cc: Ryan Roberts , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-trace-kernel@vger.kernel.org Subject: [RFC PATCH v1 18/57] trace: Remove PAGE_SIZE compile-time constant assumption Date: Mon, 14 Oct 2024 11:58:25 +0100 Message-ID: <20241014105912.3207374-18-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-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 5AD9E20026 X-Stat-Signature: uduixfx7w14rcxbffnafrn793cg1bt9e X-Rspam-User: X-HE-Tag: 1728903620-378315 X-HE-Meta: U2FsdGVkX1+sy18YSrwCaZ1f87tW4HzqZB06c8j15JhEk+o0giZ3azeYmWBVRew9p545v1ijmx60pk/eS3969Y7Uh4lUx0nSRaItaWAoIWPylTmANq0/Jh6+4ZNYR7+Hg7FY8njk1/y6Xwsd0p1aZrJjvy0bVKVOk9PaVMYwKwfbYe1nrxvjZzOszUefQzrbtHWxPEfIw9s3nLXXCbETB8G9ti+xGgJmA/3p+sHVoGamLKwkyx/0drAtW0MdeSvUEPVDpcPMaAt+JjoEc0EA6YhOyZ75kX39rUmfNiK9Zn2zQ1G7bsLlZ47gztbYIDYOWtJjG+XkDjz5+j54yoWO7CQUiuAZprtgv0Gufup4MFT31mbQAFYOnm44lKdtZqk/7lGpfoNLcQdMpREnSL8pPO9ffB93gyQMhrW2hP8M4gpqttuwSXRgmzwlHl1nn3siDHuol3rInlc0MxuyLegdU9uVgs5xhgDxEv2s97YSXw4bbkTlr+oXnnhfJkwmRK9kjsXjriKSRSHiQVyEPOhcyMYE/ZOoYN6GYhNLgpUUWAhrTFGz97WKJfKYFO7f9yQDku2DMFu8kvnN9WN0mfVQPBRkLk8ZTVwOS6uzixdLhay0p7jx8KgTjSDy7KSf2tlUgqGbidBiXVbubgGN0k39w6kWXEF6RJGD605IR+DIMfDLvfCcYpXA2UFVD5wVwoVRzfivfM4KGkILMYnUPhHZiuuQezmS9QMsv2H8hOZ7VepF5BEKvxgj78957tU+A2uayZlsrIgba+89Vi3AhTFOWax6hH2baqMy17eYVrBjqZngKef3Q3H3GOK6FWmpW+n+9KNYtGtgElIzomiZim5VeSjYgowZwQJeZ2PzA2LMxb7wBN81SQdHR1a1FbT/l8dbwmE7ep5LsyMdSeczOh7HqdsfpBp3MiF3eIxkuOZswF7/t1hcL3Ms/jtPl/FX75gA2IYpmwAHXWWvszeaqQ0 k7V78uFC Rp4pfug+k/Pb4HIHdacsXV7QIZXNw43Zr//WNrIgA3Ow7XJ2fdq9wCW62kwHqyrtcz4lAamhHqK+oYkNnm9TpcDCgOWh2ObkEb9lEXNOeQFB6dGIurszxaQoE4Z8pCXbUuGx49eZl+EZWz85whUc+oHF0Q6Tnn3DnA51ZTxw+6uCUmvs1TPehmu+ctXqcQSAqqpLT4g0g1AqRQLeQ+hM/aZW9tgwcOgKyRNHo 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. Convert BUILD_BUG_ON() BUG_ON() since the argument depends on PAGE_SIZE and its not trivial to test against a page size limit. Redefine FTRACE_KSTACK_ENTRIES so that "struct ftrace_stacks" is always sized at 32K for 64-bit and 16K for 32-bit. It was previously defined in terms of PAGE_SIZE (and worked out at the quoted sizes for a 4K page size). But for 64K pages, the size expanded to 512K. Given the ftrace stacks should be invariant to page size, this seemed like a waste. As a side effect, it removes the PAGE_SIZE compile-time constant assumption from this code. 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/ kernel/trace/fgraph.c | 2 +- kernel/trace/trace.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c index d7d4fb403f6f0..47aa5c8d8090e 100644 --- a/kernel/trace/fgraph.c +++ b/kernel/trace/fgraph.c @@ -534,7 +534,7 @@ ftrace_push_return_trace(unsigned long ret, unsigned long func, if (!current->ret_stack) return -EBUSY; - BUILD_BUG_ON(SHADOW_STACK_SIZE % sizeof(long)); + BUG_ON(SHADOW_STACK_SIZE % sizeof(long)); /* Set val to "reserved" with the delta to the new fgraph frame */ val = (FGRAPH_TYPE_RESERVED << FGRAPH_TYPE_SHIFT) | FGRAPH_FRAME_OFFSET; diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index c3b2c7dfadef1..0f2ec3d30579f 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -2887,7 +2887,7 @@ trace_function(struct trace_array *tr, unsigned long ip, unsigned long /* Allow 4 levels of nesting: normal, softirq, irq, NMI */ #define FTRACE_KSTACK_NESTING 4 -#define FTRACE_KSTACK_ENTRIES (PAGE_SIZE / FTRACE_KSTACK_NESTING) +#define FTRACE_KSTACK_ENTRIES (SZ_4K / FTRACE_KSTACK_NESTING) struct ftrace_stack { unsigned long calls[FTRACE_KSTACK_ENTRIES];