Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753077AbcKGXda (ORCPT ); Mon, 7 Nov 2016 18:33:30 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:33711 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752640AbcKGXcf (ORCPT ); Mon, 7 Nov 2016 18:32:35 -0500 From: Naoya Horiguchi To: linux-mm@kvack.org Cc: "Kirill A. Shutemov" , Hugh Dickins , Andrew Morton , Dave Hansen , Andrea Arcangeli , Mel Gorman , Michal Hocko , Vlastimil Babka , Pavel Emelyanov , Zi Yan , Balbir Singh , linux-kernel@vger.kernel.org, Naoya Horiguchi , Naoya Horiguchi Subject: [PATCH v2 09/12] mm: hwpoison: soft offline supports thp migration Date: Tue, 8 Nov 2016 08:31:54 +0900 Message-Id: <1478561517-4317-10-git-send-email-n-horiguchi@ah.jp.nec.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1478561517-4317-1-git-send-email-n-horiguchi@ah.jp.nec.com> References: <1478561517-4317-1-git-send-email-n-horiguchi@ah.jp.nec.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1941 Lines: 62 This patch enables thp migration for soft offline. Signed-off-by: Naoya Horiguchi --- mm/memory-failure.c | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git v4.9-rc2-mmotm-2016-10-27-18-27/mm/memory-failure.c v4.9-rc2-mmotm-2016-10-27-18-27_patched/mm/memory-failure.c index 19e796d..6cc8157 100644 --- v4.9-rc2-mmotm-2016-10-27-18-27/mm/memory-failure.c +++ v4.9-rc2-mmotm-2016-10-27-18-27_patched/mm/memory-failure.c @@ -1485,7 +1485,17 @@ static struct page *new_page(struct page *p, unsigned long private, int **x) if (PageHuge(p)) return alloc_huge_page_node(page_hstate(compound_head(p)), nid); - else + else if (thp_migration_supported() && PageTransHuge(p)) { + struct page *thp; + + thp = alloc_pages_node(nid, + (GFP_TRANSHUGE | __GFP_THISNODE) & ~__GFP_RECLAIM, + HPAGE_PMD_ORDER); + if (!thp) + return NULL; + prep_transhuge_page(thp); + return thp; + } else return __alloc_pages_node(nid, GFP_HIGHUSER_MOVABLE, 0); } @@ -1687,28 +1697,11 @@ static int __soft_offline_page(struct page *page, int flags) static int soft_offline_in_use_page(struct page *page, int flags) { int ret; - struct page *hpage = compound_head(page); - - if (!PageHuge(page) && PageTransHuge(hpage)) { - lock_page(hpage); - if (!PageAnon(hpage) || unlikely(split_huge_page(hpage))) { - unlock_page(hpage); - if (!PageAnon(hpage)) - pr_info("soft offline: %#lx: non anonymous thp\n", page_to_pfn(page)); - else - pr_info("soft offline: %#lx: thp split failed\n", page_to_pfn(page)); - put_hwpoison_page(hpage); - return -EBUSY; - } - unlock_page(hpage); - get_hwpoison_page(page); - put_hwpoison_page(hpage); - } if (PageHuge(page)) ret = soft_offline_huge_page(page, flags); else - ret = __soft_offline_page(page, flags); + ret = __soft_offline_page(compound_head(page), flags); return ret; } -- 2.7.0