Skip to content

Commit 551a6e7

Browse files
howletttehcaster
authored andcommitted
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/[email protected]/ Suggested-by: Pedro Falcato <[email protected]> Signed-off-by: Liam R. Howlett <[email protected]> Reviewed-by: Suren Baghdasaryan <[email protected]> Signed-off-by: Vlastimil Babka <[email protected]>
1 parent 9f910f7 commit 551a6e7

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

tools/testing/shared/maple-shared.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,15 @@
1010
#include <time.h>
1111
#include "linux/init.h"
1212

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+
1324
#endif /* __MAPLE_SHARED_H__ */

tools/testing/shared/maple-shim.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,9 @@
66
#include <linux/slab.h>
77

88
#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+
}

0 commit comments

Comments
 (0)