[rh7] mm/memcg: Fix reparent warning again.

Submitted by Andrey Ryabinin on July 17, 2019, 2:17 p.m.

Details

Message ID 20190717141713.1861-1-aryabinin@virtuozzo.com
State New
Series "mm/memcg: Fix reparent warning again."
Headers show

Commit Message

Andrey Ryabinin July 17, 2019, 2:17 p.m.
In case of unsuccessful reparenting reparent_attempts counter
will be -1, so intended warning will not trigger. Check diff
of ->memory - ->kmem counters instead. It's correct and easier
to read.

Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
---
 mm/memcontrol.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 3fabad9d409c..acbe83875cdc 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -4379,7 +4379,8 @@  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,
+	WARN_ONCE((page_counter_read(&memcg->memory) -
+			page_counter_read(&memcg->kmem) > 0),
 		  "memcg 0x%p leak suspected, performed %d iterations: "
 		  "memory=%lu, kmem=%lu",
 		  memcg,