Skip to content

Commit b71e635

Browse files
committed
Merge tag 'cgroup-for-6.19-rc5-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup
Pull cgroup fix from Tejun Heo: - Fix -Wflex-array-member-not-at-end warnings in cgroup_root * tag 'cgroup-for-6.19-rc5-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup: cgroup: Eliminate cgrp_ancestor_storage in cgroup_root
2 parents 0f61b18 + ef56578 commit b71e635

2 files changed

Lines changed: 15 additions & 12 deletions

File tree

include/linux/cgroup-defs.h

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,13 @@ struct cgroup {
626626
#endif
627627

628628
/* All ancestors including self */
629-
struct cgroup *ancestors[];
629+
union {
630+
DECLARE_FLEX_ARRAY(struct cgroup *, ancestors);
631+
struct {
632+
struct cgroup *_root_ancestor;
633+
DECLARE_FLEX_ARRAY(struct cgroup *, _low_ancestors);
634+
};
635+
};
630636
};
631637

632638
/*
@@ -647,16 +653,6 @@ struct cgroup_root {
647653
struct list_head root_list;
648654
struct rcu_head rcu; /* Must be near the top */
649655

650-
/*
651-
* The root cgroup. The containing cgroup_root will be destroyed on its
652-
* release. cgrp->ancestors[0] will be used overflowing into the
653-
* following field. cgrp_ancestor_storage must immediately follow.
654-
*/
655-
struct cgroup cgrp;
656-
657-
/* must follow cgrp for cgrp->ancestors[0], see above */
658-
struct cgroup *cgrp_ancestor_storage;
659-
660656
/* Number of cgroups in the hierarchy, used only for /proc/cgroups */
661657
atomic_t nr_cgrps;
662658

@@ -668,6 +664,13 @@ struct cgroup_root {
668664

669665
/* The name for this hierarchy - may be empty */
670666
char name[MAX_CGROUP_ROOT_NAMELEN];
667+
668+
/*
669+
* The root cgroup. The containing cgroup_root will be destroyed on its
670+
* release. This must be embedded last due to flexible array at the end
671+
* of struct cgroup.
672+
*/
673+
struct cgroup cgrp;
671674
};
672675

673676
/*

kernel/cgroup/cgroup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5847,7 +5847,7 @@ static struct cgroup *cgroup_create(struct cgroup *parent, const char *name,
58475847
int ret;
58485848

58495849
/* allocate the cgroup and its ID, 0 is reserved for the root */
5850-
cgrp = kzalloc(struct_size(cgrp, ancestors, (level + 1)), GFP_KERNEL);
5850+
cgrp = kzalloc(struct_size(cgrp, _low_ancestors, level), GFP_KERNEL);
58515851
if (!cgrp)
58525852
return ERR_PTR(-ENOMEM);
58535853

0 commit comments

Comments
 (0)