linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/3] testing/radix-tree/maple: Hack around kfree_rcu not existing
@ 2025-08-12 16:21 Pedro Falcato
  2025-08-12 16:21 ` [PATCH v2 2/3] maple_tree: Use kfree_rcu in ma_free_rcu Pedro Falcato
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Pedro Falcato @ 2025-08-12 16:21 UTC (permalink / raw)
  To: Andrew Morton, Liam R. Howlett, Matthew Wilcox
  Cc: maple-tree, linux-mm, linux-kernel, Sidhartha Kumar, Pedro Falcato

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.

Reviewed-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
Signed-off-by: Pedro Falcato <pfalcato@suse.de>
---
v2:
 - Move kfree_rcu hack to maple-shared.h, to fix userland VMA tests, per
   Lorenzo

 tools/testing/shared/maple-shared.h | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

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



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-08-15 17:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-12 16:21 [PATCH v2 1/3] testing/radix-tree/maple: Hack around kfree_rcu not existing Pedro Falcato
2025-08-12 16:21 ` [PATCH v2 2/3] maple_tree: Use kfree_rcu in ma_free_rcu Pedro Falcato
2025-08-12 16:21 ` [PATCH v2 3/3] maple_tree: Replace mt_free_one() with kfree() Pedro Falcato
2025-08-12 19:41 ` [PATCH v2 1/3] testing/radix-tree/maple: Hack around kfree_rcu not existing Liam R. Howlett
2025-08-15 15:11 ` Liam R. Howlett
2025-08-15 17:06   ` Pedro Falcato

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox