Re: [PATCH] memcg: multi-memcg percpu charge cache

Shakeel Butt
2025-04-23T23:14:41Z

Hi Andrew,

Can you please squash the following patch in this one?

From: Shakeel Butt <shakeel.butt@linux.dev>
Date: Wed, 23 Apr 2025 15:41:18 -0700
Subject: [PATCH] memcg: multi-memcg percpu charge cache - fix

Add BUILD_BUG_ON() for MEMCG_CHARGE_BATCH

Signed-off-by: Shakeel Butt <shakeel.butt@linux.dev>
---
mm/memcontrol.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 23894e60c3c0..80ff002b0259 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1909,6 +1909,13 @@ static void refill_stock(struct mem_cgroup *memcg, unsigned int nr_pages)
bool evict = true;
int i;

+ /*
+ * For now limit MEMCG_CHARGE_BATCH to 127 and less. In future if we
+ * decide to increase it more than 127 then we will need more careful
+ * handling of nr_pages[] in struct memcg_stock_pcp.
+ */
+ BUILD_BUG_ON(MEMCG_CHARGE_BATCH > S8_MAX);
+
VM_WARN_ON_ONCE(mem_cgroup_is_root(memcg));

if (nr_pages > MEMCG_CHARGE_BATCH ||
--
2.47.1