[Devel] [PATCH rh7] mm/memcg: Charge memsw as well in __GFP_NOFAIL case

Konstantin Khorenko khorenko at virtuozzo.com
Thu May 5 14:49:11 MSK 2022


From: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>

RedHat has ported ms commit 10d53c748bc9 ("memcg: ratify and consolidate
over-charge handling") but forgotten to charge memsw in __GFP_NOFAIL
case, so fix this.

Fixes: 8a9bfaf5d824 ("rh7: import RHEL7 kernel-3.10.0-1160.62.1.el7")
https://jira.sw.ru/browse/PSBM-139519

Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
 mm/memcontrol.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 649e4cc37f24..fdc5245e48a9 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -3336,6 +3336,8 @@ static int try_charge(struct mem_cgroup *memcg, gfp_t gfp_mask, bool kmem_charge
 		 * charging allocations that carry the __GFP_NOFAIL flag.
 		 */
 		page_counter_charge(&memcg->memory, batch);
+		if (do_swap_account)
+			page_counter_charge(&memcg->memsw, batch);
 	} else
 		mem_over_limit = mem_cgroup_from_counter(counter, memory);
 
-- 
2.24.3



More information about the Devel mailing list