From: Andrew Morton <akpm@linux-foundation.org>
To: Yosry Ahmed <yosryahmed@google.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>,
Michal Hocko <mhocko@kernel.org>,
Roman Gushchin <roman.gushchin@linux.dev>,
Shakeel Butt <shakeelb@google.com>,
Muchun Song <songmuchun@bytedance.com>,
Matthew Wilcox <willy@infradead.org>,
Vlastimil Babka <vbabka@suse.cz>,
David Hildenbrand <david@redhat.com>,
Miaohe Lin <linmiaohe@huawei.com>, NeilBrown <neilb@suse.de>,
Alistair Popple <apopple@nvidia.com>,
Suren Baghdasaryan <surenb@google.com>,
Peter Xu <peterx@redhat.com>,
linux-kernel@vger.kernel.org, cgroups@vger.kernel.org,
linux-mm@kvack.org
Subject: Re: [PATCH] mm: vmpressure: don't count userspace-induced reclaim as memory pressure
Date: Wed, 22 Jun 2022 17:16:24 -0700 [thread overview]
Message-ID: <20220622171624.fc7de8d0ab18a5cf663f8ab8@linux-foundation.org> (raw)
In-Reply-To: <20220623000530.1194226-1-yosryahmed@google.com>
On Thu, 23 Jun 2022 00:05:30 +0000 Yosry Ahmed <yosryahmed@google.com> wrote:
> Commit e22c6ed90aa9 ("mm: memcontrol: don't count limit-setting reclaim
> as memory pressure") made sure that memory reclaim that is induced by
> userspace (limit-setting, proactive reclaim, ..) is not counted as
> memory pressure for the purposes of psi.
>
> Instead of counting psi inside try_to_free_mem_cgroup_pages(), callers
> from try_charge() and reclaim_high() wrap the call to
> try_to_free_mem_cgroup_pages() with psi handlers.
>
> However, vmpressure is still counted in these cases where reclaim is
> directly induced by userspace. This patch makes sure vmpressure is not
> counted in those operations, in the same way as psi. Since vmpressure
> calls need to happen deeper within the reclaim path, the same approach
> could not be followed. Hence, a new "controlled" flag is added to struct
> scan_control to flag a reclaim operation that is controlled by
> userspace. This flag is set by limit-setting and proactive reclaim
> operations, and is used to count vmpressure correctly.
>
> To prevent future divergence of psi and vmpressure, commit e22c6ed90aa9
> ("mm: memcontrol: don't count limit-setting reclaim as memory pressure")
> is effectively reverted and the same flag is used to control psi as
> well.
I'll await reviewer input on this, but I can always do trivia!
> @@ -3502,6 +3497,8 @@ unsigned long mem_cgroup_soft_limit_reclaim(pg_data_t *pgdat, int order,
> static int mem_cgroup_force_empty(struct mem_cgroup *memcg)
> {
> int nr_retries = MAX_RECLAIM_RETRIES;
> + unsigned int reclaim_options = MEMCG_RECLAIM_CONTROLLED |
> + MEMCG_RECLAIM_MAY_SWAP;
If it doesn't fit, it's nicer to do
unsigned int reclaim_options;
...
reclaim_options = MEMCG_RECLAIM_CONTROLLED | MEMCG_RECLAIM_MAY_SWAP;
(several places)
> @@ -3751,6 +3757,7 @@ unsigned long try_to_free_pages(struct zonelist *zonelist, int order,
> .may_writepage = !laptop_mode,
> .may_unmap = 1,
> .may_swap = 1,
> + .controlled = 0,
> };
Let's just skip all these initializations to zero, let the compiler take
care of it.
> @@ -4095,6 +4112,7 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int highest_zoneidx)
> .gfp_mask = GFP_KERNEL,
> .order = order,
> .may_unmap = 1,
> + .controlled = 0,
> };
>
> set_task_reclaim_state(current, &sc.reclaim_state);
> @@ -4555,6 +4573,7 @@ unsigned long shrink_all_memory(unsigned long nr_to_reclaim)
> .may_unmap = 1,
> .may_swap = 1,
> .hibernation_mode = 1,
> + .controlled = 0,
> };
> struct zonelist *zonelist = node_zonelist(numa_node_id(), sc.gfp_mask);
> unsigned long nr_reclaimed;
> @@ -4707,6 +4726,7 @@ static int __node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask, unsigned in
> .may_unmap = !!(node_reclaim_mode & RECLAIM_UNMAP),
> .may_swap = 1,
> .reclaim_idx = gfp_zone(gfp_mask),
> + .controlled = 0,
> };
> unsigned long pflags;
next prev parent reply other threads:[~2022-06-23 0:16 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-23 0:05 [PATCH] mm: vmpressure: don't count userspace-induced reclaim as memory pressure Yosry Ahmed
2022-06-23 0:16 ` Andrew Morton [this message]
2022-06-23 0:24 ` Yosry Ahmed
2022-06-23 8:05 ` Michal Hocko
2022-06-23 8:35 ` Yosry Ahmed
2022-06-23 9:42 ` Michal Hocko
2022-06-23 16:22 ` Yosry Ahmed
2022-06-23 16:37 ` Michal Hocko
2022-06-23 16:42 ` Shakeel Butt
2022-06-23 16:49 ` Yosry Ahmed
2022-06-23 17:04 ` Michal Hocko
2022-06-23 17:26 ` Yosry Ahmed
2022-06-24 22:10 ` Suren Baghdasaryan
2022-06-24 22:13 ` Yosry Ahmed
2022-06-24 22:41 ` Suren Baghdasaryan
2022-06-27 8:25 ` Michal Hocko
2022-06-27 8:39 ` Yosry Ahmed
2022-06-27 9:20 ` Michal Hocko
2022-06-27 9:39 ` Yosry Ahmed
2022-06-27 12:31 ` Michal Hocko
2022-06-27 17:03 ` Yosry Ahmed
2022-06-30 1:07 ` Shakeel Butt
2022-06-30 2:08 ` Yosry Ahmed
2022-06-30 8:22 ` Michal Hocko
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=20220622171624.fc7de8d0ab18a5cf663f8ab8@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=apopple@nvidia.com \
--cc=cgroups@vger.kernel.org \
--cc=david@redhat.com \
--cc=hannes@cmpxchg.org \
--cc=linmiaohe@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=neilb@suse.de \
--cc=peterx@redhat.com \
--cc=roman.gushchin@linux.dev \
--cc=shakeelb@google.com \
--cc=songmuchun@bytedance.com \
--cc=surenb@google.com \
--cc=vbabka@suse.cz \
--cc=willy@infradead.org \
--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