cgroup: Move rcu_head up near the top of cgroup_root
Commit d23b5c577715 ("cgroup: Make operations on the cgroup root_list RCU safe") adds a new rcu_head to the cgroup_root structure and kvfree_rcu() for freeing the cgroup_root.
The use of kvfree_rcu(), however, has the limitation that the offset of the rcu_head structure within the larger data structure cannot exceed 4096 or the compilation will fail. By putting rcu_head below the cgroup structure, any change to the cgroup structure that makes it larger has the risk of build failure. Commit 77070eeb8821 ("cgroup: Avoid false cacheline sharing of read mostly rstat_cpu") happens to be the commit that breaks it even though it is not its fault. Fix it by moving the rcu_head structure up before the cgroup structure.
--- include/linux/cgroup-defs.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
include/linux/cgroup-defs.h +4 -4
@@ -562,6 +562,10 @@ struct cgroup_root {/* Unique id for this hierarchy. */ int hierarchy_id; +/* A list running through the active hierarchies */ +struct list_head root_list; +struct rcu_head rcu; +/* * The root cgroup. The containing cgroup_root will be destroyed on its * release. cgrp->ancestors[0] will be used overflowing into the
@@ -575,10 +579,6 @@ struct cgroup_root {/* Number of cgroups in the hierarchy, used only for /proc/cgroups */ atomic_t nr_cgrps; -/* A list running through the active hierarchies */ -struct list_head root_list; -struct rcu_head rcu; -/* Hierarchy-specific flags */ unsigned int flags;
Signature · 1 line
2.39.3
Quoted 25 lines · Waiman Long
Commit
d23b5c577715("cgroup: Make operations on the cgrouproot_listRCU safe") adds a newrcu_headto thecgroup_rootstructure andkvfree_rcu()for freeing thecgroup_root.The use of
kvfree_rcu(), however, has the limitation that the offset of thercu_headstructure within the larger data structure cannot exceed 4096 or the compilation will fail. By puttingrcu_headbelow the cgroup structure, any change to the cgroup structure that makes it larger has the risk of build failure. Commit77070eeb8821("cgroup: Avoid false cacheline sharing of read mostlyrstat_cpu") happens to be the commit that breaks it even though it is not its fault. Fix it by moving thercu_headstructure up before the cgroup structure.Fixes d23b5c577715 ("cgroup: Make operations on the cgroup root_list RCU safe")Signed-off-by Waiman Long <[email protected]>--- include/linux/cgroup-defs.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)include/linux/cgroup-defs.h +0
-0
include/linux/cgroup-defs.h struct cgroup_root { · line 568
Quoted 7 lines
include/linux/cgroup-defs.h +4
-0@@ -562,6 +562,10 @@ struct cgroup_root {/* Unique id for this hierarchy. */ int hierarchy_id; +/* A list running through the active hierarchies */ +struct list_head root_list; +struct rcu_head rcu; +
Perhaps the comment should mention the placement requirements, and maybe a pointer to wherever it is specified that the offset of struct rcu_head should not exceed 4096?
Quoted 28 lines · Yosry Ahmed
Quoted 27 lines · Waiman Long
Commit
d23b5c577715("cgroup: Make operations on the cgrouproot_listRCU safe") adds a newrcu_headto thecgroup_rootstructure andkvfree_rcu()for freeing thecgroup_root.The use of
kvfree_rcu(), however, has the limitation that the offset of thercu_headstructure within the larger data structure cannot exceed 4096 or the compilation will fail. By puttingrcu_headbelow the cgroup structure, any change to the cgroup structure that makes it larger has the risk of build failure. Commit77070eeb8821("cgroup: Avoid false cacheline sharing of read mostlyrstat_cpu") happens to be the commit that breaks it even though it is not its fault. Fix it by moving thercu_headstructure up before the cgroup structure.Fixes d23b5c577715 ("cgroup: Make operations on the cgroup root_list RCU safe")Signed-off-by Waiman Long <[email protected]>--- include/linux/cgroup-defs.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)include/linux/cgroup-defs.h +0
-0@@ -562,6 +562,10 @@ struct cgroup_root {/* Unique id for this hierarchy. */ int hierarchy_id;
Quoted 7 lines
include/linux/cgroup-defs.h struct cgroup_root { · line 568
Quoted 4 lines
include/linux/cgroup-defs.h +4
-0+/* A list running through the active hierarchies */ +struct list_head root_list; +struct rcu_head rcu; +Perhaps the comment should mention the placement requirements, and maybe a pointer to wherever it is specified that the offset of struct
rcu_headshould not exceed 4096?
Fair. I will update the patch description to give more details about that. It is new to me too before I got a compilation failure report in linux-next.
Cheers,
Longman
Quoted 1 line
Yafang Shao
Acked-byQuoted 14 lines · Waiman Long
Commit
d23b5c577715("cgroup: Make operations on the cgrouproot_listRCU safe") adds a newrcu_headto thecgroup_rootstructure andkvfree_rcu()for freeing thecgroup_root.The use of
kvfree_rcu(), however, has the limitation that the offset of thercu_headstructure within the larger data structure cannot exceed 4096 or the compilation will fail. By puttingrcu_headbelow the cgroup structure, any change to the cgroup structure that makes it larger has the risk of build failure. Commit77070eeb8821("cgroup: Avoid false cacheline sharing of read mostlyrstat_cpu") happens to be the commit that breaks it even though it is not its fault. Fix it by moving thercu_headstructure up before the cgroup structure.
Quoted 2 lines
Fixes d23b5c577715 ("cgroup: Make operations on the cgroup root_list RCU safe")Signed-off-by Waiman Long <[email protected]>
Quoted 33 lines
--- include/linux/cgroup-defs.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)include/linux/cgroup-defs.h +4
-5@@ -562,6 +562,10 @@ struct cgroup_root {/* Unique id for this hierarchy. */ int hierarchy_id; +/* A list running through the active hierarchies */ +struct list_head root_list; +struct rcu_head rcu; +/* * The root cgroup. The containing cgroup_root will be destroyed on its * release. cgrp->ancestors[0] will be used overflowing into the @@ -575,10 +579,6 @@ struct cgroup_root {/* Number of cgroups in the hierarchy, used only for /proc/cgroups */ atomic_t nr_cgrps; -/* A list running through the active hierarchies */ -struct list_head root_list; -struct rcu_head rcu; -/* Hierarchy-specific flags */ unsigned int flags; --2.39.3
Signature · 2 lines
Regards Yafang