Patch "mm: memcontrol: fix memcg id ref counter on swap charge move" has been added to the 4.6-stable tree
Subsystems (3)
This is a note to let you know that I've just added the patch titled
mm: memcontrol: fix memcg id ref counter on swap charge move
to the 4.6-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
mm-memcontrol-fix-memcg-id-ref-counter-on-swap-charge-move.patch
and it can be found in the queue-4.6 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
615d66c37c755c49ce022c9e5ac0875d27d2603dMon Sep 17 00:00:00 2001
From: Vladimir Davydov <[email protected]>
Date: Thu, 11 Aug 2016 15:33:03 -0700
Subject: mm: memcontrol: fix memcg id ref counter on swap charge move
From: Vladimir Davydov <[email protected]>
commit 615d66c37c755c49ce022c9e5ac0875d27d2603d upstream.
Since commit 73f576c04b94 ("mm: memcontrol: fix cgroup creation failure after many small jobs") swap entries do not pin memcg->css.refcnt directly. Instead, they pin memcg->id.ref. So we should adjust the reference counters accordingly when moving swap charges between cgroups.
--- mm/memcontrol.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-)
mm/memcontrol.c +18 -6
@@ -4064,9 +4064,9 @@ static struct cftype mem_cgroup_legacy_fstatic DEFINE_IDR (mem_cgroup_idr); -static void mem_cgroup_id_get (struct mem_cgroup *memcg) +static void mem_cgroup_id_get_many (struct mem_cgroup *memcg,unsigned int n) { -atomic_inc (&memcg->id.ref); +atomic_add (n, &memcg->id.ref); }static struct mem_cgroup *mem_cgroup_id_get_online (struct mem_cgroup *memcg)
@@ -4087,9 +4087,9 @@ static struct mem_cgroup *mem_cgroup_id_return memcg; } -static void mem_cgroup_id_put (struct mem_cgroup *memcg) +static void mem_cgroup_id_put_many (struct mem_cgroup *memcg,unsigned int n) { -if (atomic_dec_and_test (&memcg->id.ref)) { +if (atomic_sub_and_test (n, &memcg->id.ref)) {idr_remove (&mem_cgroup_idr, memcg->id.id); memcg->id.id =0 ;
@@ -4098,6 +4098,16 @@ static void mem_cgroup_id_put(struct mem } } +static inline void mem_cgroup_id_get (struct mem_cgroup *memcg) +{ +mem_cgroup_id_get_many (memcg,1 ); +} + +static inline void mem_cgroup_id_put (struct mem_cgroup *memcg) +{ +mem_cgroup_id_put_many (memcg,1 ); +} +/** * mem_cgroup_from_id - look up a memcg from a memcg id * @id: the memcg id to look up
@@ -4734,6 +4744,8 @@ static void __mem_cgroup_clear_mc(void)if (!mem_cgroup_is_root (mc.from))page_counter_uncharge (&mc.from->memsw, mc.moved_swap); +mem_cgroup_id_put_many (mc.from, mc.moved_swap); +/* * we charged both to->memory and to->memsw, so we * should uncharge to->memory.
@@ -4741,9 +4753,9 @@ static void __mem_cgroup_clear_mc(void)if (!mem_cgroup_is_root (mc.to))page_counter_uncharge (&mc.to->memory, mc.moved_swap); -css_put_many (&mc.from->css, mc.moved_swap); +mem_cgroup_id_get_many (mc.to, mc.moved_swap); +css_put_many (&mc.to->css, mc.moved_swap); -/* we've already done css_get(mc.to) */ mc.moved_swap =0 ; }memcg_oom_recover (from);
Patches currently in stable-queue which might be from [email protected] are
queue-4.6/mm-memcontrol-fix-memcg-id-ref-counter-on-swap-charge-move.patch queue-4.6/mm-memcontrol-fix-swap-counter-leak-on-swapout-from-offline-cgroup.patch