[Devel] [PATCH RHEL7 COMMIT] memcg: force css_put after last kmem uncharge in uncharge_batch

Vasily Averin vvs at virtuozzo.com
Tue Feb 23 10:54:00 MSK 2021


The commit is pushed to "branch-rh7-3.10.0-1160.11.1.vz7.172.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1160.11.1.vz7.172.15
------>
commit 5e2fb27d528e9d41fb465f8fad23dc01feaea53e
Author: Vasily Averin <vvs at virtuozzo.com>
Date:   Tue Feb 23 10:54:00 2021 +0300

    memcg: force css_put after last kmem uncharge in uncharge_batch
    
    This patch calls css_put() after last kmem uncharge in uncharge_batch.
    and releases a reference taken in memcg_deactivate_kmem.
    
    https://bugs.openvz.org/browse/OVZ-7250
    Signed-off-by: Vasily Averin <vvs at virtuozzo.com>
---
 mm/memcontrol.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 24e3bd7..3c2538d 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -7875,10 +7875,11 @@ static void uncharge_batch(struct mem_cgroup *memcg, unsigned long pgpgout,
 			   unsigned long nr_shmem, struct page *dummy_page)
 {
 	unsigned long flags;
+	u64 kmem = 1;
 
 	if (!mem_cgroup_is_root(memcg)) {
 		if (nr_kmem)
-			page_counter_uncharge(&memcg->kmem, nr_kmem);
+			kmem = page_counter_uncharge(&memcg->kmem, nr_kmem);
 		if (nr_mem + nr_kmem)
 			page_counter_uncharge(&memcg->memory, nr_mem + nr_kmem);
 		if (nr_memsw + nr_kmem)
@@ -7898,6 +7899,8 @@ static void uncharge_batch(struct mem_cgroup *memcg, unsigned long pgpgout,
 	__this_cpu_add(memcg->stat->nr_page_events, nr_anon + nr_file);
 	memcg_check_events(memcg, dummy_page);
 	local_irq_restore(flags);
+	if (kmem == 0)
+		memcg_kmem_release_css(memcg);
 }
 
 static void uncharge_list(struct list_head *page_list)


More information about the Devel mailing list