[Devel] [PATCH rh7] mm/memcg: use timeout instead of iteration count to determine leak.

Andrey Ryabinin aryabinin at virtuozzo.com
Mon Aug 5 13:22:49 MSK 2019


100 reparent attempts seems too low, and hits too often.
Try to use 2min timeout instead.

https://jira.sw.ru/browse/PSBM-96533
Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
---
 mm/memcontrol.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index acbe83875cdc..884f1596bb24 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -4344,7 +4344,7 @@ static void mem_cgroup_reparent_charges(struct mem_cgroup *memcg)
 {
 	int node, zid;
 	/* Protection from leaked memcg->memory counter. */
-	int reparent_attempts = 99;
+	unsigned long timeout = jiffies + HZ*120;
 
 	do {
 		/* This is for making all *used* pages to be on LRU. */
@@ -4377,14 +4377,13 @@ static void mem_cgroup_reparent_charges(struct mem_cgroup *memcg)
 		 * charge before adding to the LRU.
 		 */
 	} while ((page_counter_read(&memcg->memory) -
-		 page_counter_read(&memcg->kmem) > 0) && reparent_attempts--);
+		 page_counter_read(&memcg->kmem) > 0) && time_after(jiffies, timeout));
 
 	WARN_ONCE((page_counter_read(&memcg->memory) -
 			page_counter_read(&memcg->kmem) > 0),
-		  "memcg 0x%p leak suspected, performed %d iterations: "
+		  "memcg 0x%p leak suspected: "
 		  "memory=%lu, kmem=%lu",
 		  memcg,
-		  100,
 		  page_counter_read(&memcg->memory),
 		  page_counter_read(&memcg->kmem));
 }
-- 
2.21.0



More information about the Devel mailing list