[RH7] memcg: improvements for "memcg leak due to missing css_put on last kmem uncharge"

Submitted by Vasily Averin on Feb. 25, 2021, 5:58 a.m.

Details

Message ID d0a33145-48f9-56f2-d58e-131acb5beae5@virtuozzo.com
State New
Series "memcg: improvements for "memcg leak due to missing css_put on last kmem uncharge""
Headers show

Commit Message

Vasily Averin Feb. 25, 2021, 5:58 a.m.
- inlined memcg_kmem_release_css() to improve function reference in css_stack
- removed css_get/css_put extra calls in refill_stock/drain_stock

https://bugs.openvz.org/browse/OVZ-7250
Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
---
 mm/memcontrol.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 3c2538d..ca426134 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -439,7 +439,7 @@  enum {
 	KMEM_ACCOUNTED_DEAD, /* dead memcg with pending kmem charges */
 };
 
-static void memcg_kmem_release_css(struct mem_cgroup *memcg);
+static inline void memcg_kmem_release_css(struct mem_cgroup *memcg);
 
 static struct mem_cgroup_per_node *
 mem_cgroup_nodeinfo(struct mem_cgroup *memcg, int nid)
@@ -2948,7 +2948,6 @@  static void drain_stock(struct memcg_stock_pcp *stock)
 		stock->kmem_nr_pages = 0;
 		stock->cache_nr_pages = 0;
 	}
-	css_put(&old->css);
 	if (kmem == 0)
 		memcg_kmem_release_css(old);
 	stock->cached = NULL;
@@ -2987,7 +2986,6 @@  static void refill_stock(struct mem_cgroup *memcg, unsigned int nr_pages,
 
 	if (stock->cached != memcg) { /* reset if necessary */
 		drain_stock(stock);
-		css_get(&memcg->css);
 		stock->cached = memcg;
 	}
 
@@ -3622,7 +3620,7 @@  void memcg_uncharge_kmem(struct mem_cgroup *memcg,
 		memcg_kmem_release_css(memcg);
 }
 
-static void memcg_kmem_release_css(struct mem_cgroup *memcg)
+static inline void memcg_kmem_release_css(struct mem_cgroup *memcg)
 {
 	/*
 	 * Releases a reference taken in memcg_deactivate_kmem in case