From: Wandun Chen <chenwandun1@gmail.com>
To: david@kernel.org, akpm@linux-foundation.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Cc: ljs@kernel.org, liam@infradead.org, vbabka@kernel.org,
rppt@kernel.org, surenb@google.com, mhocko@suse.com,
ziy@nvidia.com, matthew.brost@intel.com, joshua.hahnjy@gmail.com,
byungchul@sk.com, gourry@gourry.net,
ying.huang@linux.alibaba.com, apopple@nvidia.com
Subject: [PATCH 1/3] mm: factor out common softleaf offset PTE batch scanning
Date: Fri, 20 Nov 2026 11:29:47 +0800 [thread overview]
Message-ID: <20261120032949.2036731-2-chenwandun1@gmail.com> (raw)
In-Reply-To: <20261120032949.2036731-1-chenwandun1@gmail.com>
From: Wandun Chen <chenwandun@lixiang.com>
Extract the consecutive-offset scan from swap_pte_batch() into
__softleaf_pte_batch() to prepare for migration PTE batching in a
subsequent patch.
No functional change.
Signed-off-by: Wandun Chen <chenwandun@lixiang.com>
---
mm/internal.h | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/mm/internal.h b/mm/internal.h
index 3a1643afedc0..9f78c12882cb 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -512,29 +512,26 @@ static inline pte_t pte_next_swp_offset(pte_t pte)
}
/**
- * swap_pte_batch - detect a PTE batch for a set of contiguous swap entries
+ * __softleaf_pte_batch - detect a PTE batch for contiguous softleaf entries
* @start_ptep: Page table pointer for the first entry.
* @max_nr: The maximum number of table entries to consider.
* @pte: Page table entry for the first entry.
*
- * Detect a batch of contiguous swap entries: consecutive (non-present) PTEs
- * containing swap entries all with consecutive offsets and targeting the same
- * swap type, all with matching swp pte bits.
+ * Detect a batch of contiguous swap or migration entries: consecutive
+ * (non-present) PTEs with consecutive offsets/PFNs and the same entry type,
+ * all with matching swp pte bits.
*
* max_nr must be at least one and must be limited by the caller so scanning
* cannot exceed a single page table.
*
* Return: the number of table entries in the batch.
*/
-static inline int swap_pte_batch(pte_t *start_ptep, int max_nr, pte_t pte)
+static inline int __softleaf_pte_batch(pte_t *start_ptep, int max_nr, pte_t pte)
{
pte_t expected_pte = pte_next_swp_offset(pte);
const pte_t *end_ptep = start_ptep + max_nr;
pte_t *ptep = start_ptep + 1;
- VM_WARN_ON(max_nr < 1);
- VM_WARN_ON(!softleaf_is_swap(softleaf_from_pte(pte)));
-
while (ptep < end_ptep) {
pte = ptep_get(ptep);
@@ -546,6 +543,15 @@ static inline int swap_pte_batch(pte_t *start_ptep, int max_nr, pte_t pte)
return ptep - start_ptep;
}
+
+static inline int swap_pte_batch(pte_t *start_ptep, int max_nr, pte_t pte)
+{
+ VM_WARN_ON(max_nr < 1);
+ VM_WARN_ON(!softleaf_is_swap(softleaf_from_pte(pte)));
+
+ return __softleaf_pte_batch(start_ptep, max_nr, pte);
+}
+
#endif /* CONFIG_MMU */
void __acct_reclaim_writeback(pg_data_t *pgdat, struct folio *folio,
--
2.43.0
next prev parent reply other threads:[~2026-11-20 3:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 3:29 [PATCH 0/3] mm/migrate: batch PTE restoration for large folios Wandun Chen
2026-11-20 3:29 ` Wandun Chen [this message]
2026-11-20 15:34 ` [PATCH 1/3] mm: factor out common softleaf offset PTE batch scanning Lorenzo Stoakes (ARM)
2026-11-20 3:29 ` [PATCH 2/3] mm/migrate: batch PTE restoration in remove_migration_pte() Wandun Chen
2026-11-20 15:22 ` Lorenzo Stoakes (ARM)
2026-11-20 3:29 ` [PATCH 3/3] mm/migrate: batch PTE restoration for device-private folios Wandun Chen
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=20261120032949.2036731-2-chenwandun1@gmail.com \
--to=chenwandun1@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=apopple@nvidia.com \
--cc=byungchul@sk.com \
--cc=david@kernel.org \
--cc=gourry@gourry.net \
--cc=joshua.hahnjy@gmail.com \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=matthew.brost@intel.com \
--cc=mhocko@suse.com \
--cc=rppt@kernel.org \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
--cc=ying.huang@linux.alibaba.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