From: Usama Arif <usama.arif@linux.dev>
To: Matthew Wilcox <willy@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
david@kernel.org, chrisl@kernel.org, kasong@tencent.com,
ljs@kernel.org, ziy@nvidia.com, linux-mm@kvack.org,
ying.huang@linux.alibaba.com, Baoquan He <baoquan.he@linux.dev>,
youngjun.park@lge.com, hannes@cmpxchg.org, riel@surriel.com,
shakeel.butt@linux.dev, alex@ghiti.fr, kas@kernel.org,
baohua@kernel.org, dev.jain@arm.com,
baolin.wang@linux.alibaba.com, Nico Pache <nico.pache@linux.dev>,
"Liam R. Howlett" <liam@infradead.org>,
ryan.roberts@arm.com, Vlastimil Babka <vbabka@kernel.org>,
lance.yang@linux.dev, linux-kernel@vger.kernel.org,
nphamcs@gmail.com, shikemeng@huaweicloud.com, yosry@kernel.org,
kernel-team@meta.com
Subject: Re: [PATCH v5 10/11] mm: install PMD swap entries on swap-out
Date: Fri, 24 Jul 2026 11:27:26 +0100 [thread overview]
Message-ID: <f6b71e13-0eb4-41bd-b2c5-30bf48a174f1@linux.dev> (raw)
In-Reply-To: <amJoe_iRHEaMdo9i@casper.infradead.org>
On 23/07/2026 20:16, Matthew Wilcox wrote:
> On Wed, Jul 22, 2026 at 08:19:41AM -0700, Usama Arif wrote:
>> +++ b/mm/rmap.c
>> @@ -2282,6 +2282,25 @@ static bool try_to_unmap_one(struct folio *folio, struct vm_area_struct *vma,
>> goto walk_abort;
>> }
>>
>> +#ifdef CONFIG_THP_SWAP
>> + /*
>> + * If the folio is in the swap cache and we're not
>> + * asked to split, install a PMD-level swap entry.
>> + */
>> + if (!(flags & TTU_SPLIT_HUGE_PMD) &&
>> + folio_test_anon(folio) &&
>> + folio_test_swapcache(folio)) {
>> + if (set_pmd_swap_entry(&pvmw, folio))
>> + goto walk_abort;
>> +
>> + add_mm_counter(mm, MM_ANONPAGES,
>> + -HPAGE_PMD_NR);
>> + add_mm_counter(mm, MM_SWAPENTS,
>> + HPAGE_PMD_NR);
>> + goto walk_done;
>> + }
>> +#endif
>> +
>> if (flags & TTU_SPLIT_HUGE_PMD) {
>> /*
>> * We temporarily have to drop the PTL and
>
> This makes me sad. It feels like we're bolting more complexity onto
> try_to_unmap() instead of removing TTU_SPLIT_HUGE_PMD entirely.
>
> Ideally we'd just cope with folios of whatever size (including
> PMD and PUD mapped folios) and only handle hugetlb weirdness when we
> absolutely have to. Similarly, we could split PUDs to PMDs and
> PMDs to PTEs when we need to, without the caller specifying
> TTU_SPLIT_anything.
>
> Is there a reason we can't do that?
I will prototype what the code would look like without TTU_SPLIT_HUGE_PMD
and get back to you on this. Looking at the code right now, I feel like I
would be shifting complexity, but let me try and do something about this.
next prev parent reply other threads:[~2026-07-24 10:27 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-22 15:19 [PATCH v5 00/11] mm: PMD-level swap entries for anonymous THPs Usama Arif
2026-07-22 15:19 ` [PATCH v5 01/11] mm: add PMD swap entry detection support Usama Arif
2026-07-24 6:10 ` Dev Jain
2026-07-24 10:00 ` Usama Arif
2026-07-22 15:19 ` [PATCH v5 02/11] mm: add PMD swap entry splitting support Usama Arif
2026-07-24 6:52 ` Dev Jain
2026-07-24 10:05 ` Usama Arif
2026-07-22 15:19 ` [PATCH v5 03/11] mm: handle PMD swap entries in fork path Usama Arif
2026-07-22 15:19 ` [PATCH v5 04/11] mm: zswap: add range lookup for large-folio swapin Usama Arif
2026-07-23 0:01 ` Yosry Ahmed
2026-07-23 12:45 ` Usama Arif
2026-07-23 16:42 ` Yosry Ahmed
2026-07-23 17:15 ` Nhat Pham
2026-07-24 9:59 ` Usama Arif
2026-07-22 15:19 ` [PATCH v5 05/11] mm: swap in PMD swap entries as whole THPs during swapoff Usama Arif
2026-07-22 15:19 ` [PATCH v5 06/11] mm: handle PMD swap entries in non-present PMD walkers Usama Arif
2026-07-22 15:19 ` [PATCH v5 07/11] mm: handle PMD swap entries in MADV_WILLNEED Usama Arif
2026-07-22 15:19 ` [PATCH v5 08/11] mm: handle PMD swap entries in UFFDIO_MOVE Usama Arif
2026-07-22 15:19 ` [PATCH v5 09/11] mm: handle PMD swap entry faults on swap-in Usama Arif
2026-07-22 15:19 ` [PATCH v5 10/11] mm: install PMD swap entries on swap-out Usama Arif
2026-07-23 19:16 ` Matthew Wilcox
2026-07-24 10:27 ` Usama Arif [this message]
2026-07-22 15:19 ` [PATCH v5 11/11] selftests/mm: add PMD swap entry tests Usama Arif
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=f6b71e13-0eb4-41bd-b2c5-30bf48a174f1@linux.dev \
--to=usama.arif@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=alex@ghiti.fr \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=baoquan.he@linux.dev \
--cc=chrisl@kernel.org \
--cc=david@kernel.org \
--cc=dev.jain@arm.com \
--cc=hannes@cmpxchg.org \
--cc=kas@kernel.org \
--cc=kasong@tencent.com \
--cc=kernel-team@meta.com \
--cc=lance.yang@linux.dev \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=nico.pache@linux.dev \
--cc=nphamcs@gmail.com \
--cc=riel@surriel.com \
--cc=ryan.roberts@arm.com \
--cc=shakeel.butt@linux.dev \
--cc=shikemeng@huaweicloud.com \
--cc=vbabka@kernel.org \
--cc=willy@infradead.org \
--cc=ying.huang@linux.alibaba.com \
--cc=yosry@kernel.org \
--cc=youngjun.park@lge.com \
--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