| From: Shakeel Butt <shakeel.butt@linux.dev> |
| Subject: memcg: multi-memcg percpu charge cache - fix |
| Date: Wed, 23 Apr 2025 15:41:18 -0700 |
| |
| Add BUILD_BUG_ON() for MEMCG_CHARGE_BATCH |
| |
| Link: https://lkml.kernel.org/r/rlsgeosg3j7v5nihhbxxxbv3xfy4ejvigihj7lkkbt3n6imyne@2apxx2jm2e57 |
| Signed-off-by: Shakeel Butt <shakeel.butt@linux.dev> |
| Cc: Eric Dumaze <edumazet@google.com> |
| Cc: Jakub Kacinski <kuba@kernel.org> |
| Cc: Johannes Weiner <hannes@cmpxchg.org> |
| Cc: Michal Hocko <mhocko@kernel.org> |
| Cc: Muchun Song <muchun.song@linux.dev> |
| Cc: Roman Gushchin <roman.gushchin@linux.dev> |
| Cc: Soheil Hassas Yeganeh <soheil@google.com> |
| Cc: Vlastimil Babka <vbabka@suse.cz> |
| Cc: Hugh Dickins <hughd@google.com> |
| Cc: Michal Hocko <mhocko@suse.com> |
| Signed-off-by: Andrew Morton <akpm@linux-foundation.org> |
| --- |
| |
| mm/memcontrol.c | 7 +++++++ |
| 1 file changed, 7 insertions(+) |
| |
| --- a/mm/memcontrol.c~memcg-multi-memcg-percpu-charge-cache-fix |
| +++ a/mm/memcontrol.c |
| @@ -1907,6 +1907,13 @@ static void refill_stock(struct mem_cgro |
| 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 || |
| _ |