git: 796fff59a5d3 - main - linuxkpi: Define `DEFINE_XARRAY*()` macros
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 30 Apr 2026 07:18:30 UTC
The branch main has been updated by dumbbell:
URL: https://cgit.FreeBSD.org/src/commit/?id=796fff59a5d32bc3be14feaeb228fc15ef43eb32
commit 796fff59a5d32bc3be14feaeb228fc15ef43eb32
Author: Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
AuthorDate: 2026-04-13 21:44:16 +0000
Commit: Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
CommitDate: 2026-04-30 07:05:02 +0000
linuxkpi: Define `DEFINE_XARRAY*()` macros
The `DEFINE_XARRAY*()` macros are used to declare a static xarray.
As the structure embeds a mutex(9), we also need to declare the static
mutex after the `struct xarray`. Thus the slightly awkward definition
of `DEFINE_XARRAY_FLAGS()`.
The DRM generic code started to use `DEFINE_XARRAY_ALLOC()` in Linux
6.12.
Reviewed by: bz
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D56446
---
sys/compat/linuxkpi/common/include/linux/xarray.h | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/sys/compat/linuxkpi/common/include/linux/xarray.h b/sys/compat/linuxkpi/common/include/linux/xarray.h
index e6511130d50c..b26aa6f0d13a 100644
--- a/sys/compat/linuxkpi/common/include/linux/xarray.h
+++ b/sys/compat/linuxkpi/common/include/linux/xarray.h
@@ -54,6 +54,18 @@ struct xarray {
uint32_t xa_flags; /* see XA_FLAGS_XXX */
};
+#define DEFINE_XARRAY_FLAGS(name, flags) \
+ struct xarray name = { \
+ .xa_head.gfp_mask = GFP_NOWAIT, \
+ .xa_flags = flags, \
+ }; \
+ MTX_SYSINIT(name ## _mtx, &name.xa_lock, \
+ "linuxkpi_DEFINE_XARRAY(" #name ")", \
+ MTX_DEF | MTX_RECURSE)
+
+#define DEFINE_XARRAY(name) DEFINE_XARRAY_FLAGS(name, 0)
+#define DEFINE_XARRAY_ALLOC(name) DEFINE_XARRAY_FLAGS(name, XA_FLAGS_ALLOC)
+
struct xa_limit {
uint32_t max;
uint32_t min;