From: Michal Hocko <mhocko@suse.com>
To: Mina Almasry <almasrymina@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Johannes Weiner <hannes@cmpxchg.org>,
Roman Gushchin <roman.gushchin@linux.dev>,
Shakeel Butt <shakeelb@google.com>,
Muchun Song <songmuchun@bytedance.com>,
Huang Ying <ying.huang@intel.com>,
Yang Shi <yang.shi@linux.alibaba.com>,
Yosry Ahmed <yosryahmed@google.com>,
weixugc@google.com, fvdl@google.com, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] [mm-unstable] mm: Fix memcg reclaim on memory tiered systems
Date: Tue, 6 Dec 2022 13:20:37 +0100 [thread overview]
Message-ID: <Y48zlaimOb/wr8qd@dhcp22.suse.cz> (raw)
In-Reply-To: <20221206023406.3182800-1-almasrymina@google.com>
On Mon 05-12-22 18:34:05, Mina Almasry wrote:
> commit 3f1509c57b1b ("Revert "mm/vmscan: never demote for memcg
> reclaim"") enabled demotion in memcg reclaim, which is the right thing
> to do, however, it introduced a regression in the behavior of
> try_to_free_mem_cgroup_pages().
>
> The callers of try_to_free_mem_cgroup_pages() expect it to attempt to
> reclaim - not demote - nr_pages from the cgroup. I.e. the memory usage
> of the cgroup should reduce by nr_pages. The callers expect
> try_to_free_mem_cgroup_pages() to also return the number of pages
> reclaimed, not demoted.
>
> However, what try_to_free_mem_cgroup_pages() actually does is it
> unconditionally counts demoted pages as reclaimed pages. So in practice
> when it is called it will often demote nr_pages and return the number of
> demoted pages to the caller. Demoted pages don't lower the memcg usage,
> and so try_to_free_mem_cgroup_pages() is not actually doing what the
> callers want it to do.
>
> Various things work suboptimally on memory tiered systems or don't work
> at all due to this:
>
> - memory.high enforcement likely doesn't work (it just demotes nr_pages
> instead of lowering the memcg usage by nr_pages).
> - try_charge_memcg() will keep retrying the charge while
> try_to_free_mem_cgroup_pages() is just demoting pages and not actually
> making any room for the charge.
This has been brought up during the review https://lore.kernel.org/all/YoYTEDD+c4GT0xYY@dhcp22.suse.cz/
> - memory.reclaim has a wonky interface. It advertises to the user it
> reclaims the provided amount but it will actually often demote that
> amount.
>
> There may be more effects to this issue.
>
> To fix these issues I propose shrink_folio_list() to only count pages
> demoted from inside of sc->nodemask to outside of sc->nodemask as
> 'reclaimed'.
Could you expand on why the node mask matters? From the charge point of
view it should be completely uninteresting as the charge remains.
I suspect we really need to change to reclaim metrics for memcg reclaim.
In the memory balancing reclaim we can indeed consider demotions as a
reclaim because the memory is freed in the end but for the memcg reclaim
we really should be counting discharges instead. No demotion/migration will
free up charges.
--
Michal Hocko
SUSE Labs
next prev parent reply other threads:[~2022-12-06 12:20 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-06 2:34 [PATCH v3] [mm-unstable] mm: Fix memcg reclaim on memory tiered systems Mina Almasry
2022-12-06 3:13 ` Huang, Ying
2022-12-06 4:15 ` Mina Almasry
2022-12-06 5:22 ` Huang, Ying
2022-12-06 12:20 ` Michal Hocko [this message]
2022-12-06 16:06 ` Mina Almasry
2022-12-06 19:55 ` Michal Hocko
2022-12-07 1:22 ` Huang, Ying
2022-12-07 1:55 ` Mina Almasry
2022-12-07 11:12 ` Michal Hocko
2022-12-07 21:43 ` Mina Almasry
2022-12-08 8:09 ` Michal Hocko
2022-12-08 9:00 ` Mina Almasry
2022-12-08 11:54 ` Michal Hocko
2022-12-09 0:59 ` Wei Xu
2022-12-09 8:08 ` Michal Hocko
2022-12-09 16:41 ` Wei Xu
2022-12-09 21:16 ` Michal Hocko
2022-12-09 21:39 ` Mina Almasry
2022-12-12 8:33 ` Michal Hocko
2022-12-10 8:01 ` Wei Xu
2022-12-12 8:36 ` Michal Hocko
2022-12-06 15:15 ` kernel test robot
2022-12-06 18:17 ` kernel test robot
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=Y48zlaimOb/wr8qd@dhcp22.suse.cz \
--to=mhocko@suse.com \
--cc=akpm@linux-foundation.org \
--cc=almasrymina@google.com \
--cc=fvdl@google.com \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=roman.gushchin@linux.dev \
--cc=shakeelb@google.com \
--cc=songmuchun@bytedance.com \
--cc=weixugc@google.com \
--cc=yang.shi@linux.alibaba.com \
--cc=ying.huang@intel.com \
--cc=yosryahmed@google.com \
/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).