drivers/net/wireguard/allowedips.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
Replace call_rcu() + kmem_cache_free() with kfree_rcu() to simplify
the code and reduce function size.
Signed-off-by: Fushuai Wang <wangfushuai@baidu.com>
---
drivers/net/wireguard/allowedips.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/net/wireguard/allowedips.c b/drivers/net/wireguard/allowedips.c
index 09f7fcd7da78..506f7cf0d7cf 100644
--- a/drivers/net/wireguard/allowedips.c
+++ b/drivers/net/wireguard/allowedips.c
@@ -48,11 +48,6 @@ static void push_rcu(struct allowedips_node **stack,
}
}
-static void node_free_rcu(struct rcu_head *rcu)
-{
- kmem_cache_free(node_cache, container_of(rcu, struct allowedips_node, rcu));
-}
-
static void root_free_rcu(struct rcu_head *rcu)
{
struct allowedips_node *node, *stack[MAX_ALLOWEDIPS_DEPTH] = {
@@ -271,13 +266,13 @@ static void remove_node(struct allowedips_node *node, struct mutex *lock)
if (free_parent)
child = rcu_dereference_protected(parent->bit[!(node->parent_bit_packed & 1)],
lockdep_is_held(lock));
- call_rcu(&node->rcu, node_free_rcu);
+ kfree_rcu(&node, rcu);
if (!free_parent)
return;
if (child)
child->parent_bit_packed = parent->parent_bit_packed;
*(struct allowedips_node **)(parent->parent_bit_packed & ~3UL) = child;
- call_rcu(&parent->rcu, node_free_rcu);
+ kfree_rcu(&parent, rcu);
}
static int remove(struct allowedips_node __rcu **trie, u8 bits, const u8 *key,
--
2.36.1
Hi Fushuai,
kernel test robot noticed the following build errors:
[auto build test ERROR on linus/master]
[also build test ERROR on crng-random/master v6.17 next-20251009]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Fushuai-Wang/wireguard-allowedips-Use-kfree_rcu-instead-of-call_rcu/20251009-142048
base: linus/master
patch link: https://lore.kernel.org/r/20251005122626.26988-1-wangfushuai%40baidu.com
patch subject: [PATCH] wireguard: allowedips: Use kfree_rcu() instead of call_rcu()
config: m68k-hp300_defconfig (https://download.01.org/0day-ci/archive/20251010/202510100057.ZUiqBtur-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 15.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251010/202510100057.ZUiqBtur-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202510100057.ZUiqBtur-lkp@intel.com/
All errors (new ones prefixed by >>):
In file included from <command-line>:
drivers/net/wireguard/allowedips.c: In function 'remove_node':
>> include/linux/stddef.h:16:33: error: '*0' is a pointer; did you mean to use '->'?
16 | #define offsetof(TYPE, MEMBER) __builtin_offsetof(TYPE, MEMBER)
| ^~~~~~~~~~~~~~~~~~
include/linux/compiler_types.h:575:23: note: in definition of macro '__compiletime_assert'
575 | if (!(condition)) \
| ^~~~~~~~~
include/linux/compiler_types.h:595:9: note: in expansion of macro '_compiletime_assert'
595 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
| ^~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:50:9: note: in expansion of macro 'BUILD_BUG_ON_MSG'
50 | BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
| ^~~~~~~~~~~~~~~~
include/linux/rcupdate.h:1124:17: note: in expansion of macro 'BUILD_BUG_ON'
1124 | BUILD_BUG_ON(offsetof(typeof(*(ptr)), rhf) >= 4096); \
| ^~~~~~~~~~~~
include/linux/rcupdate.h:1124:30: note: in expansion of macro 'offsetof'
1124 | BUILD_BUG_ON(offsetof(typeof(*(ptr)), rhf) >= 4096); \
| ^~~~~~~~
include/linux/rcupdate.h:1087:29: note: in expansion of macro 'kvfree_rcu_arg_2'
1087 | #define kfree_rcu(ptr, rhf) kvfree_rcu_arg_2(ptr, rhf)
| ^~~~~~~~~~~~~~~~
drivers/net/wireguard/allowedips.c:269:9: note: in expansion of macro 'kfree_rcu'
269 | kfree_rcu(&node, rcu);
| ^~~~~~~~~
In file included from include/linux/rculist.h:11,
from include/linux/dcache.h:8,
from include/linux/fs.h:9,
from include/linux/highmem.h:5,
from include/linux/bvec.h:10,
from include/linux/skbuff.h:17,
from include/linux/ip.h:16,
from drivers/net/wireguard/allowedips.h:10,
from drivers/net/wireguard/allowedips.c:6:
>> include/linux/rcupdate.h:1125:41: error: '___p' is a pointer to pointer; did you mean to dereference it before applying '->' to it?
1125 | kvfree_call_rcu(&((___p)->rhf), (void *) (___p)); \
| ^~
include/linux/rcupdate.h:1087:29: note: in expansion of macro 'kvfree_rcu_arg_2'
1087 | #define kfree_rcu(ptr, rhf) kvfree_rcu_arg_2(ptr, rhf)
| ^~~~~~~~~~~~~~~~
drivers/net/wireguard/allowedips.c:269:9: note: in expansion of macro 'kfree_rcu'
269 | kfree_rcu(&node, rcu);
| ^~~~~~~~~
>> include/linux/stddef.h:16:33: error: '*0' is a pointer; did you mean to use '->'?
16 | #define offsetof(TYPE, MEMBER) __builtin_offsetof(TYPE, MEMBER)
| ^~~~~~~~~~~~~~~~~~
include/linux/compiler_types.h:575:23: note: in definition of macro '__compiletime_assert'
575 | if (!(condition)) \
| ^~~~~~~~~
include/linux/compiler_types.h:595:9: note: in expansion of macro '_compiletime_assert'
595 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
| ^~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:50:9: note: in expansion of macro 'BUILD_BUG_ON_MSG'
50 | BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
| ^~~~~~~~~~~~~~~~
include/linux/rcupdate.h:1124:17: note: in expansion of macro 'BUILD_BUG_ON'
1124 | BUILD_BUG_ON(offsetof(typeof(*(ptr)), rhf) >= 4096); \
| ^~~~~~~~~~~~
include/linux/rcupdate.h:1124:30: note: in expansion of macro 'offsetof'
1124 | BUILD_BUG_ON(offsetof(typeof(*(ptr)), rhf) >= 4096); \
| ^~~~~~~~
include/linux/rcupdate.h:1087:29: note: in expansion of macro 'kvfree_rcu_arg_2'
1087 | #define kfree_rcu(ptr, rhf) kvfree_rcu_arg_2(ptr, rhf)
| ^~~~~~~~~~~~~~~~
drivers/net/wireguard/allowedips.c:275:9: note: in expansion of macro 'kfree_rcu'
275 | kfree_rcu(&parent, rcu);
| ^~~~~~~~~
>> include/linux/rcupdate.h:1125:41: error: '___p' is a pointer to pointer; did you mean to dereference it before applying '->' to it?
1125 | kvfree_call_rcu(&((___p)->rhf), (void *) (___p)); \
| ^~
include/linux/rcupdate.h:1087:29: note: in expansion of macro 'kvfree_rcu_arg_2'
1087 | #define kfree_rcu(ptr, rhf) kvfree_rcu_arg_2(ptr, rhf)
| ^~~~~~~~~~~~~~~~
drivers/net/wireguard/allowedips.c:275:9: note: in expansion of macro 'kfree_rcu'
275 | kfree_rcu(&parent, rcu);
| ^~~~~~~~~
--
In file included from <command-line>:
allowedips.c: In function 'remove_node':
>> include/linux/stddef.h:16:33: error: '*0' is a pointer; did you mean to use '->'?
16 | #define offsetof(TYPE, MEMBER) __builtin_offsetof(TYPE, MEMBER)
| ^~~~~~~~~~~~~~~~~~
include/linux/compiler_types.h:575:23: note: in definition of macro '__compiletime_assert'
575 | if (!(condition)) \
| ^~~~~~~~~
include/linux/compiler_types.h:595:9: note: in expansion of macro '_compiletime_assert'
595 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
| ^~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:50:9: note: in expansion of macro 'BUILD_BUG_ON_MSG'
50 | BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
| ^~~~~~~~~~~~~~~~
include/linux/rcupdate.h:1124:17: note: in expansion of macro 'BUILD_BUG_ON'
1124 | BUILD_BUG_ON(offsetof(typeof(*(ptr)), rhf) >= 4096); \
| ^~~~~~~~~~~~
include/linux/rcupdate.h:1124:30: note: in expansion of macro 'offsetof'
1124 | BUILD_BUG_ON(offsetof(typeof(*(ptr)), rhf) >= 4096); \
| ^~~~~~~~
include/linux/rcupdate.h:1087:29: note: in expansion of macro 'kvfree_rcu_arg_2'
1087 | #define kfree_rcu(ptr, rhf) kvfree_rcu_arg_2(ptr, rhf)
| ^~~~~~~~~~~~~~~~
allowedips.c:269:9: note: in expansion of macro 'kfree_rcu'
269 | kfree_rcu(&node, rcu);
| ^~~~~~~~~
In file included from include/linux/rculist.h:11,
from include/linux/dcache.h:8,
from include/linux/fs.h:9,
from include/linux/highmem.h:5,
from include/linux/bvec.h:10,
from include/linux/skbuff.h:17,
from include/linux/ip.h:16,
from allowedips.h:10,
from allowedips.c:6:
>> include/linux/rcupdate.h:1125:41: error: '___p' is a pointer to pointer; did you mean to dereference it before applying '->' to it?
1125 | kvfree_call_rcu(&((___p)->rhf), (void *) (___p)); \
| ^~
include/linux/rcupdate.h:1087:29: note: in expansion of macro 'kvfree_rcu_arg_2'
1087 | #define kfree_rcu(ptr, rhf) kvfree_rcu_arg_2(ptr, rhf)
| ^~~~~~~~~~~~~~~~
allowedips.c:269:9: note: in expansion of macro 'kfree_rcu'
269 | kfree_rcu(&node, rcu);
| ^~~~~~~~~
>> include/linux/stddef.h:16:33: error: '*0' is a pointer; did you mean to use '->'?
16 | #define offsetof(TYPE, MEMBER) __builtin_offsetof(TYPE, MEMBER)
| ^~~~~~~~~~~~~~~~~~
include/linux/compiler_types.h:575:23: note: in definition of macro '__compiletime_assert'
575 | if (!(condition)) \
| ^~~~~~~~~
include/linux/compiler_types.h:595:9: note: in expansion of macro '_compiletime_assert'
595 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
| ^~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:50:9: note: in expansion of macro 'BUILD_BUG_ON_MSG'
50 | BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
| ^~~~~~~~~~~~~~~~
include/linux/rcupdate.h:1124:17: note: in expansion of macro 'BUILD_BUG_ON'
1124 | BUILD_BUG_ON(offsetof(typeof(*(ptr)), rhf) >= 4096); \
| ^~~~~~~~~~~~
include/linux/rcupdate.h:1124:30: note: in expansion of macro 'offsetof'
1124 | BUILD_BUG_ON(offsetof(typeof(*(ptr)), rhf) >= 4096); \
| ^~~~~~~~
include/linux/rcupdate.h:1087:29: note: in expansion of macro 'kvfree_rcu_arg_2'
1087 | #define kfree_rcu(ptr, rhf) kvfree_rcu_arg_2(ptr, rhf)
| ^~~~~~~~~~~~~~~~
allowedips.c:275:9: note: in expansion of macro 'kfree_rcu'
275 | kfree_rcu(&parent, rcu);
| ^~~~~~~~~
>> include/linux/rcupdate.h:1125:41: error: '___p' is a pointer to pointer; did you mean to dereference it before applying '->' to it?
1125 | kvfree_call_rcu(&((___p)->rhf), (void *) (___p)); \
| ^~
include/linux/rcupdate.h:1087:29: note: in expansion of macro 'kvfree_rcu_arg_2'
1087 | #define kfree_rcu(ptr, rhf) kvfree_rcu_arg_2(ptr, rhf)
| ^~~~~~~~~~~~~~~~
allowedips.c:275:9: note: in expansion of macro 'kfree_rcu'
275 | kfree_rcu(&parent, rcu);
| ^~~~~~~~~
vim +16 include/linux/stddef.h
6e218287432472 Richard Knutsson 2006-09-30 14
^1da177e4c3f41 Linus Torvalds 2005-04-16 15 #undef offsetof
14e83077d55ff4 Rasmus Villemoes 2022-03-23 @16 #define offsetof(TYPE, MEMBER) __builtin_offsetof(TYPE, MEMBER)
3876488444e712 Denys Vlasenko 2015-03-09 17
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
On Sun, Oct 5, 2025 at 5:26 AM Fushuai Wang <wangfushuai@baidu.com> wrote:
>
> Replace call_rcu() + kmem_cache_free() with kfree_rcu() to simplify
> the code and reduce function size.
>
> Signed-off-by: Fushuai Wang <wangfushuai@baidu.com>
Hmm... have you compiled this patch ?
I think all compilers would complain loudly.
> ---
> drivers/net/wireguard/allowedips.c | 9 ++-------
> 1 file changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/wireguard/allowedips.c b/drivers/net/wireguard/allowedips.c
> index 09f7fcd7da78..506f7cf0d7cf 100644
> --- a/drivers/net/wireguard/allowedips.c
> +++ b/drivers/net/wireguard/allowedips.c
> @@ -48,11 +48,6 @@ static void push_rcu(struct allowedips_node **stack,
> }
> }
>
> -static void node_free_rcu(struct rcu_head *rcu)
> -{
> - kmem_cache_free(node_cache, container_of(rcu, struct allowedips_node, rcu));
> -}
> -
> static void root_free_rcu(struct rcu_head *rcu)
> {
> struct allowedips_node *node, *stack[MAX_ALLOWEDIPS_DEPTH] = {
> @@ -271,13 +266,13 @@ static void remove_node(struct allowedips_node *node, struct mutex *lock)
> if (free_parent)
> child = rcu_dereference_protected(parent->bit[!(node->parent_bit_packed & 1)],
> lockdep_is_held(lock));
> - call_rcu(&node->rcu, node_free_rcu);
> + kfree_rcu(&node, rcu);
kfree_rcu(node, rcu);
> if (!free_parent)
> return;
> if (child)
> child->parent_bit_packed = parent->parent_bit_packed;
> *(struct allowedips_node **)(parent->parent_bit_packed & ~3UL) = child;
> - call_rcu(&parent->rcu, node_free_rcu);
> + kfree_rcu(&parent, rcu);
kfree_rcu(parent, rcu);
> }
>
> static int remove(struct allowedips_node __rcu **trie, u8 bits, const u8 *key,
> --
> 2.36.1
>
>> Replace call_rcu() + kmem_cache_free() with kfree_rcu() to simplify >> the code and reduce function size. >> >> Signed-off-by: Fushuai Wang <wangfushuai@baidu.com> > > Hmm... have you compiled this patch ? > > I think all compilers would complain loudly. you are right. I uploaded the wrong version of the patch. I will send the correct v2 shortly. Thank you for pointing it out! Regards, Wang.
© 2016 - 2025 Red Hat, Inc.