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 24AC1D1812F for ; Mon, 14 Oct 2024 16:48: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: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Subject:Cc:To: From:Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=EmyN5VGeTi0X0G+pf7vHQXjLQIMthwYdtbdJFuOH9i8=; b=pgjUYhwigMRtberjoPHzoioHzu vgPSeNbqpBOXuXzvnmXAnwYTKNEZsfa79ylXmqDX9leaoVxWNingz6PJJXucuyg9laRUJJopwqQuy avRpBOA4uruLCtBU8pe0pGTw2LDxJeHlZFfyexpKmnD5ekyhJ11B7AWuqujNgR7v4yy+ah/71i1ma fky9FjeYHCCjT+gV0UGk+XL/i/jDcTtDGw507us47j6MTUQTtvn+uA+pkbHUhr0d9MiuekdE6egpS 2p3h0gV8vz+Wt/qpWem5ILGZ/mB80dsuewarLVd9Ks9aDfyJ2jXKPRyJaIAJAZcUKoyIkgfPhYfYU QUBu8MNQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t0OEt-00000005vcf-0GF8; Mon, 14 Oct 2024 16:48:11 +0000 Received: from nyc.source.kernel.org ([147.75.193.91]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t0ODU-00000005vTt-0F2L for linux-arm-kernel@lists.infradead.org; Mon, 14 Oct 2024 16:46:45 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id B39E5A42633; Mon, 14 Oct 2024 16:46:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F2E1C4CEC3; Mon, 14 Oct 2024 16:46:40 +0000 (UTC) Date: Mon, 14 Oct 2024 12:46:56 -0400 From: Steven Rostedt To: Ryan Roberts Cc: 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 , Will Deacon , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-trace-kernel@vger.kernel.org Subject: Re: [RFC PATCH v1 18/57] trace: Remove PAGE_SIZE compile-time constant assumption Message-ID: <20241014124656.3ffb0f65@gandalf.local.home> In-Reply-To: <20241014105912.3207374-18-ryan.roberts@arm.com> References: <20241014105514.3206191-1-ryan.roberts@arm.com> <20241014105912.3207374-1-ryan.roberts@arm.com> <20241014105912.3207374-18-ryan.roberts@arm.com> X-Mailer: Claws Mail 3.20.0git84 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241014_094644_269358_37EEC495 X-CRM114-Status: GOOD ( 24.16 ) 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 On Mon, 14 Oct 2024 11:58:25 +0100 Ryan Roberts wrote: > 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)); Absolutely not! BUG_ON() is in no way a substitution of any BUILD_BUG_ON(). BUILD_BUG_ON() is a non intrusive way to see if something isn't lined up correctly, and can fix it before you execute any code. BUG_ON() is the most intrusive way to say something is wrong and you crash the system. Not to mention, when function graph tracing is enabled, this gets triggered for *every* function call! So I do not want any runtime test done. Every nanosecond counts in this code path. If anything, this needs to be moved to initialization and checked once, if it fails, gives a WARN_ON() and disables function graph tracing. -- Steve > > /* 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];