diff options
| author | Johannes Weiner <hannes@cmpxchg.org> | 2026-03-02 14:50:17 -0500 |
|---|---|---|
| committer | Andrew Morton <akpm@linux-foundation.org> | 2026-04-05 13:53:16 -0700 |
| commit | 4665aa7e6523c418d6178ef7e23a4159c72b9d3a (patch) | |
| tree | 184e4f635906186ae3fbcd0a7fe9058eafacc48a | |
| parent | edb6abd31bff0746c687cf5af9ecacefaa90e9cb (diff) | |
mm: memcontrol: use __account_obj_stock() in the !locked path
Make __account_obj_stock() usable for the case where the local trylock
failed. Then switch refill_obj_stock() over to it.
This consolidates the mod_objcg_mlstate() call into one place and will
make the next patch easier to follow.
Link: https://lkml.kernel.org/r/20260302195305.620713-5-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>
| -rw-r--r-- | mm/memcontrol.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index c01da86e6a2e..15f552a85a52 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -2969,6 +2969,9 @@ static void __account_obj_stock(struct obj_cgroup *objcg, { int *bytes; + if (!stock) + goto direct; + /* * Save vmstat data in stock and skip vmstat array update unless * accumulating over a page of vmstat data or when pgdat changes. @@ -3008,6 +3011,7 @@ static void __account_obj_stock(struct obj_cgroup *objcg, nr = 0; } } +direct: if (nr) mod_objcg_mlstate(objcg, pgdat, idx, nr); } @@ -3124,7 +3128,7 @@ static void refill_obj_stock(struct obj_cgroup *objcg, unsigned int nr_bytes, stock = trylock_stock(); if (!stock) { if (pgdat) - mod_objcg_mlstate(objcg, pgdat, idx, nr_acct); + __account_obj_stock(objcg, NULL, nr_acct, pgdat, idx); nr_pages = nr_bytes >> PAGE_SHIFT; nr_bytes = nr_bytes & (PAGE_SIZE - 1); atomic_add(nr_bytes, &objcg->nr_charged_bytes); |
