Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755280AbaKEOxP (ORCPT ); Wed, 5 Nov 2014 09:53:15 -0500 Received: from mga01.intel.com ([192.55.52.88]:62488 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755103AbaKEOuQ (ORCPT ); Wed, 5 Nov 2014 09:50:16 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,320,1413270000"; d="scan'208";a="617582802" From: "Kirill A. Shutemov" To: Andrew Morton , Andrea Arcangeli Cc: Dave Hansen , Hugh Dickins , Mel Gorman , Rik van Riel , Vlastimil Babka , Christoph Lameter , Naoya Horiguchi , Steve Capper , "Aneesh Kumar K.V" , Johannes Weiner , Michal Hocko , linux-kernel@vger.kernel.org, linux-mm@kvack.org, "Kirill A. Shutemov" Subject: [PATCH 08/19] mm: prepare migration code for new THP refcounting Date: Wed, 5 Nov 2014 16:49:43 +0200 Message-Id: <1415198994-15252-9-git-send-email-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1415198994-15252-1-git-send-email-kirill.shutemov@linux.intel.com> References: <1415198994-15252-1-git-send-email-kirill.shutemov@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With new refcounting VMAs can start or end in the middle of huge page. We need to modify code to call split_huge_page() properly. Signed-off-by: Kirill A. Shutemov --- mm/migrate.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index f1a12ced2531..4dc941100388 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1235,7 +1235,7 @@ static int do_move_page_to_node_array(struct mm_struct *mm, vma = find_vma(mm, pp->addr); if (!vma || pp->addr < vma->vm_start || !vma_migratable(vma)) goto set_status; - +retry: page = follow_page(vma, pp->addr, FOLL_GET); err = PTR_ERR(page); @@ -1246,9 +1246,27 @@ static int do_move_page_to_node_array(struct mm_struct *mm, if (!page) goto set_status; - if (PageTransHuge(page) && split_huge_page(page)) { - err = -EBUSY; - goto set_status; + if (PageTransCompound(page)) { + struct page *head_page = compound_head(page); + + /* + * split_huge_page() wants pin to be only on head page + */ + if (page != head_page) { + get_page(head_page); + put_page(page); + } + + err = split_huge_page(head_page); + if (err) { + put_page(head_page); + goto set_status; + } + + if (page != head_page) { + put_page(head_page); + goto retry; + } } /* Use PageReserved to check for zero page */ -- 2.1.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/