Subject: Re: linux-next: build failure after merge of the cgroup tree

From: Waiman Long <[email-masked]>
Date: Wed, 6 Dec 2023 23:18:03 -0500

On 12/6/23 22:38, Stephen Rothwell wrote:
> Hi all,
>
> After merging the cgroup tree, today's linux-next build (x86_64
> allmodconfig) failed like this:
>
> In file included from <command-line>:
> kernel/cgroup/cgroup.c: In function 'cgroup_free_root':
> include/linux/compiler_types.h:435:45: error: call to '__compiletime_assert_1792' declared with attribute error: BUILD_BUG_ON failed: !__is_kvfree_rcu_offset(offsetof(typeof(*(root)), rcu))
>    435 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>        |                                             ^
> include/linux/compiler_types.h:416:25: note: in definition of macro '__compiletime_assert'
>    416 |                         prefix ## suffix();                             \
>        |                         ^~~~~~
> include/linux/compiler_types.h:435:9: note: in expansion of macro '_compiletime_assert'
>    435 |         _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:985:17: note: in expansion of macro 'BUILD_BUG_ON'
>    985 |                 BUILD_BUG_ON(!__is_kvfree_rcu_offset(offsetof(typeof(*(ptr)), rhf)));   \

#define __is_kvfree_rcu_offset(offset) ((offset) < 4096)

It looks like commit 77070eeb8821 ("cgroup: Avoid false cacheline 
sharing of read mostly rstat_cpu") has caused the offset of rcu to 
exceed the 4096 limit under such configuration. After I move the rcu 
field up, the compilation error was gone. So any change that makes the 
cgroup structure larger is likely to cause this problem again. The 
simple fix is just to move the rcu field up. I will send a patch to do that.

Cheers,
Longman

>        |                 ^~~~~~~~~~~~
> include/linux/rcupdate.h:957:29: note: in expansion of macro 'kvfree_rcu_arg_2'
>    957 | #define kfree_rcu(ptr, rhf) kvfree_rcu_arg_2(ptr, rhf)
>        |                             ^~~~~~~~~~~~~~~~
> kernel/cgroup/cgroup.c:1318:9: note: in expansion of macro 'kfree_rcu'
>   1318 |         kfree_rcu(root, rcu);
>        |         ^~~~~~~~~
> In function 'cgroup_free_root',
>      inlined from 'cgroup_destroy_root' at kernel/cgroup/cgroup.c:1363:2:
> include/linux/compiler_types.h:435:45: error: call to '__compiletime_assert_1792' declared with attribute error: BUILD_BUG_ON failed: !__is_kvfree_rcu_offset(offsetof(typeof(*(root)), rcu))
>    435 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>        |                                             ^
> include/linux/compiler_types.h:416:25: note: in definition of macro '__compiletime_assert'
>    416 |                         prefix ## suffix();                             \
>        |                         ^~~~~~
> include/linux/compiler_types.h:435:9: note: in expansion of macro '_compiletime_assert'
>    435 |         _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:985:17: note: in expansion of macro 'BUILD_BUG_ON'
>    985 |                 BUILD_BUG_ON(!__is_kvfree_rcu_offset(offsetof(typeof(*(ptr)), rhf)));   \
>        |                 ^~~~~~~~~~~~
> include/linux/rcupdate.h:957:29: note: in expansion of macro 'kvfree_rcu_arg_2'
>    957 | #define kfree_rcu(ptr, rhf) kvfree_rcu_arg_2(ptr, rhf)
>        |                             ^~~~~~~~~~~~~~~~
> kernel/cgroup/cgroup.c:1318:9: note: in expansion of macro 'kfree_rcu'
>   1318 |         kfree_rcu(root, rcu);
>        |         ^~~~~~~~~
>
> Possibly caused by commit
>
>    77070eeb8821 ("cgroup: Avoid false cacheline sharing of read mostly rstat_cpu")
>
> I have used the cgroup tree from next-20231206 for today.
>
>
>