Linux driver-core infrastructure
 help / color / mirror / Atom feed
From: David Laight <david.laight.linux@gmail.com>
To: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Cc: Aary Milind Kinge <kingeaary@gmail.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Danilo Krummrich <dakr@kernel.org>,
	Miguel Ojeda <ojeda@kernel.org>,
	Alice Ryhl <aliceryhl@google.com>,
	rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
	driver-core@lists.linux.dev
Subject: Re: [PATCH v2] rust: devres: optimize type name allocation and fix truncation
Date: Tue, 26 May 2026 16:03:06 +0100	[thread overview]
Message-ID: <20260526160306.15351508@pumpkin> (raw)
In-Reply-To: <CANiq72m5MnUJRJTH=Li-GCYEDoHLcPbKKNUQ=hJUKxB=tNLQaw@mail.gmail.com>

On Tue, 26 May 2026 14:37:44 +0200
Miguel Ojeda <miguel.ojeda.sandonis@gmail.com> wrote:

> On Tue, May 26, 2026 at 1:58 PM Aary Milind Kinge <kingeaary@gmail.com> wrote:
> >
> > The unconditional 128-byte const array allocation for every unique
> > `Devres<T>` caused unnecessary .rodata bloat in production builds,  
> 
> Wasn't the string deduplicated?
> 
> > terminator), the copy routine now appends "..." at the end — copying  
> 
> Did an LLM assist this patch? If so, please add a tag:
> 
>   https://docs.kernel.org/process/generated-content.html
>   https://docs.kernel.org/process/coding-assistants.html
> 
> Moreover, this should be sent to the right maintainers and reviewers,
> e.g. at least to "DRIVER CORE, KOBJECTS, DEBUGFS AND SYSFS". Cc'ing
> them here, but also please Cc all the "RUST" entry.
> 
> > +        let mut buf = [0u8; 128];  
> 
> Why is there a hardcoded literal? Please use constants where possible,
> deriving the rest of the literals from that.
> 
> > +        let mut len = 0;
> > +        while len < 128 && static_buf[len] != 0 {
> > +            len += 1;
> > +        }
> > +
> > +        // SAFETY: `static_buf` is promoted to static memory, and we verified the null byte.  
> 
> This should explain why this is all OK, e.g. why it doesn't go out of
> bounds (a local-only reading of the loop above would appear to make it
> so).

I'm no rust expert (or novice) but that code all looks like run-time
initialisers rather that the static data you really want.

Can you generate the '\0' terminated C 'string' by including an explicit
zero byte in the rust one?

-- David


      reply	other threads:[~2026-05-26 15:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260526094329.533943-1-kingeaary@gmail.com>
     [not found] ` <20260526115825.1480768-1-kingeaary@gmail.com>
2026-05-26 12:37   ` [PATCH v2] rust: devres: optimize type name allocation and fix truncation Miguel Ojeda
2026-05-26 15:03     ` David Laight [this message]

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=20260526160306.15351508@pumpkin \
    --to=david.laight.linux@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=dakr@kernel.org \
    --cc=driver-core@lists.linux.dev \
    --cc=gregkh@linuxfoundation.org \
    --cc=kingeaary@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miguel.ojeda.sandonis@gmail.com \
    --cc=ojeda@kernel.org \
    --cc=rafael@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    /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