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.
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
---
mm/memcontrol.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 32c09b4d520f..4f12b75743d4 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -3227,6 +3227,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.
@@ -3266,6 +3269,7 @@ static void __account_obj_stock(struct obj_cgroup *objcg,
nr = 0;
}
}
+direct:
if (nr)
mod_objcg_mlstate(objcg, pgdat, idx, nr);
}
@@ -3382,7 +3386,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);
--
2.53.0