On Tue, 2024-08-20 at 18:53 -0700, Haitao Huang wrote: > /** > * misc_cg_alloc() - Allocate misc cgroup. > * @parent_css: Parent cgroup. > @@ -451,20 +519,25 @@ static struct cftype misc_cg_files[] = { > static struct cgroup_subsys_state * > misc_cg_alloc(struct cgroup_subsys_state *parent_css) > { > - enum misc_res_type i; > - struct misc_cg *cg; > + struct misc_cg *parent_cg, *cg; > + int ret; > > if (!parent_css) { > + parent_cg = &root_cg; > cg = &root_cg; > } else { > cg = kzalloc(sizeof(*cg), GFP_KERNEL); > if (!cg) > return ERR_PTR(-ENOMEM); > + parent_cg = css_misc(parent_css); > } > > - for (i = 0; i < MISC_CG_RES_TYPES; i++) { > - WRITE_ONCE(cg->res[i].max, MAX_NUM); > - atomic64_set(&cg->res[i].usage, 0); > + ret = _misc_cg_res_alloc(cg); > + if (ret) { > + if (likely(parent_css)) > + kfree(cg); > + > + return ERR_PTR(ret); > } > > return &cg->css; What's the purpose of @parent_cg? # make kernel/cgroup/ W=1 ... kernel/cgroup/misc.c: In function ‘misc_cg_alloc’: kernel/cgroup/misc.c:522:25: warning: variable ‘parent_cg’ set but not used [- Wunused-but-set-variable] 522 | struct misc_cg *parent_cg, *cg; | ^~~~~~~~~