From: "Alexandre Courbot" <acourbot@nvidia.com>
To: "Gary Guo" <gary@kernel.org>
Cc: "Gary Guo" <gary@garyguo.net>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
"Danilo Krummrich" <dakr@kernel.org>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Boqun Feng" <boqun@kernel.org>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Tamir Duberstein" <tamird@kernel.org>,
"Onur Özkan" <work@onurozkan.dev>,
"Matthew Maurer" <mmaurer@google.com>,
driver-core@lists.linux.dev, rust-for-linux@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] samples: rust: debugfs: fix excessive stack use
Date: Thu, 16 Jul 2026 13:33:53 -0700 [thread overview]
Message-ID: <DK0A6FE3RARB.7ITJEIUVGTGP@nvidia.com> (raw)
In-Reply-To: <20260716144144.3665719-1-gary@kernel.org>
On Thu Jul 16, 2026 at 7:41 AM PDT, Gary Guo wrote:
> From: Gary Guo <gary@garyguo.net>
>
> The current implementation creates a 4K array and move it into the box.
> Klint reports that this causes excesssive stack usage:
>
> warning: stack size of `create_file_write` is 4472 bytes, exceeds the 2048-byte limit
> --> samples/rust/rust_debugfs_scoped.rs:54:1
> |
> 54 | / fn create_file_write(
> 55 | | mod_data: &ModuleData,
> 56 | | reader: &mut kernel::uaccess::UserSliceReader,
> 57 | | ) -> Result {
> | |___________^
> |
> = note: the stack size is inferred from instruction `sub $0x1178,%rsp` at .text+2205
>
> Use pin-init to create the array in-place instead.
>
> Fixes: f656279afde1 ("samples: rust: debugfs_scoped: add example for blobs")
> Signed-off-by: Gary Guo <gary@garyguo.net>
> ---
> samples/rust/rust_debugfs_scoped.rs | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/samples/rust/rust_debugfs_scoped.rs b/samples/rust/rust_debugfs_scoped.rs
> index 6a575a15a2c2..33a4a0865f5b 100644
> --- a/samples/rust/rust_debugfs_scoped.rs
> +++ b/samples/rust/rust_debugfs_scoped.rs
> @@ -75,7 +75,7 @@ fn create_file_write(
> GFP_KERNEL,
> )?;
> }
> - let blob = KBox::pin_init(new_mutex!([0x42; SZ_4K]), GFP_KERNEL)?;
> + let blob = KBox::pin_init(new_mutex!(pin_init::init_array_from_fn(|_| 0x42)), GFP_KERNEL)?;
Since this is a sample, do we want to specify the size explicitly as it
is arguably more readable in this case?
Regardless,
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
next prev parent reply other threads:[~2026-07-16 20:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-16 14:41 [PATCH] samples: rust: debugfs: fix excessive stack use Gary Guo
2026-07-16 20:33 ` Alexandre Courbot [this message]
2026-07-16 21:09 ` Gary Guo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DK0A6FE3RARB.7ITJEIUVGTGP@nvidia.com \
--to=acourbot@nvidia.com \
--cc=a.hindborg@kernel.org \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=driver-core@lists.linux.dev \
--cc=gary@garyguo.net \
--cc=gary@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=mmaurer@google.com \
--cc=ojeda@kernel.org \
--cc=rafael@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
--cc=work@onurozkan.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox