From: Shakeel Butt <shakeel.butt@linux.dev>
To: sashiko-reviews@lists.linux.dev
Cc: Andrew Morton <akpm@linux-foundation.org>,
Johannes Weiner <hannes@cmpxchg.org>,
David Hildenbrand <david@kernel.org>,
Michal Hocko <mhocko@kernel.org>,
Roman Gushchin <roman.gushchin@linux.dev>,
Muchun Song <muchun.song@linux.dev>,
Qi Zheng <qi.zheng@linux.dev>, Zi Yan <ziy@nvidia.com>,
Lorenzo Stoakes <ljs@kernel.org>,
Vlastimil Babka <vbabka@kernel.org>,
Kairui Song <kasong@tencent.com>, Nhat Pham <nphamcs@gmail.com>,
Usama Arif <usama.arif@linux.dev>,
Hugh Dickins <hughd@google.com>,
Meta kernel team <kernel-team@meta.com>,
linux-mm@kvack.org
Subject: Re: [PATCH 4/4] mm/vmscan: don't give swap to an anon folio that nothing maps
Date: Mon, 30 Nov 2026 11:13:28 -0800 [thread overview]
Message-ID: <aw3KE5dDAz1lkMcx@linux.dev> (raw)
In-Reply-To: <sashiko-outbox-241883@kernel.org>
On Mon, Nov 30, 2026 at 06:54:30PM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential
> issues to consider:
> - [Medium] mm/vmscan: unadjusted sc->nr_scanned in shrink_folio_list()
> after folio split
> - [Medium] mm/vmscan: redundant shrink_folio_list() retry in MGLRU
> evict_folios()
> --
>
> commit adf73a464f11b1c23175eec0f7510cddfa8d6dc1
> Author: Shakeel Butt <shakeel.butt@linux.dev>
>
> mm/vmscan: don't give swap to an anon folio that nothing maps
>
> This commit skips swap allocation in shrink_folio_list() for unmapped
> anonymous folios that are not in the swap cache, and frees newly allocated
> swap slots if the folio becomes an orphan during the unmap step.
>
> > diff --git a/mm/vmscan.c b/mm/vmscan.c
> > index 99cb209797b4b..ddc1584d06eda 100644
> > --- a/mm/vmscan.c
> > +++ b/mm/vmscan.c
>
> [ ... ]
>
> > @@ -1331,6 +1332,19 @@ static unsigned int shrink_folio_list(struct list_head *folio_list,
> > split_folio_to_list(folio, folio_list))
> > goto activate_locked;
> > }
> > + /*
> > + * If nothing maps the folio, its last mapping went
> > + * away, usually because its process exited, and no page
> > + * table or shmem entry refers to it. It is freed when
> > + * the last reference goes away. Giving it swap would
> > + * only leave it in the swap cache if something else
> > + * still holds a reference. KSM can map a KSM folio
> > + * again; a later pass swaps it out then. This comes
> > + * after the split above, so it also skips an unmapped
> > + * first page of a partially mapped folio.
> > + */
> > + if (!folio_mapped(folio))
> > + goto keep_locked;
>
> [Severity: Medium]
> When split_folio_to_list() splits a partially mapped large folio and its
> first page is unmapped, does jumping to keep_locked overcount
> sc->nr_scanned by nr_pages - 1?
Yes, thanks. The new check runs after the partial-map split, but it
jumps over the fixup that every other exit after a split goes through,
so the tail pages get counted twice. Will fix in v2 (after additional reviews
are in).
[...]
>
> [Severity: Medium]
> Under MGLRU, does jumping to keep_locked before folio_mark_dirty() cause
> evict_folios() to run a second shrink_folio_list() pass on every unmapped
> non-swapcache anonymous folio?
Yeah this need to be handled better. Will do something about in v2.
prev parent reply other threads:[~2026-11-30 19:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 18:27 [PATCH 0/4] mm, memcg: stop orphaned swap cache from using up memcg IDs Shakeel Butt
2026-11-30 18:27 ` [PATCH 1/4] mm/swap: free orphaned swap cache instead of leaving it to reclaim Shakeel Butt
2026-11-30 18:27 ` [PATCH 2/4] mm: free swap cache that migration or a split leaves unmapped Shakeel Butt
2026-11-30 18:27 ` [PATCH 3/4] mm/memory: free the swap cache folio that a KSM copy leaves behind Shakeel Butt
2026-11-30 18:27 ` [PATCH 4/4] mm/vmscan: don't give swap to an anon folio that nothing maps Shakeel Butt
2026-11-30 18:54 ` sashiko-bot
2026-11-30 19:13 ` Shakeel Butt [this message]
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=aw3KE5dDAz1lkMcx@linux.dev \
--to=shakeel.butt@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=hughd@google.com \
--cc=kasong@tencent.com \
--cc=kernel-team@meta.com \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@kernel.org \
--cc=muchun.song@linux.dev \
--cc=nphamcs@gmail.com \
--cc=qi.zheng@linux.dev \
--cc=roman.gushchin@linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
--cc=usama.arif@linux.dev \
--cc=vbabka@kernel.org \
--cc=ziy@nvidia.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