Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752633AbcKGXc3 (ORCPT ); Mon, 7 Nov 2016 18:32:29 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:36596 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752399AbcKGXcY (ORCPT ); Mon, 7 Nov 2016 18:32:24 -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 03/12] mm: thp: introduce separate TTU flag for thp freezing Date: Tue, 8 Nov 2016 08:31:48 +0900 Message-Id: <1478561517-4317-4-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: 3000 Lines: 71 TTU_MIGRATION is used to convert pte into migration entry until thp split completes. This behavior conflicts with thp migration added later patches, so let's introduce a new TTU flag specifically for freezing. Signed-off-by: Naoya Horiguchi --- include/linux/rmap.h | 1 + mm/huge_memory.c | 2 +- mm/rmap.c | 8 +++++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git v4.9-rc2-mmotm-2016-10-27-18-27/include/linux/rmap.h v4.9-rc2-mmotm-2016-10-27-18-27_patched/include/linux/rmap.h index b46bb56..a2fa425 100644 --- v4.9-rc2-mmotm-2016-10-27-18-27/include/linux/rmap.h +++ v4.9-rc2-mmotm-2016-10-27-18-27_patched/include/linux/rmap.h @@ -87,6 +87,7 @@ enum ttu_flags { TTU_MUNLOCK = 4, /* munlock mode */ TTU_LZFREE = 8, /* lazy free mode */ TTU_SPLIT_HUGE_PMD = 16, /* split huge PMD if any */ + TTU_SPLIT_FREEZE = 32, /* freeze pte under splitting thp */ TTU_IGNORE_MLOCK = (1 << 8), /* ignore mlock */ TTU_IGNORE_ACCESS = (1 << 9), /* don't age */ diff --git v4.9-rc2-mmotm-2016-10-27-18-27/mm/huge_memory.c v4.9-rc2-mmotm-2016-10-27-18-27_patched/mm/huge_memory.c index 2d1d6bb..0509d17 100644 --- v4.9-rc2-mmotm-2016-10-27-18-27/mm/huge_memory.c +++ v4.9-rc2-mmotm-2016-10-27-18-27_patched/mm/huge_memory.c @@ -1794,7 +1794,7 @@ static void freeze_page(struct page *page) VM_BUG_ON_PAGE(!PageHead(page), page); if (PageAnon(page)) - ttu_flags |= TTU_MIGRATION; + ttu_flags |= TTU_SPLIT_FREEZE; /* We only need TTU_SPLIT_HUGE_PMD once */ ret = try_to_unmap(page, ttu_flags | TTU_SPLIT_HUGE_PMD); diff --git v4.9-rc2-mmotm-2016-10-27-18-27/mm/rmap.c v4.9-rc2-mmotm-2016-10-27-18-27_patched/mm/rmap.c index 1ef3640..a4be307 100644 --- v4.9-rc2-mmotm-2016-10-27-18-27/mm/rmap.c +++ v4.9-rc2-mmotm-2016-10-27-18-27_patched/mm/rmap.c @@ -1449,7 +1449,7 @@ static int try_to_unmap_one(struct page *page, struct vm_area_struct *vma, if (flags & TTU_SPLIT_HUGE_PMD) { split_huge_pmd_address(vma, address, - flags & TTU_MIGRATION, page); + flags & TTU_SPLIT_FREEZE, page); /* check if we have anything to do after split */ if (page_mapcount(page) == 0) goto out; @@ -1527,7 +1527,8 @@ static int try_to_unmap_one(struct page *page, struct vm_area_struct *vma, * will take care of the rest. */ dec_mm_counter(mm, mm_counter(page)); - } else if (IS_ENABLED(CONFIG_MIGRATION) && (flags & TTU_MIGRATION)) { + } else if (IS_ENABLED(CONFIG_MIGRATION) && + (flags & (TTU_MIGRATION|TTU_SPLIT_FREEZE))) { swp_entry_t entry; pte_t swp_pte; /* @@ -1649,7 +1650,8 @@ int try_to_unmap(struct page *page, enum ttu_flags flags) * locking requirements of exec(), migration skips * temporary VMAs until after exec() completes. */ - if ((flags & TTU_MIGRATION) && !PageKsm(page) && PageAnon(page)) + if ((flags & (TTU_MIGRATION|TTU_SPLIT_FREEZE)) + && !PageKsm(page) && PageAnon(page)) rwc.invalid_vma = invalid_migration_vma; if (flags & TTU_RMAP_LOCKED) -- 2.7.0