From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795962939; b=qSy0XC+NkA4pHEf4CfLcG2eJAjekgwI24jn6/B/gWVTGp3HJy1c2wxKbN34oMkdAW5/V hPMd9XSydVFqGcUZey2Whgl1okSyRjbrLkSZlrjAHo+XDC6Kmq2NkL+8bqhHvdSPrMTNa S7PTm85LKYTaXo96l+CPXcLxZ0Zm2THm1qA1UYPWg+5AgYMG/N+A5z7GvTAd8EJTOjFeX Xjfr3sTfvLAC41RNRKbBbGRVeJguTZgwA+PkzgN/Z+ErCg9wVZ47Xx20b0NKI0CUqcZi3 u1D3088ohI3sSoPrmAx3nPfkBpzj1NWm0hfdYqyto4lbL1TT7PuKHCDUsxDUkOsJ3og== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795962939; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: MIME-Version:Content-Transfer-Encoding; bh=nRRE54ZWiiDBcdVuwp9Af+I4syeZ2EfAkDyaXBdkaU4=; b=At6qmH5zqoh2EPSSUWSJTUBJEXR+IyPjZyN3JMABN7sNrzLBhibNtzfhLD2mC+WMAPXp smJga6ToWgRp51SsePLObQmZbBjeSO31RyzbIGbzeCsR63RfF9u3p6Xy0ZEUyHCw1BuDJ 7pt0vLRUV8ynwO72ahCd13OtnPGA7ur4z64y3u8fPUPWfWO4Zk/JqWm6HVbrQQtybaz/F /YYJlXMKvwQnreWKiLavYfD26vwxDUtya8LDX+Vk9ff4rNmzQlv1I0XqhCUBKJC0RKcAL jwWCktksVeXk286f6DKxWG0wKYSazaoLV2TqO3fHRX037MHC7/If3plD5bEOxiB+jRw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="ZT5ggG8/"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0A200606A31C; Sun, 29 Nov 2026 14:35:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ZT5ggG8/ Received: by smtp.kernel.org (Postfix) with ESMTPSA id CBD841F00896; Sun, 29 Nov 2026 14:35:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795962938; bh=nRRE54ZWiiDBcdVuwp9Af+I4syeZ2EfAkDyaXBdkaU4=; h=From:To:Cc:Subject:Date; b=ZT5ggG8/TtyuxY9Smkq/976laE4B3Hfcc13Js/Yf4H03p82m+PBvU1DTOfN3jMx8O AD6QhltU+gOIHV8A2/j+BS9rHD9t8Muuc+t5om8EVn6PedbnCulsRfFy66przF/25U ty2dKiRyRVlig4zNyNvUD79VTSeg65HlmSgYz/Q3qWpSXev9c5hzO+C+Boc9Bjudy4 KfI1qA8nWwjljh5OVMtfdejRzEKGqSAmMK4UjDuTzgosZ8SvLzNwEBkeicCeG1zfmy woQBrPCjdIZqY0uXgOwEzd8Cw10q9IT9bpIO/sciYk0g/OkWzk7Py16Z+ojAKzX9R7 isOANial9T6mw== From: Miguel Ojeda To: Benno Lossin , Gary Guo , Miguel Ojeda Cc: rust-for-linux@vger.kernel.org, Boqun Feng , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Daniel Almeida , Tamir Duberstein , Alexandre Courbot , =?UTF-8?q?Onur=20=C3=96zkan?= , stable@vger.kernel.org Subject: [PATCH v2] rust: init: clean Rust 1.102.0's `clippy::large_unopt_stack_frames` lint Date: Sun, 29 Nov 2026 15:35:28 +0100 Message-ID: <20261129143528.142974-1-ojeda@kernel.org> X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Starting with Rust 1.102.0 (expected 2027-02-04), Clippy renames the `large_stack_frames` lint to `large_unopt_stack_frames` and moves it to `suspicious` from `nursery` [1], and thus we start to see it in the examples of `try_init!` and `try_pin_init!`: warning: closure generated by this macro may allocate a lot of stack space --> rust/doctests_kernel_generated.rs:6716:9 | 6716 | / try_init!(Self { 6717 | | big: KBox::init(init_zeroed(), GFP_KERNEL)?, 6718 | | small: [0; 1024 * 1024], 6719 | | }? Error) | |_________________^ | = help: for further information visit https://clippy.rust-lang.org/main/index.html#large_unopt_stack_frames = note: `-W clippy::large-unopt-stack-frames` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::large_unopt_stack_frames)]` The 1 MiB array is initialized by value, thus the closure that is generated would need to hold it in its stack frame (without optimizations, which is what the lint goes by). Thus make it actually small (128 bytes), as the name of the field says, which allows to keep initializing it by value. Cc: stable@vger.kernel.org # 6.12.x (Rust is pinned in older LTSs) Link: https://github.com/rust-lang/rust-clippy/pull/17749 [1] Signed-off-by: Miguel Ojeda --- v2: - Made `small` actually small (128 bytes) and kept the by-value initialization instead. v1: https://lore.kernel.org/rust-for-linux/20261126131456.87524-1-ojeda@kernel.org/ rust/kernel/init.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rust/kernel/init.rs b/rust/kernel/init.rs index 1fdc3963e3e3..a8df7b6a2749 100644 --- a/rust/kernel/init.rs +++ b/rust/kernel/init.rs @@ -204,14 +204,14 @@ fn init(init: impl Init, flags: Flags) -> error::Result /// use pin_init::init_zeroed; /// struct BigBuf { /// big: KBox<[u8; 1024 * 1024 * 1024]>, -/// small: [u8; 1024 * 1024], +/// small: [u8; 128], /// } /// /// impl BigBuf { /// fn new() -> impl Init { /// try_init!(Self { /// big: KBox::init(init_zeroed(), GFP_KERNEL)?, -/// small: [0; 1024 * 1024], +/// small: [0; 128], /// }? Error) /// } /// } @@ -255,7 +255,7 @@ macro_rules! try_init { /// #[pin_data] /// struct BigBuf { /// big: KBox<[u8; 1024 * 1024 * 1024]>, -/// small: [u8; 1024 * 1024], +/// small: [u8; 128], /// ptr: *mut u8, /// } /// @@ -263,7 +263,7 @@ macro_rules! try_init { /// fn new() -> impl PinInit { /// try_pin_init!(Self { /// big: KBox::init(init_zeroed(), GFP_KERNEL)?, -/// small: [0; 1024 * 1024], +/// small: [0; 128], /// ptr: core::ptr::null_mut(), /// }? Error) /// } base-commit: b6a9fa34ce4187cb69d3c588a4bbffc31ce5db8f -- 2.56.1