diff options
| author | Tamir Duberstein <[email protected]> | 2025-04-23 13:54:38 +0000 |
|---|---|---|
| committer | Andreas Hindborg <[email protected]> | 2025-05-01 09:37:59 +0000 |
| commit | 210b81578efbe5c5e7748e50d313e1a90b03df55 (patch) | |
| tree | 54f30a53c6484fad38bda0d6d98ba2bd3f987eea /rust/helpers | |
| parent | rust: types: add `ForeignOwnable::PointedTo` (diff) | |
| download | kernel-210b81578efbe5c5e7748e50d313e1a90b03df55.tar.gz kernel-210b81578efbe5c5e7748e50d313e1a90b03df55.zip | |
rust: xarray: Add an abstraction for XArray
`XArray` is an efficient sparse array of pointers. Add a Rust
abstraction for this type.
This implementation bounds the element type on `ForeignOwnable` and
requires explicit locking for all operations. Future work may leverage
RCU to enable lockless operation.
Inspired-by: MaĆra Canal <[email protected]>
Inspired-by: Asahi Lina <[email protected]>
Reviewed-by: Andreas Hindborg <[email protected]>
Reviewed-by: Alice Ryhl <[email protected]>
Signed-off-by: Tamir Duberstein <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Andreas Hindborg <[email protected]>
Diffstat (limited to 'rust/helpers')
| -rw-r--r-- | rust/helpers/helpers.c | 1 | ||||
| -rw-r--r-- | rust/helpers/xarray.c | 28 |
2 files changed, 29 insertions, 0 deletions
diff --git a/rust/helpers/helpers.c b/rust/helpers/helpers.c index 1e7c84df7252..80785b1e7a63 100644 --- a/rust/helpers/helpers.c +++ b/rust/helpers/helpers.c @@ -38,3 +38,4 @@ #include "vmalloc.c" #include "wait.c" #include "workqueue.c" +#include "xarray.c" diff --git a/rust/helpers/xarray.c b/rust/helpers/xarray.c new file mode 100644 index 000000000000..60b299f11451 --- /dev/null +++ b/rust/helpers/xarray.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <linux/xarray.h> + +int rust_helper_xa_err(void *entry) +{ + return xa_err(entry); +} + +void rust_helper_xa_init_flags(struct xarray *xa, gfp_t flags) +{ + return xa_init_flags(xa, flags); +} + +int rust_helper_xa_trylock(struct xarray *xa) +{ + return xa_trylock(xa); +} + +void rust_helper_xa_lock(struct xarray *xa) +{ + return xa_lock(xa); +} + +void rust_helper_xa_unlock(struct xarray *xa) +{ + return xa_unlock(xa); +} |
