Re: [PATCH -v4 1/4] mm/vmscan: fix anon-only reclaim evicting file pages when swappiness=max

From: Barry Song

Date: Mon Jul 27 2026 - 07:02:23 EST


On Mon, Jul 27, 2026 at 4:19 PM Michal Hocko <mhocko@xxxxxxxx> wrote:
>
> On Fri 24-07-26 11:34:32, Ridong wrote:
> > From: Ridong Chen <chenridong@xxxxxxxxxx>
> >
> > As Qi mentioned [1], when swappiness=max (SWAPPINESS_ANON_ONLY) is set,
> > the reclaim logic is expected to reclaim anonymous pages exclusively.
> > However, due to the current ordering of checks in get_scan_count(),
> > file pages may still be evicted if can_reclaim_anon_pages() returns
> > false, which contradicts the semantics of SWAPPINESS_ANON_ONLY.
>
> But if can_reclaim_anon_pages tells us that anonymous pages are not
> reclaimable then it makes no sense to try that, no? What do you expect
> to see? An OOM killer?

This is proactive reclaim rather than direct reclaim, and
SWAPPINESS_ANON_ONLY is only supported for proactive reclaim. It
therefore cannot invoke the OOM killer.

If I understand correctly, this is exactly the issue this patch is
trying to address. Instead of falling back to reclaiming file folios,
it returns "bash: echo: write error: Resource temporarily unavailable".

After (file cache is left intact):
# cat memory.stat
anon 200704
file 67178496
pgscan_proactive 0
# echo "64M swappiness=max" > memory.reclaim
-bash: echo: write error: Resource temporarily unavailable
# cat memory.stat
anon 208896
file 67178496 <- page cache untouched
pgsteal_proactive 0
pgscan_proactive 0

Ridong, please correct me if I am wrong.