]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm: memory-failure: kill __soft_offline_page()
authorKefeng Wang <wangkefeng.wang@huawei.com>
Fri, 19 Aug 2022 03:34:02 +0000 (11:34 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 22 Aug 2022 22:58:16 +0000 (15:58 -0700)
Squash the __soft_offline_page() into soft_offline_in_use_page() and kill
__soft_offline_page().

Link: https://lkml.kernel.org/r/20220819033402.156519-2-wangkefeng.wang@huawei.com
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Reviewed-by: Miaohe Lin <linmiaohe@huawei.com>
Acked-by: Naoya Horiguchi <naoya.horiguchi@nec.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/memory-failure.c

index 0681f5aebf0043b2bd9449bd52c97ec85ca9a2c9..f1cc7f66dcd2f49be14c7815089d8b3923e2efb2 100644 (file)
@@ -2436,11 +2436,11 @@ static bool isolate_page(struct page *page, struct list_head *pagelist)
 }
 
 /*
- * __soft_offline_page handles hugetlb-pages and non-hugetlb pages.
+ * soft_offline_in_use_page handles hugetlb-pages and non-hugetlb pages.
  * If the page is a non-dirty unmapped page-cache page, it simply invalidates.
  * If the page is mapped, it migrates the contents over.
  */
-static int __soft_offline_page(struct page *page)
+static int soft_offline_in_use_page(struct page *page)
 {
        long ret = 0;
        unsigned long pfn = page_to_pfn(page);
@@ -2453,6 +2453,13 @@ static int __soft_offline_page(struct page *page)
                .gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL,
        };
 
+       if (!huge && PageTransHuge(hpage)) {
+               if (try_to_split_thp_page(page)) {
+                       pr_info("soft offline: %#lx: thp split failed\n", pfn);
+                       return -EBUSY;
+               }
+       }
+
        lock_page(page);
        if (!PageHuge(page))
                wait_on_page_writeback(page);
@@ -2502,19 +2509,6 @@ static int __soft_offline_page(struct page *page)
        return ret;
 }
 
-static int soft_offline_in_use_page(struct page *page)
-{
-       struct page *hpage = compound_head(page);
-
-       if (!PageHuge(page) && PageTransHuge(hpage))
-               if (try_to_split_thp_page(page) < 0) {
-                       pr_info("soft offline: %#lx: thp split failed\n",
-                               page_to_pfn(page));
-                       return -EBUSY;
-               }
-       return __soft_offline_page(page);
-}
-
 static void put_ref_page(struct page *page)
 {
        if (page)