[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250814064927.27345-1-lorenzo.stoakes@oracle.com>
Date: Thu, 14 Aug 2025 07:49:27 +0100
From: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>
To: Andrew Morton <akpm@...ux-foundation.org>,
Pedro Falcato <pfalcato@...e.de>
Cc: "Liam R . Howlett" <Liam.Howlett@...cle.com>,
Matthew Wilcox <willy@...radead.org>,
Sidhartha Kumar <sidhartha.kumar@...cle.com>,
Vlastimil Babka <vbabka@...e.cz>, maple-tree@...ts.infradead.org,
linux-mm@...ck.org, linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] testing/radix-tree/maple: hack around kfree_rcu not existing
From: Pedro Falcato <pfalcato@...e.de>
liburcu doesn't have kfree_rcu (or anything similar). Despite that, we can
hack around it in a trivial fashion, by adding a wrapper.
This wrapper only works for maple_nodes, and not anything else (due to us
not being able to know rcu_head offsets in any way), and thus we take
advantage of the type checking to avoid future silent breakage.
This fixes the build for the VMA userland tests.
Additionally remove the existing implementation in maple.c, and have
maple.c include the maple-shared.c header.
Reviewed-by: Sidhartha Kumar <sidhartha.kumar@...cle.com>
Tested-by: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>
Signed-off-by: Pedro Falcato <pfalcato@...e.de>
Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>
---
Andrew - please attribute this as Pedro's patch (Pedro - please mail to
confirm), as this is simply an updated version of [0], pulled out to fix the
VMA tests which remain broken.
Sid - I kept your R-b as this is fundamentally the same thing, just pulling out
shared code from maple.c.
Delta from [0]:
* Removed duplicated code from maple.c.
* Slightly reworded patch description.
Note I didn't put a Fixes, as the relevant commit [1] is not yet upstream.
Thanks, Lorenzo
[0]:https://lore.kernel.org/all/20250812162124.59417-1-pfalcato@suse.de/
[1]:https://lore.kernel.org/all/20250718172138.103116-1-pfalcato@suse.de/
tools/testing/radix-tree/maple.c | 18 +-----------------
tools/testing/shared/maple-shared.h | 15 +++++++++++++++
2 files changed, 16 insertions(+), 17 deletions(-)
diff --git a/tools/testing/radix-tree/maple.c b/tools/testing/radix-tree/maple.c
index bfdc93c36cf9..fbfd4fcc634c 100644
--- a/tools/testing/radix-tree/maple.c
+++ b/tools/testing/radix-tree/maple.c
@@ -23,23 +23,7 @@
#define MODULE_LICENSE(x)
#define dump_stack() assert(0)
-
-#include <linux/maple_tree.h>
-
-static void free_node(struct rcu_head *head)
-{
- struct maple_node *node = container_of(head, struct maple_node, rcu);
-
- free(node);
-}
-
-static void kfree_rcu_node(struct maple_node *node)
-{
- call_rcu(&node->rcu, free_node);
-}
-
-#define kfree_rcu(ptr, memb) kfree_rcu_node(ptr)
-
+#include "../shared/maple-shared.h"
#include "../../../lib/maple_tree.c"
#include "../../../lib/test_maple_tree.c"
diff --git a/tools/testing/shared/maple-shared.h b/tools/testing/shared/maple-shared.h
index dc4d30f3860b..572cd2580123 100644
--- a/tools/testing/shared/maple-shared.h
+++ b/tools/testing/shared/maple-shared.h
@@ -9,5 +9,20 @@
#include <stdlib.h>
#include <time.h>
#include "linux/init.h"
+#include <linux/maple_tree.h>
+
+static inline void free_node(struct rcu_head *head)
+{
+ struct maple_node *node = container_of(head, struct maple_node, rcu);
+
+ free(node);
+}
+
+static inline void kfree_rcu_node(struct maple_node *node)
+{
+ call_rcu(&node->rcu, free_node);
+}
+
+#define kfree_rcu(ptr, memb) kfree_rcu_node(ptr)
#endif /* __MAPLE_SHARED_H__ */
--
2.50.1
Powered by blists - more mailing lists