Re: [PATCH v3 0/4] rust: alloc: add Vec shrinking methods
From: Alice Ryhl
Date: Tue Feb 10 2026 - 09:01:18 EST
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@xxxxxxx/
>
> 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.
> 3. In the binder patch, use a less aggressive shrink strategy to
> avoid shrink-then-regrow oscillation: (Alice)
> if len < cap / 4 {
> shrink_to(cap / 2);
> }
>
> 4. Fix commit prefix to rust_binder: instead of rust: binder:. (Alice)
>
> Also noting that starting from v4, I will be sending patches from
> a new email address: shivamkalra98@xxxxxxxxx
>
> Does this look right? Any other concerns before I send v4?
>
> Thanks,
> Shivam
>
> Note: I previously sent patches as shivamklr@xxxxxxx. That account
> has run out of quota, so I'm continuing from shivamkalra98@xxxxxxxxx
> going forward. All future patches (v4+) will come from this address.