lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <DBNU4N9KCD5J.2G97H1EI7DO1W@kernel.org>
Date: Mon, 28 Jul 2025 18:39:29 +0200
From: "Danilo Krummrich" <dakr@...nel.org>
To: "Boqun Feng" <boqun.feng@...il.com>
Cc: "Alice Ryhl" <aliceryhl@...gle.com>, "Andrew Morton"
 <akpm@...ux-foundation.org>, "Liam R. Howlett" <Liam.Howlett@...cle.com>,
 "Lorenzo Stoakes" <lorenzo.stoakes@...cle.com>, "Miguel Ojeda"
 <ojeda@...nel.org>, "Andrew Ballance" <andrewjballance@...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>,
 <linux-kernel@...r.kernel.org>, <maple-tree@...ts.infradead.org>,
 <rust-for-linux@...r.kernel.org>, <linux-mm@...ck.org>
Subject: Re: [PATCH 1/3] rust: maple_tree: add MapleTree

On Mon Jul 28, 2025 at 6:04 PM CEST, Boqun Feng wrote:
> On Sat, Jul 26, 2025 at 01:23:22PM +0000, Alice Ryhl wrote:
>> The maple tree will be used in the Tyr driver to allocate and keep track
>> of GPU allocations created internally (i.e. not by userspace). It will
>> likely also be used in the Nova driver eventually.
>> 
>> This adds the simplest methods for additional and removal that do not
>> require any special care with respect to concurrency.
>> 
>> This implementation is based on the RFC by Andrew but with significant
>> changes to simplify the implementation.
>> 
>> Co-developed-by: Andrew Ballance <andrewjballance@...il.com>
>> Signed-off-by: Andrew Ballance <andrewjballance@...il.com>
>> Signed-off-by: Alice Ryhl <aliceryhl@...gle.com>
>> ---
> [...]
>> +    /// Free all `T` instances in this tree.
>> +    ///
>> +    /// # Safety
>> +    ///
>> +    /// This frees Rust data referenced by the maple tree without removing it from the maple tree.
>> +    /// The caller must ensure that no reference that remains in the maple tree is used incorrectly
>> +    /// after this call.
>> +    unsafe fn free_all_entries(self: Pin<&mut Self>) {
>> +        // SAFETY: The pointer references a valid maple tree.
>> +        let ma_state = unsafe { Opaque::new(bindings::MA_STATE(self.tree.get(), 0, usize::MAX)) };
>> +
>
> A meta comment here for the future direction: I think it really makes a
> lot of sense if we could have the Rust abstraction for struct ma_state,
> that'll allow us to have flexible locking strategy and Iterator-like
> interface. Maybe it's something Andrew can take a deeper look when
> MapleTree binding is in-tree (no word play intented ;-))?
>
> For example, with a ma_state binding, we can do:
>
>     let mas = MAState::new(self, 0..);
>
>     while let Some(v) = mas.next() {
>     	drop(v)
>     }

FYI: Left a similar comment on MapleLock [1]. :)

I'd rather have that sooner than later, free_all_entries() is a good internal
user.

[1] https://lore.kernel.org/all/DBNO0N1TDAGI.2OEWH6Y60JNYZ@kernel.org/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ