[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <DGBKYW8RRJJZ.3I4FG8U6UXGRQ@kernel.org>
Date: Tue, 10 Feb 2026 21:56:41 +0100
From: "Danilo Krummrich" <dakr@...nel.org>
To: "Alice Ryhl" <aliceryhl@...gle.com>
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 9:53 PM CET, Danilo Krummrich wrote:
> On Tue Feb 10, 2026 at 9:43 PM CET, Danilo Krummrich wrote:
>> On Tue Feb 10, 2026 at 9:05 PM CET, Alice Ryhl wrote:
>>> 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?
>>
>> KVVec::realloc() should not have this behavior either, we only want it for
>
> s/KVVec::realloc()/KVec::shrink_to()/
>
>> VVec::shrink_to() and KVVec::shrink_to(), so I think we need a temporary quirk
>> trait.
>
> Unless you mean to implement shrink_to() for VVec and KVVec only, that would be
s/and/or/ (Sorry for another correction, slightly distracted currently. :)
> fine with me as well.
Powered by blists - more mailing lists