From: Alex Shi <alex.shi@linux.alibaba.com>
To: linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
hannes@cmpxchg.org, hughd@google.com, linux-mm@kvack.org,
mhocko@suse.com, mm-commits@vger.kernel.org, shakeelb@google.com,
stable@vger.kernel.org, torvalds@linux-foundation.org
Subject: Re: [patch 06/15] mm/memcg: fix refcount error while moving and swapping
Date: Fri, 24 Jul 2020 21:41:07 +0800 [thread overview]
Message-ID: <e22a1ccb-6b5a-d448-e3ff-3045e93e4f09@linux.alibaba.com> (raw)
In-Reply-To: <20200724041524.eAqB5zPs6%akpm@linux-foundation.org>
在 2020/7/24 下午12:15, Andrew Morton 写道:
> From: Hugh Dickins <hughd@google.com>
> Subject: mm/memcg: fix refcount error while moving and swapping
>
> It was hard to keep a test running, moving tasks between memcgs with
> move_charge_at_immigrate, while swapping: mem_cgroup_id_get_many()'s
> refcount is discovered to be 0 (supposedly impossible), so it is then
> forced to REFCOUNT_SATURATED, and after thousands of warnings in quick
> succession, the test is at last put out of misery by being OOM killed.
>
> This is because of the way moved_swap accounting was saved up until the
> task move gets completed in __mem_cgroup_clear_mc(), deferred from when
> mem_cgroup_move_swap_account() actually exchanged old and new ids.
> Concurrent activity can free up swap quicker than the task is scanned,
> bringing id refcount down 0 (which should only be possible when
> offlining).
>
> Just skip that optimization: do that part of the accounting immediately.
>
> Link: http://lkml.kernel.org/r/alpine.LSU.2.11.2007071431050.4726@eggly.anvils
> Fixes: 615d66c37c75 ("mm: memcontrol: fix memcg id ref counter on swap charge move")
> Signed-off-by: Hugh Dickins <hughd@google.com>
> Cc: Johannes Weiner <hannes@cmpxchg.org>
> Cc: Alex Shi <alex.shi@linux.alibaba.com>
> Cc: Shakeel Butt <shakeelb@google.com>
> Cc: Michal Hocko <mhocko@suse.com>
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> ---
Reviewed-by: Alex Shi <alex.shi@linux.alibaba.com>
>
> mm/memcontrol.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> --- a/mm/memcontrol.c~mm-memcg-fix-refcount-error-while-moving-and-swapping
> +++ a/mm/memcontrol.c
> @@ -5669,7 +5669,6 @@ static void __mem_cgroup_clear_mc(void)
> if (!mem_cgroup_is_root(mc.to))
> page_counter_uncharge(&mc.to->memory, mc.moved_swap);
>
> - mem_cgroup_id_get_many(mc.to, mc.moved_swap);
> css_put_many(&mc.to->css, mc.moved_swap);
>
> mc.moved_swap = 0;
> @@ -5860,7 +5859,8 @@ put: /* get_mctgt_type() gets the page
> ent = target.ent;
> if (!mem_cgroup_move_swap_account(ent, mc.from, mc.to)) {
> mc.precharge--;
> - /* we fixup refcnts and charges later. */
> + mem_cgroup_id_get_many(mc.to, 1);
> + /* we fixup other refcnts and charges later. */
> mc.moved_swap++;
> }
> break;
> _
>
next prev parent reply other threads:[~2020-07-24 13:41 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20200723211432.b31831a0df3bc2cbdae31b40@linux-foundation.org>
2020-07-24 4:15 ` [patch 02/15] mm/mmap.c: close race between munmap() and expand_upwards()/downwards() Andrew Morton
2020-07-24 4:15 ` [patch 03/15] vfs/xattr: mm/shmem: kernfs: release simple xattr entry in a right way Andrew Morton
2020-07-24 4:15 ` [patch 06/15] mm/memcg: fix refcount error while moving and swapping Andrew Morton
2020-07-24 13:41 ` Alex Shi [this message]
2020-07-24 4:15 ` [patch 07/15] mm: memcg/slab: fix memory leak at non-root kmem_cache destroy Andrew Morton
2020-07-24 4:15 ` [patch 08/15] mm/hugetlb: avoid hardcoding while checking if cma is enabled Andrew Morton
2020-07-24 4:15 ` [patch 09/15] khugepaged: fix null-pointer dereference due to race Andrew Morton
2020-07-24 4:15 ` [patch 13/15] io-mapping: indicate mapping failure Andrew Morton
2020-07-31 20:57 ` + mm-hugetlb-fix-calculation-of-adjust_range_if_pmd_sharing_possible.patch added to -mm tree Andrew Morton
2020-07-31 21:02 ` + cma-dont-quit-at-first-error-when-activating-reserved-areas.patch " Andrew Morton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e22a1ccb-6b5a-d448-e3ff-3045e93e4f09@linux.alibaba.com \
--to=alex.shi@linux.alibaba.com \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=mm-commits@vger.kernel.org \
--cc=shakeelb@google.com \
--cc=stable@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).