[Devel] [PATCH RHEL7 COMMIT] mm/memcg: uncharge ->memory ->memsw if try charge of ->kmem fails

Konstantin Khorenko khorenko at virtuozzo.com
Fri Mar 31 08:13:16 PDT 2017

The commit is pushed to "branch-rh7-3.10.0-514.10.2.vz7.29.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-514.10.2.vz7.29.9
commit dd43dcd9f96f9b9c0c90d60ec0ba5a5c445e2a06
Author: Andrey Ryabinin <aryabinin at virtuozzo.com>
Date:   Fri Mar 31 19:13:15 2017 +0400

    mm/memcg: uncharge ->memory ->memsw if try charge of ->kmem fails
    if page_counter_try_charge(&memcg->kmem, nr_pages) fails we bail out
    from memcg_charge_kmem() too early without uncharging back ->memory and ->memsw
    Fixes: 355ccab81bc9 ("mm: memcontrol: fix race between kmem uncharge and charge reparenting")
    Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
 mm/memcontrol.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 74faf07..e028861 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -3043,9 +3043,6 @@ int memcg_charge_kmem(struct mem_cgroup *memcg, gfp_t gfp,
 	 * uncharged before res.
 	ret = page_counter_try_charge(&memcg->kmem, nr_pages, &counter);
-	if (ret < 0)
-		return ret;
 	if (ret) {
 		page_counter_uncharge(&memcg->memory, nr_pages);
 		if (do_swap_account)

More information about the Devel mailing list