Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+15 -12
+14 -11
include/linux/cgroup-defs.h
··· 626 626 #endif 627 627 628 628 /* 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 + }; 630 636 }; 631 637 632 638 /* ··· 653 647 struct list_head root_list; 654 648 struct rcu_head rcu; /* Must be near the top */ 655 649 656 - /* 657 - * The root cgroup. The containing cgroup_root will be destroyed on its 658 - * release. cgrp->ancestors[0] will be used overflowing into the 659 - * following field. cgrp_ancestor_storage must immediately follow. 660 - */ 661 - struct cgroup cgrp; 662 - 663 - /* must follow cgrp for cgrp->ancestors[0], see above */ 664 - struct cgroup *cgrp_ancestor_storage; 665 - 666 650 /* Number of cgroups in the hierarchy, used only for /proc/cgroups */ 667 651 atomic_t nr_cgrps; 668 652 ··· 664 668 665 669 /* The name for this hierarchy - may be empty */ 666 670 char name[MAX_CGROUP_ROOT_NAMELEN]; 671 + 672 + /* 673 + * The root cgroup. The containing cgroup_root will be destroyed on its 674 + * release. This must be embedded last due to flexible array at the end 675 + * of struct cgroup. 676 + */ 677 + struct cgroup cgrp; 667 678 }; 668 679 669 680 /*
+1 -1
kernel/cgroup/cgroup.c
··· 5847 5847 int ret; 5848 5848 5849 5849 /* 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); 5851 5851 if (!cgrp) 5852 5852 return ERR_PTR(-ENOMEM); 5853 5853