On Wed, Dec 11, 2024 at 04:32:50AM +0000, Matthew Wilcox (Oracle) wrote: [...] > +int obj_cgroup_charge_vmalloc(struct obj_cgroup **objcgp, > + unsigned int nr_pages, gfp_t gfp) > +{ > + struct obj_cgroup *objcg; > + int err; > + > + if (mem_cgroup_disabled() || !(gfp & __GFP_ACCOUNT)) > + return 0; > + > + objcg = current_obj_cgroup(); > + if (!objcg) > + return 0; > + > + err = obj_cgroup_charge_pages(objcg, gfp, nr_pages); > + if (err) > + return err; > + obj_cgroup_get(objcg); > + mod_memcg_state(obj_cgroup_memcg(objcg), MEMCG_VMALLOC, nr_pages); obj_cgroup_memcg() needs to be within rcu. See MEMCG_PERCPU_B as an example. > + *objcgp = objcg; > + > + return 0; > +} > + > +/** > + * obj_cgroup_uncharge_vmalloc - Uncharge vmalloc memory > + * @objcg: The object cgroup > + * @nr_pages: Number of pages > + */ > +void obj_cgroup_uncharge_vmalloc(struct obj_cgroup *objcg, > + unsigned int nr_pages) > +{ > + if (!objcg) > + return; > + mod_memcg_state(objcg->memcg, MEMCG_VMALLOC, 0L - nr_pages); Please use obj_cgroup_memcg() above instead of objcg->memcg and within rcu lock. Overall the patch looks good.