[rh7] mm/memcontrol: warn about leaking memory on reparanting

Submitted by Konstantin Khorenko on July 1, 2019, 1:53 p.m.

Details

Message ID 20190701135338.4178-1-khorenko@virtuozzo.com
State New
Series "mm/memcontrol: don't reparent forever if counter leaked."
Headers show

Commit Message

Konstantin Khorenko July 1, 2019, 1:53 p.m.
We expect reparent of memory cgroup is done in only 1 cycle iteration
and would like to make sure our expectations are correct,
so let's add a warning in case several iterations required to reparent a
memcg.

Fixes: e548e343c40b ("mm/memcontrol: don't reparent forever if counter
leaked.")

https://pmc.acronis.com/browse/VSTOR-24241

Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 mm/memcontrol.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Patch hide | download patch | download mbox

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index edc6bebc1f34..e123323f1044 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -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 != 10,
+		  "memcg 0x%p leak suspected, performed %d iterations: "
+		  "memory=%lu, kmem=%lu",
+		  memcg,
+		  10 - reparent_attempts,
+		  page_counter_read(&memcg->memory),
+		  page_counter_read(&memcg->kmem));
 }
 
 /*

Comments

Andrey Ryabinin July 1, 2019, 2:22 p.m.
On 7/1/19 4:53 PM, Konstantin Khorenko wrote:
> We expect reparent of memory cgroup is done in only 1 cycle iteration
> and would like to make sure our expectations are correct,
> so let's add a warning in case several iterations required to reparent a
> memcg.
> 
> Fixes: e548e343c40b ("mm/memcontrol: don't reparent forever if counter
> leaked.")
> 
> https://pmc.acronis.com/browse/VSTOR-24241
> 
> Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
> ---

Acked-by: Andrey Ryabinin <aryabinin@virtuozzo.com>