Re: [PATCH] mm: Consider non-anon swap cache folios in folio_expected_ref_count()
From: Baolin Wang
Date: Thu Dec 18 2025 - 20:42:23 EST
On 2025/12/19 08:21, Wei Yang wrote:
On Wed, Dec 17, 2025 at 02:04:16AM +0100, David Hildenbrand (Red Hat) wrote:
I am not very familiar with the memory hot-(un)plug or swapping code, so
I am not 100% certain if this patch actually solves the root of the
problem. I believe the issue is from shmem folios, in which case I believe
this patch is correct. However, I couldn't think of an easy way to confirm
that the affected folios were from shmem. I guess it could be possible that
the root cause could be from some bug where some anonymous pages do not
return true to folio_test_anon(). I don't think that's the case, but
figured the MM maintainers would have a better idea of what's going on.
I am not sure about if shmem in swapcache causes the issue, since
the above setup does not involve shmem. +Baolin and Hugh for some insight.
We might just push out another unrelated shmem page to swap as we create
memory pressure in the system I think.
One trivial question: currently we only put anon/shmem folio in swapcache,
right?
AFAICT, Yes (note a special case for anonymous folios: lazyfree anonymous folios will be directly freed instead of being swapped out).