[RHEL7,COMMIT] mm/memcontrol: warn about leaking memory on reparenting after 100 attempts

Submitted by Konstantin Khorenko on July 8, 2019, 9:23 a.m.

Details

Message ID 201907080923.x689Nh4j019961@finist-ce7.sw.ru
State New
Series "mm/memcontrol: don't reparent forever if counter leaked."
Headers show

Commit Message

Konstantin Khorenko July 8, 2019, 9:23 a.m.
The commit is pushed to "branch-rh7-3.10.0-957.21.3.vz7.106.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-957.21.3.vz7.106.5
------>
commit 73bad91e8fc2297423a1c886ec81079a11bc8c7a
Author: Konstantin Khorenko <khorenko@virtuozzo.com>
Date:   Mon Jul 1 15:58:15 2019 +0300

    mm/memcontrol: warn about leaking memory on reparenting after 100 attempts
    
    We know that 1 iteration could be not enough for complete reparenting of
    memcg, so warn in case we don't succeed in 100 iterations.
    If we ever see this warning, we better get rid of reparenting at all as
    it is planned in https://jira.sw.ru/browse/PSBM-94117.
    
    Fixes: e548e343c40b ("mm/memcontrol: don't reparent forever if
    counter leaked.")
    
    https://jira.sw.ru/browse/PSBM-96003
    https://pmc.acronis.com/browse/VSTOR-24241
    
    Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 mm/memcontrol.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index edc6bebc1f34..8ead76b97079 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -4291,7 +4291,7 @@  static void mem_cgroup_reparent_charges(struct mem_cgroup *memcg)
 {
 	int node, zid;
 	/* Protection from leaked memcg->memory counter. */
-	int reparent_attempts = 10;
+	int reparent_attempts = 99;
 
 	do {
 		/* This is for making all *used* pages to be on LRU. */
@@ -4325,6 +4325,14 @@  static void mem_cgroup_reparent_charges(struct mem_cgroup *memcg)
 		 */
 	} while ((page_counter_read(&memcg->memory) -
 		 page_counter_read(&memcg->kmem) > 0) && reparent_attempts--);
+
+	WARN_ONCE(!reparent_attempts,
+		  "memcg 0x%p leak suspected, performed %d iterations: "
+		  "memory=%lu, kmem=%lu",
+		  memcg,
+		  100,
+		  page_counter_read(&memcg->memory),
+		  page_counter_read(&memcg->kmem));
 }
 
 /*