Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Usama Arif <usama.arif@linux.dev>
To: 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
Cc: ying.huang@linux.alibaba.com, Baoquan He <baoquan.he@linux.dev>,
	willy@infradead.org, 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, npache@redhat.com,
	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,
	kernel-team@meta.com, Usama Arif <usama.arif@linux.dev>
Subject: [PATCH 0/6] mm: preparatory patches for PMD level swap entries
Date: Tue, 30 Jun 2026 09:34:37 -0700	[thread overview]
Message-ID: <20260630164143.1595669-1-usama.arif@linux.dev> (raw)

This is the preparatory part of the PMD page table swapin work.  The
full PMD swap entry series has been split into two parts:

  1. this preparatory series, which contains the first 6 patches. Zi [1]
     and Lance [2] suggested to separate this out from the core series.
  2. the PMD swap entry core series, which depends on this one. I will
     send this once the preparatory series is merged in mm-new as v3
     as the combined is currently at v2 [1].
     I have not marked this prep series as v3, as its not really adding
     support for PMD swap entries.

This series does not introduce PMD swap entries and does not install any
new page-table entry type.  It only cleans up existing PMD softleaf
helpers and call sites so the follow-up PMD swap entry series can be
smaller and easier to review.

It should be safe to merge independently.  The patches are either helper
additions, refactors of existing open-coded logic, defensive checks that
preserve current migration/device-private behavior, or a mechanical
rename of the PMD softleaf Kconfig gate.  The follow-up series depends
on these helpers, but this series does not depend on the follow-up
series.

Patch breakdown:

  1. mm: add softleaf_to_pmd() and convert existing callers
     Add the PMD counterpart to softleaf_to_pte() and convert existing
     swp_entry_to_pmd() users that are constructing PMD softleaf
     entries.

  2. mm: extract mm_prepare_for_swap_entries() helper
     Hoist the "register mm with swapoff" double-checked-locking
     pattern out of try_to_unmap_one() and copy_nonpresent_pte() so
     future PMD-level users do not need another open-coded copy.

  3. fs/proc: use softleaf_has_pfn() in pagemap PMD walker
     Avoid assuming every non-present PMD softleaf entry encodes a PFN.
     Existing migration/device-private behavior is preserved.

  4. mm/huge_memory: move softleaf_to_folio() inside migration branch
     Keep the folio lookup in change_non_present_huge_pmd() scoped to
     the migration-entry branch that actually needs it.

  5. mm/migrate_device: move softleaf_to_folio() inside device-private
     branch
     Apply the same ordering cleanup to migrate_vma_collect_pmd(): only
     derive a folio after confirming the PMD entry is device-private.

  6. mm: rename ARCH_ENABLE_THP_MIGRATION to ARCH_SUPPORTS_PMD_SOFTLEAF
     Rename the architecture gate to describe what it actually enables:
     PMD softleaf entries.  Migration remains the only current user in
     this series; the follow-up series adds PMD swap entries.

The patches are based on akpm/mm-new as of 29 June
(git hash: 15654b0268cd65b4e673510c0377774e61b86397)

[1] https://lore.kernel.org/all/6E99CC4E-A026-4DE3-8A5A-34216771F521@nvidia.com/
[2] https://lore.kernel.org/all/b08cafbb-a4b7-4609-84ae-dbb2cfcfc8be@linux.dev/#t 
[3] https://lore.kernel.org/all/20260602142537.198755-1-usama.arif@linux.dev/

Usama Arif (6):
  mm: add softleaf_to_pmd() and convert existing callers
  mm: extract mm_prepare_for_swap_entries() helper
  fs/proc: use softleaf_has_pfn() in pagemap PMD walker
  mm/huge_memory: move softleaf_to_folio() inside migration branch
  mm/migrate_device: move softleaf_to_folio() inside device-private
    branch
  mm: rename ARCH_ENABLE_THP_MIGRATION to ARCH_SUPPORTS_PMD_SOFTLEAF

 arch/arm64/Kconfig                           |  2 +-
 arch/arm64/include/asm/pgtable.h             |  4 +--
 arch/loongarch/Kconfig                       |  2 +-
 arch/powerpc/include/asm/book3s/64/pgtable.h |  2 +-
 arch/powerpc/platforms/Kconfig.cputype       |  2 +-
 arch/riscv/Kconfig                           |  2 +-
 arch/riscv/include/asm/pgtable.h             |  8 +++---
 arch/s390/Kconfig                            |  2 +-
 arch/s390/include/asm/pgtable.h              |  2 +-
 arch/x86/Kconfig                             |  2 +-
 arch/x86/include/asm/pgtable.h               |  2 +-
 fs/proc/task_mmu.c                           |  3 ++-
 include/linux/huge_mm.h                      |  2 +-
 include/linux/leafops.h                      | 28 +++++++++++++++++---
 include/linux/pgtable.h                      |  2 +-
 include/linux/swapops.h                      |  6 ++---
 mm/Kconfig                                   |  2 +-
 mm/debug_vm_pgtable.c                        | 12 ++++-----
 mm/hmm.c                                     |  4 +--
 mm/huge_memory.c                             | 17 ++++++------
 mm/internal.h                                | 13 +++++++++
 mm/memory.c                                  |  9 +------
 mm/migrate.c                                 |  4 +--
 mm/migrate_device.c                          | 19 +++++++------
 mm/rmap.c                                    |  9 ++-----
 25 files changed, 93 insertions(+), 67 deletions(-)

-- 
2.53.0-Meta



             reply	other threads:[~2026-06-30 16:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-30 16:34 Usama Arif [this message]
2026-06-30 16:34 ` [PATCH 1/6] mm: add softleaf_to_pmd() and convert existing callers Usama Arif
2026-06-30 16:34 ` [PATCH 2/6] mm: extract mm_prepare_for_swap_entries() helper Usama Arif
2026-06-30 16:34 ` [PATCH 3/6] fs/proc: use softleaf_has_pfn() in pagemap PMD walker Usama Arif
2026-06-30 16:34 ` [PATCH 4/6] mm/huge_memory: move softleaf_to_folio() inside migration branch Usama Arif
2026-06-30 16:34 ` [PATCH 5/6] mm/migrate_device: move softleaf_to_folio() inside device-private branch Usama Arif
2026-06-30 16:34 ` [PATCH 6/6] mm: rename ARCH_ENABLE_THP_MIGRATION to ARCH_SUPPORTS_PMD_SOFTLEAF Usama Arif
2026-06-30 19:50 ` [PATCH 0/6] mm: preparatory patches for PMD level swap entries Andrew Morton

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=20260630164143.1595669-1-usama.arif@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=npache@redhat.com \
    --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=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