+ mm-hwpoison-fix-race-between-hugetlb-free-demotion-and-memory_failure_hugetlb-v7.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     Subject: mm-hwpoison-fix-race-between-hugetlb-free-demotion-and-memory_failure_hugetlb-v7
has been added to the -mm tree.  Its filename is
     mm-hwpoison-fix-race-between-hugetlb-free-demotion-and-memory_failure_hugetlb-v7.patch

This patch should soon appear at
    https://ozlabs.org/~akpm/mmots/broken-out/mm-hwpoison-fix-race-between-hugetlb-free-demotion-and-memory_failure_hugetlb-v7.patch
and later at
    https://ozlabs.org/~akpm/mmotm/broken-out/mm-hwpoison-fix-race-between-hugetlb-free-demotion-and-memory_failure_hugetlb-v7.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next and is updated
there every 3-4 working days

------------------------------------------------------
From: Naoya Horiguchi <naoya.horiguchi@xxxxxxx>
Subject: mm-hwpoison-fix-race-between-hugetlb-free-demotion-and-memory_failure_hugetlb-v7

- Move lock_page() to try_memory_failure_hugetlb()
  (based on bug report from Dan Carpenter)
- Add Fixes: tag and CC to stable.

Link: https://lkml.kernel.org/r/20220407112929.1344748-1-naoya.horiguchi@xxxxxxxxx
Fixes: 761ad8d7c7b5 ("mm: hwpoison: introduce memory_failure_hugetlb()")
Reported-by: Mike Kravetz <mike.kravetz@xxxxxxxxxx>
Signed-off-by: Naoya Horiguchi <naoya.horiguchi@xxxxxxx>
Cc: Miaohe Lin <linmiaohe@xxxxxxxxxx>
Cc: Yang Shi <shy828301@xxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 mm/memory-failure.c |   19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

--- a/mm/memory-failure.c~mm-hwpoison-fix-race-between-hugetlb-free-demotion-and-memory_failure_hugetlb-v7
+++ a/mm/memory-failure.c
@@ -1500,8 +1500,6 @@ static int try_to_split_thp_page(struct
 
 /*
  * Called from hugetlb code with hugetlb_lock held.
- * If a hugepage is successfully grabbed (so it's determined to handle
- * the error as a hugepage error), returns with holding the page lock.
  *
  * Return values:
  *   0             - free hugepage
@@ -1533,25 +1531,20 @@ int __get_huge_page_for_hwpoison(unsigne
 		goto out;
 	}
 
-	lock_page(head);
-
 	if (hwpoison_filter(page)) {
 		ret = -EOPNOTSUPP;
-		goto unlock;
+		goto out;
 	}
 
 	if (TestSetPageHWPoison(head)) {
 		ret = -EHWPOISON;
-		goto unlock;
+		goto out;
 	}
 
-	/* keep locking page. */
 	return ret;
-unlock:
-	unlock_page(head);
+out:
 	if (count_increased)
 		put_page(head);
-out:
 	return ret;
 }
 
@@ -1596,14 +1589,11 @@ retry:
 
 	num_poisoned_pages_inc();
 
-	head = compound_head(p);
-
 	/*
 	 * Handling free hugepage.  The possible race with hugepage allocation
 	 * or demotion can be prevented by PageHWPoison flag.
 	 */
 	if (res == 0) {
-		unlock_page(head);
 		res = MF_FAILED;
 		if (__page_handle_poison(p)) {
 			page_ref_inc(p);
@@ -1613,6 +1603,9 @@ retry:
 		return res == MF_RECOVERED ? 0 : -EBUSY;
 	}
 
+	head = compound_head(p);
+	lock_page(head);
+
 	/*
 	 * The page could have changed compound pages due to race window.
 	 * If this happens just bail out.
_

Patches currently in -mm which might be from naoya.horiguchi@xxxxxxx are

mm-hwpoison-fix-race-between-hugetlb-free-demotion-and-memory_failure_hugetlb.patch
mm-hwpoison-fix-race-between-hugetlb-free-demotion-and-memory_failure_hugetlb-v7.patch




[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux