From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Wed, 3 Aug 2016 15:34:45 +0300 From: Vladimir Davydov To: Andrew Morton CC: , Johannes Weiner , Michal Hocko , , Subject: Re: [PATCH v3 1/3] mm: memcontrol: fix swap counter leak on swapout from offline cgroup Message-ID: <20160803123445.GJ13263@esperanza> References: <5336daa5c9a32e776067773d9da655d2dc126491.1470219853.git.vdavydov@virtuozzo.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <5336daa5c9a32e776067773d9da655d2dc126491.1470219853.git.vdavydov@virtuozzo.com> Sender: owner-linux-mm@kvack.org List-ID: On Wed, Aug 03, 2016 at 01:35:06PM +0300, Vladimir Davydov wrote: > An offline memory cgroup might have anonymous memory or shmem left > charged to it and no swap. Since only swap entries pin the id of an > offline cgroup, such a cgroup will have no id and so an attempt to > swapout its anon/shmem will not store memory cgroup info in the swap > cgroup map. As a result, memcg->swap or memcg->memsw will never get > uncharged from it and any of its ascendants. > > Fix this by always charging swapout to the first ancestor cgroup that > hasn't released its id yet. > > [hannes@cmpxchg.org: add comment to mem_cgroup_swapout] > Fixes: 73f576c04b941 ("mm: memcontrol: fix cgroup creation failure after many small jobs") > Signed-off-by: Vladimir Davydov > Acked-by: Johannes Weiner > Acked-by: Michal Hocko > Cc: [3.19+] Andrew, could you please fold this in? diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 1c0aa59fd333..8c8e68becee9 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -4044,7 +4044,7 @@ static struct mem_cgroup *mem_cgroup_id_get_online(struct mem_cgroup *memcg) * The root cgroup cannot be destroyed, so it's refcount must * always be >= 1. */ - if (memcg == root_mem_cgroup) { + if (WARN_ON_ONCE(memcg == root_mem_cgroup)) { VM_BUG_ON(1); break; } -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org