From: Wei Yang <richard.weiyang@gmail.com>
To: Kairui Song <ryncsn@gmail.com>
Cc: Wei Yang <richard.weiyang@gmail.com>,
"David Hildenbrand (Red Hat)" <david@kernel.org>,
Zi Yan <ziy@nvidia.com>, Bijan Tabatabai <bijan311@gmail.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
akpm@linux-foundation.org, lorenzo.stoakes@oracle.com,
Liam.Howlett@oracle.com, vbabka@suse.cz, rppt@kernel.org,
surenb@google.com, mhocko@suse.com, shivankg@amd.com,
Baolin Wang <baolin.wang@linux.alibaba.com>,
Hugh Dickins <hughd@google.com>, Chris Li <chrisl@kernel.org>
Subject: Re: [PATCH] mm: Consider non-anon swap cache folios in folio_expected_ref_count()
Date: Sat, 20 Dec 2025 00:47:24 +0000 [thread overview]
Message-ID: <20251220004724.b4akrh6ljreoyg5j@master> (raw)
In-Reply-To: <CAMgjq7DU0U3RVw4cuFeNSSmTWnOmvRF9bQn5oaeZUOvXTVTdYQ@mail.gmail.com>
On Fri, Dec 19, 2025 at 10:35:05AM +0800, Kairui Song wrote:
>On Fri, Dec 19, 2025 at 8:21 AM Wei Yang <richard.weiyang@gmail.com> 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?
>
>For swapout, yes, the entry point to move a folio to swap space is
>folio_alloc_swap, only anon and shmem can do that (vmscan.c ->
>folio_test_anon && folio_test_swapbacked, and shmem.c).
>
Thanks for this information.
>Swapin is a bit different because of readahead, readahead folios are
>not marked as anon / shmem (folio->mapping) until used, they do belong
>to anon / shmem though, but we don't add them to the mapping until
>that mapping does a swap cache lookup and use the cached folio.
>
I saw this. So there is some folio which is in swapcache but no sure is
anon/shmem yet.
>Also maybe worth mentioning, swap cache lookup convention requires the
>caller to lock the folio and double check folio still matches the swap
>entry before use (folio_matches_swap_entry), folios there are unstable
>and could no longer be a valid swap cache folio unless locked.
Thanks for this notice, will pay attention to this.
--
Wei Yang
Help you, Help me
next prev parent reply other threads:[~2025-12-20 0:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-16 20:07 Bijan Tabatabai
2025-12-17 0:07 ` David Hildenbrand (Red Hat)
2025-12-17 0:34 ` Zi Yan
2025-12-17 1:04 ` David Hildenbrand (Red Hat)
2025-12-17 3:09 ` Baolin Wang
2025-12-19 0:21 ` Wei Yang
2025-12-19 1:42 ` Baolin Wang
2025-12-19 2:35 ` Kairui Song
2025-12-20 0:47 ` Wei Yang [this message]
2025-12-17 6:04 ` Kairui Song
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=20251220004724.b4akrh6ljreoyg5j@master \
--to=richard.weiyang@gmail.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=bijan311@gmail.com \
--cc=chrisl@kernel.org \
--cc=david@kernel.org \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=mhocko@suse.com \
--cc=rppt@kernel.org \
--cc=ryncsn@gmail.com \
--cc=shivankg@amd.com \
--cc=surenb@google.com \
--cc=vbabka@suse.cz \
--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