Skip to contentSkip to conversation

mm-introduce-is_pmd_order-helper.patch removed from -mm tree

merged mm-stable Andrew Morton 1 participant 1 message Mar 29

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: mm: introduce is_pmd_order helper
has been removed from the -mm tree. Its filename was
mm-introduce-is_pmd_order-helper.patch

This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Nico Pache <[email protected]>
Subject: mm: introduce is_pmd_order helper
Date: Wed, 25 Mar 2026 05:40:19 -0600

In order to add mTHP support to khugepaged, we will often be checking if a given order is (or is not) a PMD order. Some places in the kernel already use this check, so lets create a simple helper function to keep the code clean and readable.

Cc Alistair Popple <[email protected]>
Cc Andrea Arcangeli <[email protected]>
Cc Anshuman Khandual <[email protected]>
Cc Brendan Jackman <[email protected]>
Cc Byungchul Park <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc David Rientjes <[email protected]>
Cc Gregory Price <[email protected]>
Cc "Huang, Ying" <[email protected]>
Cc Hugh Dickins <[email protected]>
Cc Jan Kara <[email protected]>
Cc Jann Horn <[email protected]>
Cc Johannes Weiner <[email protected]>
Cc Jonathan Corbet <[email protected]>
Cc Joshua Hahn <[email protected]>
Cc Kefeng Wang <[email protected]>
Cc Liam Howlett <[email protected]>
Cc Lorenzo Stoakes (Oracle) <[email protected]>
Cc "Masami Hiramatsu (Google)" <[email protected]>
Cc Mathieu Desnoyers <[email protected]>
Cc Matthew Brost <[email protected]>
Cc Matthew Wilcox (Oracle) <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Mike Rapoport <[email protected]>
Cc Nanyong Sun <[email protected]>
Cc Peter Xu <[email protected]>
Cc Rafael Aquini <[email protected]>
Cc Rakie Kim <[email protected]>
Cc Randy Dunlap <[email protected]>
Cc Ryan Roberts <[email protected]>
Cc Shivank Garg <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Suren Baghdasaryan <[email protected]>
Cc Takashi Iwai (SUSE) <[email protected]>
Cc Thomas Hellström <[email protected]>
Cc Usama Arif <[email protected]>
Cc Vishal Moola (Oracle) <[email protected]>
Cc Vlastimil Babka <[email protected]>
Cc Will Deacon <[email protected]>
Cc Yang Shi <[email protected]>
Cc Zach O'Keefe <[email protected]>

---

 include/linux/huge_mm.h |    5 +++++
 mm/huge_memory.c        |    2 +-
 mm/khugepaged.c         |    6 +++---
 mm/memory.c             |    2 +-
 mm/mempolicy.c          |    2 +-
 mm/page_alloc.c         |    4 ++--
 mm/shmem.c              |    3 +--
 7 files changed, 14 insertions(+), 10 deletions(-)
include/linux/huge_mm.h renamed from include/linux/huge_mm.h~mm-introduce-is_pmd_order-helper +5 -0
@@ -771,6 +771,11 @@ static inline bool pmd_is_huge(pmd_t pmd
 }
 #endif /* CONFIG_TRANSPARENT_HUGEPAGE */
 
+static inline bool is_pmd_order(unsigned int order)
+{
+	return order == HPAGE_PMD_ORDER;
+}
+
 static inline int split_folio_to_list_to_order(struct folio *folio,
 		struct list_head *list, int new_order)
 {
mm/huge_memory.c renamed from mm/huge_memory.c~mm-introduce-is_pmd_order-helper +1 -1
@@ -4159,7 +4159,7 @@ out_unlock:
 		i_mmap_unlock_read(mapping);
 out:
 	xas_destroy(&xas);
-	if (old_order == HPAGE_PMD_ORDER)
+	if (is_pmd_order(old_order))
 		count_vm_event(!ret ? THP_SPLIT_PAGE : THP_SPLIT_PAGE_FAILED);
 	count_mthp_stat(old_order, !ret ? MTHP_STAT_SPLIT : MTHP_STAT_SPLIT_FAILED);
 	return ret;
mm/khugepaged.c renamed from mm/khugepaged.c~mm-introduce-is_pmd_order-helper +3 -3
@@ -1540,7 +1540,7 @@ static enum scan_result try_collapse_pte
 	if (IS_ERR(folio))
 		return SCAN_PAGE_NULL;
 
-	if (folio_order(folio) != HPAGE_PMD_ORDER) {
+	if (!is_pmd_order(folio_order(folio))) {
 		result = SCAN_PAGE_COMPOUND;
 		goto drop_folio;
 	}
@@ -2023,7 +2023,7 @@ static enum scan_result collapse_file(st
 		 * we locked the first folio, then a THP might be there already.
 		 * This will be discovered on the first iteration.
 		 */
-		if (folio_order(folio) == HPAGE_PMD_ORDER) {
+		if (is_pmd_order(folio_order(folio))) {
 			result = SCAN_PTE_MAPPED_HUGEPAGE;
 			goto out_unlock;
 		}
@@ -2351,7 +2351,7 @@ static enum scan_result hpage_collapse_s
 			continue;
 		}
 
-		if (folio_order(folio) == HPAGE_PMD_ORDER) {
+		if (is_pmd_order(folio_order(folio))) {
 			result = SCAN_PTE_MAPPED_HUGEPAGE;
 			/*
 			 * PMD-sized THP implies that we can only try
mm/memory.c renamed from mm/memory.c~mm-introduce-is_pmd_order-helper +1 -1
@@ -5435,7 +5435,7 @@ vm_fault_t do_set_pmd(struct vm_fault *v
 	if (!thp_vma_suitable_order(vma, haddr, PMD_ORDER))
 		return ret;
 
-	if (folio_order(folio) != HPAGE_PMD_ORDER)
+	if (!is_pmd_order(folio_order(folio)))
 		return ret;
 	page = &folio->page;
 
mm/mempolicy.c renamed from mm/mempolicy.c~mm-introduce-is_pmd_order-helper +1 -1
@@ -2449,7 +2449,7 @@ static struct page *alloc_pages_mpol(gfp
 
 	if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) &&
 	    /* filter "hugepage" allocation, unless from alloc_pages() */
-	    order == HPAGE_PMD_ORDER && ilx != NO_INTERLEAVE_INDEX) {
+	    is_pmd_order(order) && ilx != NO_INTERLEAVE_INDEX) {
 		/*
 		 * For hugepage allocation and non-interleave policy which
 		 * allows the current node (or other explicitly preferred
mm/page_alloc.c renamed from mm/page_alloc.c~mm-introduce-is_pmd_order-helper +2 -2
@@ -651,7 +651,7 @@ static inline unsigned int order_to_pind
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
 	bool movable;
 	if (order > PAGE_ALLOC_COSTLY_ORDER) {
-		VM_BUG_ON(order != HPAGE_PMD_ORDER);
+		VM_BUG_ON(!is_pmd_order(order));
 
 		movable = migratetype == MIGRATE_MOVABLE;
 
@@ -683,7 +683,7 @@ static inline bool pcp_allowed_order(uns
 	if (order <= PAGE_ALLOC_COSTLY_ORDER)
 		return true;
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
-	if (order == HPAGE_PMD_ORDER)
+	if (is_pmd_order(order))
 		return true;
 #endif
 	return false;
mm/shmem.c renamed from mm/shmem.c~mm-introduce-is_pmd_order-helper +1 -2
@@ -5558,8 +5558,7 @@ static ssize_t thpsize_shmem_enabled_sto
 		spin_unlock(&huge_shmem_orders_lock);
 	} else if (sysfs_streq(buf, "inherit")) {
 		/* Do not override huge allocation policy with non-PMD sized mTHP */
-		if (shmem_huge == SHMEM_HUGE_FORCE &&
-		    order != HPAGE_PMD_ORDER)
+		if (shmem_huge == SHMEM_HUGE_FORCE && !is_pmd_order(order))
 			return -EINVAL;
 
 		spin_lock(&huge_shmem_orders_lock);

_

Patches currently in -mm which might be from [email protected] are