Re: [PATCH v3 1/2] rust: kernel: add `drop_contents` to `BoxExt`

Benno Lossin
2024-08-05T20:39:58Z

On 05.08.24 11:07, Danilo Krummrich wrote:
> On Mon, Aug 05, 2024 at 10:43:57AM +0200, Alice Ryhl wrote:
>> On Sun, Aug 4, 2024 at 1:22 AM Danilo Krummrich <dakr@kernel.org> wrote:
>>>
>>> On 8/3/24 4:16 PM, Benno Lossin wrote:
>>>> Sometimes (see [1]) it is necessary to drop the value inside of a
>>>> `Box<T>`, but retain the allocation. For example to reuse the allocation
>>>> in the future.
>>>> Introduce a new function `drop_contents` that turns a `Box<T>` into
>>>> `Box<MaybeUninit<T>>` by dropping the value.
>>>
>>> Is this (and the stuff in patch 2) used somewhere? Otherwise, I think it
>>> would probably make sense to base this work on top of my allocator work.
>>
>> Yes, please see the red/black tree.
>> https://lore.kernel.org/rust-for-linux/20240727-b4-rbtree-v8-0-951600ada434@google.com/
>
> Ok, unless preferred otherwise, I'll pick it up in the corresponding patches of
> my allocator series then.

I am not sure if we want to do that, since the allocator series is
already rather long and the red-black tree has been in review since
February...
Another way of fixing this would be if you base your allocator series on
top of this one, then you can just include it when you remove the
`BoxExit` trait.

---
Cheers,
Benno