]> www.infradead.org Git - users/jedix/linux-maple.git/commit
mm: vmscan: move set_task_reclaim_state() after global_reclaim()
authorYosry Ahmed <yosryahmed@google.com>
Tue, 4 Apr 2023 00:13:51 +0000 (00:13 +0000)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 5 Apr 2023 23:02:54 +0000 (16:02 -0700)
commitb7ff0f629df76aac132ea408349b97f5d4d93a4e
tree526d25cac068214e30b3dc493c52ec51c2e9d41e
parent0de4f7e8f3927dda9f96e4f3433dead06c67a620
mm: vmscan: move set_task_reclaim_state() after global_reclaim()

Patch series "Ignore non-LRU-based reclaim in memcg reclaim", v4.

Upon running some proactive reclaim tests using memory.reclaim, we noticed
some tests flaking where writing to memory.reclaim would be successful
even though we did not reclaim the requested amount fully.  Looking
further into it, I discovered that *sometimes* we over-report the number
of reclaimed pages in memcg reclaim.

Reclaimed pages through other means than LRU-based reclaim are tracked
through reclaim_state in struct scan_control, which is stashed in current
task_struct.  These pages are added to the number of reclaimed pages
through LRUs.  For memcg reclaim, these pages generally cannot be linked
to the memcg under reclaim and can cause an overestimated count of
reclaimed pages.  This short series tries to address that.

Patches 1-2 are just refactoring, they add helpers that wrap some
operations on current->reclaim_state, and rename
reclaim_state->reclaimed_slab to reclaim_state->reclaimed.

Patch 3 ignores pages reclaimed outside of LRU reclaim in memcg reclaim.
The pages are uncharged anyway, so even if we end up under-reporting
reclaimed pages we will still succeed in making progress during charging.

Do not be fooled by the diffstat - the core of this series is patch 3,
which has one line of code change.  All the rest is refactoring and one
huge comment.

This patch (of 3):

set_task_reclaim_state() is currently defined in mm/vmscan.c above an
#ifdef CONFIG_MEMCG block where global_reclaim() is defined.  We are about
to add some more helpers that operate on reclaim_state, and will need to
use global_reclaim().  Move set_task_reclaim_state() after the #ifdef
CONFIG_MEMCG block containing the definition of global_reclaim() to keep
helpers operating on reclaim_state together.

Link: https://lkml.kernel.org/r/20230404001353.468224-1-yosryahmed@google.com
Link: https://lkml.kernel.org/r/20230404001353.468224-2-yosryahmed@google.com
Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Darrick J. Wong <djwong@kernel.org>
Cc: Dave Chinner <david@fromorbit.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: NeilBrown <neilb@suse.de>
Cc: Peter Xu <peterx@redhat.com>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Shakeel Butt <shakeelb@google.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Yu Zhao <yuzhao@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/vmscan.c