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

Submitted by Andrey Ryabinin on Aug. 5, 2019, 10:22 a.m.

Details

Message ID 20190805102249.24098-1-aryabinin@virtuozzo.com
State New
Series "mm/memcg: use timeout instead of iteration count to determine leak."
Headers show

Commit Message

Andrey Ryabinin Aug. 5, 2019, 10:22 a.m.
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@virtuozzo.com>
---
 mm/memcontrol.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

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));
 }