Skip to contentSkip to conversation

FAILED: patch "[PATCH] migrate: hugetlb: check for hugetlb shared PMD in node" failed to apply to 5.15-stable tree

PATCH [email protected] 1 participant 1 message Feb 7, 2023

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

Possible dependencies:

73bdf65ea748 ("migrate: hugetlb: check for hugetlb shared PMD in node migration") 7ce82f4c3f3e ("mm/migration: return errno when isolate_huge_page failed") 1b7f7e58decc ("mm/gup: Convert check_and_migrate_movable_pages() to use a folio") f9f38f78c5d5 ("mm: refactor check_and_migrate_movable_pages")

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 73bdf65ea74857d7fb2ec3067a3cec0e261b1462 Mon Sep 17 00:00:00 2001
From: Mike Kravetz <[email protected]>
Date: Thu, 26 Jan 2023 14:27:21 -0800
Subject: [PATCH] migrate: hugetlb: check for hugetlb shared PMD in node
migration

migrate_pages/mempolicy semantics state that CAP_SYS_NICE is required to move pages shared with another process to a different node. page_mapcount

Quoted 1 line

1 is being used to determine if a hugetlb page is shared. However, a

hugetlb page will have a mapcount of 1 if mapped by multiple processes via a shared PMD. As a result, hugetlb pages shared by multiple processes and mapped with a shared PMD can be moved by a process without CAP_SYS_NICE.

To fix, check for a shared PMD if mapcount is 1. If a shared PMD is found consider the page shared.

Fixes e2d8cf405525 ("migrate: add hugepage migration code to migrate_pages()")
Cc James Houghton <[email protected]>
Cc Matthew Wilcox <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Muchun Song <[email protected]>
Cc Naoya Horiguchi <[email protected]>
Cc Vishal Moola (Oracle) <[email protected]>
Cc Yang Shi <[email protected]>
mm/mempolicy.c +2 -1
index 02c8a712282f..f940395667c8 100644
@@ -600,7 +600,8 @@ static int queue_pages_hugetlb(pte_t *pte, unsigned long hmask,
 
 	/* With MPOL_MF_MOVE, we migrate only unshared hugepage. */
 	if (flags & (MPOL_MF_MOVE_ALL) ||
-	    (flags & MPOL_MF_MOVE && page_mapcount(page) == 1)) {
+	    (flags & MPOL_MF_MOVE && page_mapcount(page) == 1 &&
+	     !hugetlb_pmd_shared(pte))) {
 		if (isolate_hugetlb(page, qp->pagelist) &&
 			(flags & MPOL_MF_STRICT))
 			/*