From: Matthew Wilcox <willy@infradead.org>
To: Usama Arif <usama.arif@linux.dev>
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: Thu, 23 Jul 2026 20:16:11 +0100 [thread overview]
Message-ID: <amJoe_iRHEaMdo9i@casper.infradead.org> (raw)
In-Reply-To: <20260722152043.2273289-11-usama.arif@linux.dev>
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?
next prev parent reply other threads:[~2026-07-23 19:16 UTC|newest]
Thread overview: 17+ 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-22 15:19 ` [PATCH v5 02/11] mm: add PMD swap entry splitting support 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-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 [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=amJoe_iRHEaMdo9i@casper.infradead.org \
--to=willy@infradead.org \
--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=usama.arif@linux.dev \
--cc=vbabka@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.