[rh7] mm/memcg: don't overcharge ->memory counter when ->kmem limit reached.

Submitted by Andrey Ryabinin on March 5, 2018, 9:48 a.m.

Details

Message ID 20180305094840.18084-1-aryabinin@virtuozzo.com
State New
Series "mm/memcg: don't overcharge ->memory counter when ->kmem limit reached."
Headers show

Commit Message

Andrey Ryabinin March 5, 2018, 9:48 a.m.
If charging the ->kmem counter was unsuccessful we don't call refill_stock()
to return charges consumed in consume_stock() and go to slowpath which
charges ->memory, ->memsw counters again. Hence we overcharge these counters
which leads to lockups during cgroup destruction.

https://jira.sw.ru/browse/PSBM-82021
Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
---

 Patch is only for kernels that don't have memory.cache.limit_in_bytes,
 e.g. 3.10.0-693.11.6.vz7.40.4
 Basically, this patch is for RK only.

 mm/memcontrol.c | 1 +
 1 file changed, 1 insertion(+)

Patch hide | download patch | download mbox

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index a165a221e87b..49509530c2c0 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2790,6 +2790,7 @@  retry:
 			goto done;
 		if (!page_counter_try_charge(&memcg->kmem, nr_pages, &counter))
 			goto done;
+		refill_stock(memcg, nr_pages);
 	}
 
 	mem_over_limit = NULL;