Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

testing/radix-tree/maple: Hack around kfree_rcu not existing

liburcu doesn't have kfree_rcu (or anything similar). Despite that, we
can hack around it in a trivial fashion, by adding a wrapper.

The wrapper only works for maple_nodes because we cannot get the
kmem_cache pointer any other way in the test code.

Link: https://lore.kernel.org/all/20250812162124.59417-1-pfalcato@suse.de/
Suggested-by: Pedro Falcato <pfalcato@suse.de>
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Reviewed-by: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>

authored by

Liam R. Howlett and committed by
Vlastimil Babka
551a6e75 9f910f7d

+17
+11
tools/testing/shared/maple-shared.h
··· 10 10 #include <time.h> 11 11 #include "linux/init.h" 12 12 13 + void maple_rcu_cb(struct rcu_head *head); 14 + #define rcu_cb maple_rcu_cb 15 + 16 + #define kfree_rcu(_struct, _memb) \ 17 + do { \ 18 + typeof(_struct) _p_struct = (_struct); \ 19 + \ 20 + call_rcu(&((_p_struct)->_memb), rcu_cb); \ 21 + } while(0); 22 + 23 + 13 24 #endif /* __MAPLE_SHARED_H__ */
+6
tools/testing/shared/maple-shim.c
··· 6 6 #include <linux/slab.h> 7 7 8 8 #include "../../../lib/maple_tree.c" 9 + 10 + void maple_rcu_cb(struct rcu_head *head) { 11 + struct maple_node *node = container_of(head, struct maple_node, rcu); 12 + 13 + kmem_cache_free(maple_node_cache, node); 14 + }