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

Configure Feed

Select the types of activity you want to include in your feed.

mm: memcontrol: split out __obj_cgroup_charge()

Move the page charge and remainder calculation into its own function. It
will make the slab stat refactor easier to follow.

Link: https://lkml.kernel.org/r/20260302195305.620713-4-hannes@cmpxchg.org
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Shakeel Butt <shakeel.butt@linux.dev>
Acked-by: Roman Gushchin <roman.gushchin@linux.dev>
Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
Reviewed-by: Hao Li <hao.li@linux.dev>
Cc: Johannes Weiner <jweiner@meta.com>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Muchun Song <muchun.song@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Johannes Weiner and committed by
Andrew Morton
edb6abd3 9d181e47

+16 -5
+16 -5
mm/memcontrol.c
··· 3156 3156 obj_cgroup_uncharge_pages(objcg, nr_pages); 3157 3157 } 3158 3158 3159 + static int __obj_cgroup_charge(struct obj_cgroup *objcg, gfp_t gfp, 3160 + size_t size, size_t *remainder) 3161 + { 3162 + size_t charge_size; 3163 + int ret; 3164 + 3165 + charge_size = PAGE_ALIGN(size); 3166 + ret = obj_cgroup_charge_pages(objcg, gfp, charge_size >> PAGE_SHIFT); 3167 + if (!ret) 3168 + *remainder = charge_size - size; 3169 + 3170 + return ret; 3171 + } 3172 + 3159 3173 static int obj_cgroup_charge_account(struct obj_cgroup *objcg, gfp_t gfp, size_t size, 3160 3174 struct pglist_data *pgdat, enum node_stat_item idx) 3161 3175 { 3162 - size_t charge_size, remainder; 3176 + size_t remainder; 3163 3177 int ret; 3164 3178 3165 3179 if (likely(consume_obj_stock(objcg, size, pgdat, idx))) ··· 3202 3188 * bytes is (sizeof(object) + PAGE_SIZE - 2) if there is no data 3203 3189 * race. 3204 3190 */ 3205 - charge_size = PAGE_ALIGN(size); 3206 - remainder = charge_size - size; 3207 - 3208 - ret = obj_cgroup_charge_pages(objcg, gfp, charge_size >> PAGE_SHIFT); 3191 + ret = __obj_cgroup_charge(objcg, gfp, size, &remainder); 3209 3192 if (!ret && (remainder || pgdat)) 3210 3193 refill_obj_stock(objcg, remainder, false, size, pgdat, idx); 3211 3194