The commit is pushed to "branch-rh7-3.10.0-1160.90.1.vz7.200.x-ovz" and will 
appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1160.90.1.vz7.200.5
------>
commit 256342087b70239fab7af00bae82ab3a8e3cb312
Author: Pavel Tikhomirov <ptikhomi...@virtuozzo.com>
Date:   Fri Jul 7 17:41:37 2023 +0800

    mm/memcontrol: do not put css when putting page to swap or moving swap page
    
    When commit [1] was ported we should not have removed css_get in
    mem_cgroup_swapout, as when we put page from memory to swap we need to
    have refcount on css in case we will want to put it back. In vz7 we
    don't have commit [2] which in mainstream preceeds [1], that's why in
    mainstream in [1] they removed css_get as we don't need to take second
    reference for the same page. So fix for [1] is bringing back css_get.
    
    When commit [3] was ported we should have removed this css_get as now we
    take mem_cgroup_id_get instead. But we should not have added css_put
    there as it would be an excess put (remove get + put is equivalent of
    double put). In mainstream [3] is preceeded by [2], so they need to put
    css reference of page put to swap and replace it with id reference. So
    fix for [1] + [2] is removal of css_put.
    
    When commit [4] was ported in __mem_cgroup_clear_mc we should have
    removed css_put-s as now after [3] we don't have css reference for
    swapped pages, and there is nothing to put when moving to other cgroup.
    
    And now I understand why they do css_put(from)->css_put(to) replacement
    in original mainstream patch, it's because they also don't have refcount
    from page which is already in swap after [3], but obviousely when they
    charge pages to destination cgroup they have reference from them to css
    and as they are swap they need to put this reference.
    
    https://jira.vzint.dev/browse/PSBM-148702
    
    Fixes: d0f735e5df66 ("ms/mm: memcontrol: uncharge pages on swapout") [1]
           e8ea14cc6ead ("mm: memcontrol: take a css reference for each charged 
page") [2]
    Fixes: 9dcef96ce3e2 ("ms/mm: memcontrol: fix cgroup creation failure after 
many small jobs") [3]
    Fixes: 11870ae0f7b6 ("ms/mm: memcontrol: fix memcg id ref counter on swap 
charge move") [4]
    
    Signed-off-by: Pavel Tikhomirov <ptikhomi...@virtuozzo.com>
---
 mm/memcontrol.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index b2911329852f..3a5e89b913bd 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -7413,7 +7413,6 @@ static void __mem_cgroup_clear_mc(void)
 {
        struct mem_cgroup *from = mc.from;
        struct mem_cgroup *to = mc.to;
-       int i;
 
        /* we must uncharge all the leftover precharges from mc.to */
        if (mc.precharge) {
@@ -7436,9 +7435,6 @@ static void __mem_cgroup_clear_mc(void)
 
                mem_cgroup_id_put_many(mc.from, mc.moved_swap);
 
-               for (i = 0; i < mc.moved_swap; i++)
-                       css_put(&mc.from->css);
-
                if (!mem_cgroup_is_root(mc.to)) {
                        /*
                         * we charged both to->memory and to->memsw, so we
@@ -7837,9 +7833,6 @@ void mem_cgroup_swapout(struct page *page, swp_entry_t 
entry)
 
        mem_cgroup_charge_statistics(memcg, page, -1);
        memcg_check_events(memcg, page);
-
-       if (!mem_cgroup_is_root(memcg))
-               css_put(&memcg->css);
 }
 
 /**
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to