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=1795698907; b=YoH8mNxx1Sb5m18ZjC30L4DjLIWao1suSwGzBE0ZAJ877kgd8+v4xFB9bWyO/PkIRnDi oVaXePWEhHSjxQIG/Y4pq5BmeUjIfBBxP26PBpcUsPPRYVdD7G8/cm/Fz+5/7Axz1qrsO NnFhf16oEORBPqYbP2RSifsdnPNJXKHa1MszU4h/nZd9uaNsu5TVsIYIcho+5xW84vYMX 1NWLAFbiDxZsIbOV4tdc/dpdTwKTGE+oNBNNJ0on0myWqxAtHEFcQBoZUaOd4u47erzeA 6s2uYUtBJ9Y46IqpWcZp3ambKoMUg1Bb6ou1goJfaJlFlTzH05P9M+gQU0RvNlHZtOQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795698907; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: MIME-Version:Content-Transfer-Encoding; bh=nvZSFE/PjkvX1iQqHe4rEkvvaUjjq3HmhX1scd4d9CY=; b=IlCnPxlLPVenVElMlvz8WsOPbAO3MxkzLZ0w8iTPo3NRWzWr908+zDtUTFmTA0JX7wuD enS3XROvx7zEsg2/Hf4eF9byRsmPEyBsR+RJJQzPFaX8jx3lvS0JlhlO+HWY/qXtx00iw 54DqFlIVxpp+Akn0ErQ0i77kzr7tih9fri8DmRGUsRbul30ZceIFEXk2C2LIjuigyJu6k aYk2ffBFolop5it5ozV/JOBOv6CjrcBqUw/e1e+8p2uhVW3e9Ua2uJO6VLkprDI9vN6/g vNMp7uDf/L4bTphvZeWmh/IBFYIczSK/Kya7VVFg9YwT6iXadGjGUF4IDAi4dXD/K8A== 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=JXNunxIM; 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 1F49E606A327; Thu, 26 Nov 2026 13:15:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=JXNunxIM Received: by smtp.kernel.org (Postfix) with ESMTPSA id B207F1F000CF; Thu, 26 Nov 2026 13:15:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795698906; bh=nvZSFE/PjkvX1iQqHe4rEkvvaUjjq3HmhX1scd4d9CY=; h=From:To:Cc:Subject:Date; b=JXNunxIM1hhLnZB/if9UZ5Tv6G2xhKy2nPei+c+x8gRZAN/ibNWnWGfvCkl01Oyv3 IwmkLCI2G/pkC8ORUdw1tF01ol/eVOA+O22l7AONgXmuSxKzTVmfbY5fItqe6m+tEq crqogXB1etXRFzNmNv86hYj4eeWiLBHQaXWxTcCfj4XMXHtxtRa7Au621DNjHDP8dm tI9+x0moco/LaDUTs5hXnxoMn/uAdhqG1fEAvo/SPDXovq+H7bMEgJFSCrx4l1ZoVc Onkf7rMgZp4XSZsXtRokaWqLOe6fUh8ATyU1kYy2K9YU+9a3R4ElMwzADiF3ONTUi/ 7i3abT7w2F3JQ== 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] rust: init: clean Rust 1.102.0's `clippy::large_unopt_stack_frames` lint Date: Thu, 26 Nov 2026 14:14:56 +0100 Message-ID: <20261126131456.87524-1-ojeda@kernel.org> X-Mailing-List: stable@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 initialize it in place instead. Note that the warning only goes away together with commit 5a2024c03eb6 ("rust: pin-init: internal: allow `clippy::large_unopt_stack_frames`"). 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 --- rust/kernel/init.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/kernel/init.rs b/rust/kernel/init.rs index 1fdc3963e3e3..238ebb3b1a71 100644 --- a/rust/kernel/init.rs +++ b/rust/kernel/init.rs @@ -211,7 +211,7 @@ fn init(init: impl Init, flags: Flags) -> error::Result /// fn new() -> impl Init { /// try_init!(Self { /// big: KBox::init(init_zeroed(), GFP_KERNEL)?, -/// small: [0; 1024 * 1024], +/// small <- init_zeroed(), /// }? Error) /// } /// } @@ -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 <- init_zeroed(), /// ptr: core::ptr::null_mut(), /// }? Error) /// } base-commit: b6a9fa34ce4187cb69d3c588a4bbffc31ce5db8f -- 2.56.0