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] [thread-next>] [day] [month] [year] [list]
Message-Id: <DDCV43KW9OGL.27I8HP4TSTQ6N@kernel.org>
Date: Wed, 08 Oct 2025 12:18:24 +0200
From: "Benno Lossin" <lossin@...nel.org>
To: "Alice Ryhl" <aliceryhl@...gle.com>
Cc: Onur Özkan <work@...rozkan.dev>,
 <rust-for-linux@...r.kernel.org>, <ojeda@...nel.org>,
 <alex.gaynor@...il.com>, <boqun.feng@...il.com>, <gary@...yguo.net>,
 <bjorn3_gh@...tonmail.com>, <tmgross@...ch.edu>, <dakr@...nel.org>,
 <linux-kernel@...r.kernel.org>, <acourbot@...dia.com>, <airlied@...il.com>,
 <simona@...ll.ch>, <maarten.lankhorst@...ux.intel.com>,
 <mripard@...nel.org>, <tzimmermann@...e.de>, <corbet@....net>,
 <lyude@...hat.com>, <linux-doc@...r.kernel.org>
Subject: Re: [PATCH 1/3] rust: xarray: abstract `xa_alloc`

On Tue Oct 7, 2025 at 12:58 PM CEST, Alice Ryhl wrote:
> On Mon, Oct 06, 2025 at 09:31:43PM +0200, Benno Lossin wrote:
>> On Mon Oct 6, 2025 at 6:30 PM CEST, Onur Özkan wrote:
>> > Implements `alloc` function to `XArray<T>` that wraps
>> > `xa_alloc` safely.
>> >
>> > Resolves a task from the nova/core task list under the "XArray
>> > bindings [XARR]" section in "Documentation/gpu/nova/core/todo.rst"
>> > file.
>> >
>> > Signed-off-by: Onur Özkan <work@...rozkan.dev>
>> > ---
>> >  rust/kernel/xarray.rs | 39 +++++++++++++++++++++++++++++++++++++++
>> >  1 file changed, 39 insertions(+)
>> >
>> > diff --git a/rust/kernel/xarray.rs b/rust/kernel/xarray.rs
>> > index a49d6db28845..1b882cd2f58b 100644
>> > --- a/rust/kernel/xarray.rs
>> > +++ b/rust/kernel/xarray.rs
>> > @@ -266,6 +266,45 @@ pub fn store(
>> >              Ok(unsafe { T::try_from_foreign(old) })
>> >          }
>> >      }
>> > +
>> > +    /// Allocates an empty slot within the given limit range and stores `value` there.
>> > +    ///
>> > +    /// May drop the lock if needed to allocate memory, and then reacquire it afterwards.
>> > +    ///
>> > +    /// On success, returns the allocated id.
>> > +    ///
>> > +    /// On failure, returns the element which was attempted to be stored.
>> > +    pub fn alloc(
>> > +        &mut self,
>> > +        limit: bindings::xa_limit,
>> > +        value: T,
>> > +        gfp: alloc::Flags,
>> > +    ) -> Result<u32, StoreError<T>> {
>> 
>> I think it would be a good idea to make the id a newtype wrapper around
>> u32. Maybe not even allow users to manually construct it or even inspect
>> it if possible.
>
> What? People need to know what the assigned index is.

The documentation says "allocated id", so I assumed that it was some
internal, implementation-dependent thing, not an index. In that case we
should change the docs instead.

---
Cheers,
Benno

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ