summaryrefslogtreecommitdiff
path: root/rust/kernel/device
diff options
context:
space:
mode:
authorShivam Kalra <shivamkalra98@zohomail.in>2026-02-16 19:39:55 +0530
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-02-26 21:37:53 -0800
commit47ac2a4b5cd8f0cb826f6368c2fc0eeb97e5d55f (patch)
tree27b1fad3b4bf018a690ebd7dcd60084eabaae80e /rust/kernel/device
parentd31ed22a0678da8948439c3009b01c4806a677c9 (diff)
rust: kvec: implement shrink_to for KVVec
Implement shrink_to method specifically for `KVVec` (i.e., `Vec<T, KVmalloc>`). `shrink_to` reduces the vector's capacity to a specified minimum. For kmalloc-backed allocations, the method delegates to realloc(), letting the allocator decide whether shrinking is worthwhile. For vmalloc-backed allocations (detected via is_vmalloc_addr), shrinking only occurs if at least one page of memory can be freed, using an explicit alloc+copy+free since vrealloc does not yet support in-place shrinking. A TODO note marks this for future replacement with a generic shrink_to for all allocators that uses A::realloc() once the underlying allocators properly support shrinking via realloc. Suggested-by: Alice Ryhl <aliceryhl@google.com> Suggested-by: Danilo Krummrich <dakr@kernel.org> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Acked-by: Danilo Krummrich <dakr@kernel.org> Signed-off-by: Shivam Kalra <shivamkalra98@zohomail.in> Link: https://patch.msgid.link/20260216-binder-shrink-vec-v3-v6-1-ece8e8593e53@zohomail.in Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'rust/kernel/device')
0 files changed, 0 insertions, 0 deletions