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: <20251008225002.011378ed@nimda.home>
Date: Wed, 8 Oct 2025 22:50:02 +0300
From: Onur Özkan <work@...rozkan.dev>
To: Tamir Duberstein <tamird@...il.com>
Cc: rust-for-linux@...r.kernel.org, ojeda@...nel.org, alex.gaynor@...il.com,
 boqun.feng@...il.com, gary@...yguo.net, bjorn3_gh@...tonmail.com,
 lossin@...nel.org, aliceryhl@...gle.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, linux-mm@...ck.org
Subject: Re: [PATCH v2 2/4] rust: xarray: abstract `xa_alloc`

On Wed, 8 Oct 2025 09:59:12 -0700
Tamir Duberstein <tamird@...il.com> wrote:

> On Wed, Oct 8, 2025 at 6:05 AM Onur Özkan <work@...rozkan.dev> wrote:
> >
> > Implements `alloc` function to `XArray<T>` that wraps
> > `xa_alloc` safely, which will be used to generate the
> > auxiliary device IDs.
> >
> > 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 | 41
> > ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40
> > insertions(+), 1 deletion(-)
> >
> > diff --git a/rust/kernel/xarray.rs b/rust/kernel/xarray.rs
> > index 90e27cd5197e..0711ccf99fb4 100644
> > --- a/rust/kernel/xarray.rs
> > +++ b/rust/kernel/xarray.rs
> > @@ -10,7 +10,7 @@
> >      ffi::c_void,
> >      types::{ForeignOwnable, NotThreadSafe, Opaque},
> >  };
> > -use core::{iter, marker::PhantomData, pin::Pin, ptr::NonNull};
> > +use core::{iter, marker::PhantomData, ops::Range, pin::Pin,
> > ptr::NonNull}; use pin_init::{pin_data, pin_init, pinned_drop,
> > PinInit};
> >
> >  /// An array which efficiently maps sparse integer indices to
> > owned objects. @@ -268,6 +268,45 @@ pub fn store(
> >              Ok(unsafe { T::try_from_foreign(old) })
> >          }
> >      }
> > +
> > +    /// Allocates an empty slot within the given `limit` and
> > stores `value` there.
> > +    ///
> > +    /// May drop the lock if needed to allocate memory, and then
> > reacquire it afterwards.
> > +    ///
> > +    /// On success, returns the allocated index.
> 
> Returning the index is not a very good abstraction. Would the
> reservation API meet your needs?
> 
> https://lore.kernel.org/all/20250713-xarray-insert-reserve-v2-3-b939645808a2@gmail.com/
> 
> If yes, I would appreciate your tags there.

It should be "allocated key", I misdocumented it. I don't have a
use-case for this implementation, I am just trying to help on the nova
task list:
    https://docs.kernel.org/gpu/nova/core/todo.html#xarray-bindings-xarr

The task mentions "generate the auxiliary device IDs", which should be
the returned key, right?

There is also this reference [1] that shows that the returned key will
be useful.

[1]: https://lore.kernel.org/all/aOTyVzpJNDOaxxs6@google.com/

Regards,
Onur

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ