[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAH5fLghy3_J_in-o=y8yh94+RLn6XihNOTzTiT2kk9DkXBMPVA@mail.gmail.com>
Date: Tue, 10 Feb 2026 21:05:42 +0100
From: Alice Ryhl <aliceryhl@...gle.com>
To: Danilo Krummrich <dakr@...nel.org>
Cc: Shivam Kalra <shivamkalra98@...il.com>, Lorenzo Stoakes <lorenzo.stoakes@...cle.com>,
Vlastimil Babka <vbabka@...e.cz>, "Liam R. Howlett" <Liam.Howlett@...cle.com>,
Uladzislau Rezki <urezki@...il.com>, Miguel Ojeda <ojeda@...nel.org>, Boqun Feng <boqun.feng@...il.com>,
Gary Guo <gary@...yguo.net>, Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <lossin@...nel.org>, Andreas Hindborg <a.hindborg@...nel.org>,
Trevor Gross <tmgross@...ch.edu>, Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Arve Hjønnevåg <arve@...roid.com>,
Todd Kjos <tkjos@...roid.com>, Christian Brauner <brauner@...nel.org>,
Carlos Llamas <cmllamas@...gle.com>, rust-for-linux@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 0/4] rust: alloc: add Vec shrinking methods
On Tue, Feb 10, 2026 at 4:05 PM Danilo Krummrich <dakr@...nel.org> wrote:
>
> On Tue Feb 10, 2026 at 2:57 PM CET, Alice Ryhl wrote:
> > On Tue, Feb 10, 2026 at 07:08:09PM +0530, Shivam Kalra wrote:
> >> This is a follow-up to my v3 series:
> >> https://lore.kernel.org/rust-for-linux/20260207-binder-shrink-vec-v3-v3-0-8ff388563427@cock.li/
> >>
> >> Hi all,
> >>
> >> Thanks for the feedback on v3. Before I respin, I want to confirm
> >> the direction for v4 to avoid unnecessary iterations.
> >>
> >> Proposed changes for v4:
> >>
> >> 1. Drop the Shrinkable trait entirely. Make shrink_to() a normal
> >> method on Vec<T, A> that calls A::realloc(). (Danilo)
> >>
> >> 2. Add a temporary ShrinkQuirk trait to handle the vmalloc workaround
> >> (page-boundary check + manual alloc+copy+free) until vrealloc
> >> gains in-place shrinking support. (Danilo)
> >
> > I don't think you want any new traits at all. What types would even
> > implement the trait? The special code can go in the realloc() method of
> > Vmalloc struct in rust/kernel/alloc/allocator.rs.
>
> I did not propose to move this into the realloc() functions of the corresponding
> allocators intentionally, as there is a difference between calling realloc() and
> shrink_to().
>
> I don't want that some user of e.g. Vmalloc::realloc() experiences page wise
> shrinking by copy. This is acceptable for Vec::shrink_to(), but not for
> realloc() in general.
Ok. In that case we can add a method on KVVec directly for this
purpose, but I still don't think we need a trait?
Alice
Powered by blists - more mailing lists