From patchwork Fri May 5 15:32:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seth Forshee X-Patchwork-Id: 759070 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 3wKG9x2kZmz9s7r; Sat, 6 May 2017 01:32:53 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical-com.20150623.gappssmtp.com header.i=@canonical-com.20150623.gappssmtp.com header.b="xm3q+rV1"; dkim-atps=neutral Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1d6fDu-0004eJ-IK; Fri, 05 May 2017 15:32:50 +0000 Received: from mail-io0-f175.google.com ([209.85.223.175]) by huckleberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1d6fDp-0004cn-Ug for kernel-team@lists.ubuntu.com; Fri, 05 May 2017 15:32:46 +0000 Received: by mail-io0-f175.google.com with SMTP id k91so12653963ioi.1 for ; Fri, 05 May 2017 08:32:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=1efyDB5ylL4ptnpLsynj6K1RdgLWz+LkgZNMcHiTQ5s=; b=xm3q+rV1hd3EnnM+WTOrHiUuooVqOxdNWeHVmTalA3asMD1iJ413neKBfv6uL/ckDy 7+XlOxifFLnQJakC+Dzgaf2flilMWKfUnhsKvd1VYgw7fKN86jeqZvsLAvz/wL1nPkXi ZDPuW04ct91LJ2oWkr5B1+W9JK8CtOx/1FDadw+6kaFVIzfeoM6RVM/WzFOefSwnaUac Nty7DJEBsm3pzEX3l3yo/1+eHg2JZynmy/5wkqg3VfB5nNwykJ+o3Ip0QOczRaCKUc0+ vTdvyBSF1m/AZk2P1ZoAIN1Ach618SBykkLrRRWBb6o9OvMPlC3gemGVQtdGoYSaMbFO CmPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=1efyDB5ylL4ptnpLsynj6K1RdgLWz+LkgZNMcHiTQ5s=; b=Q2awbEHh5B+myeUpelVK5S8EoSvk9Ot2hQnvKhU7BzglYbE4+eOD9tqafFDYO1If/l N/xwOYtaJWFMZTgJ4fZv1J8OhpzMkO6GqOEPT0J4axng5Jbu9C5rezWdkwvtVa9QUS1A ju9/YHaEHCARVyNFxt0QHj3ySCkHG6q7PXe4f/BR0uubr4F1dE5rB07vtxGM4odsJBrU veJ/HaXa2R910xYwQv1FQEUIF0u2d4rwiC+H9/ncvlNok1SAI4ieel3EoHx0vfmL7Jwb 8Q9PXs47dUVEjHY+oIpgJJ+6ak6sdzvmcqtoYA+J1OELLHNgg5/dyFK4QWReATQhR8xu FM2w== X-Gm-Message-State: AODbwcASMzbpuC8rfGaT3e/2AehFJ6ckOJYVmRbbboCN4rKGNt4pritx D6p64teaXmF/yoSeZUQ= X-Received: by 10.107.134.198 with SMTP id q67mr3977963ioi.28.1493998364453; Fri, 05 May 2017 08:32:44 -0700 (PDT) Received: from localhost ([2605:a601:aa7:8220:d525:2d8c:d0b4:d509]) by smtp.gmail.com with ESMTPSA id c84sm12402326ioj.8.2017.05.05.08.32.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 May 2017 08:32:43 -0700 (PDT) From: Seth Forshee To: kernel-team@lists.ubuntu.com Subject: [PATCH 3/4][Zesty SRU] Revert "mm: introduce page_vma_mapped_walk()" Date: Fri, 5 May 2017 10:32:38 -0500 Message-Id: <1493998359-5919-4-git-send-email-seth.forshee@canonical.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1493998359-5919-1-git-send-email-seth.forshee@canonical.com> References: <1493998359-5919-1-git-send-email-seth.forshee@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: kernel-team-bounces@lists.ubuntu.com BugLink: http://bugs.launchpad.net/bugs/1674838 This reverts commit 6e2a092a48d38cfc0f06bdb523014acbfeba7b2e. Signed-off-by: Seth Forshee --- include/linux/rmap.h | 26 ------- mm/Makefile | 6 +- mm/huge_memory.c | 9 +-- mm/page_vma_mapped.c | 188 --------------------------------------------------- 4 files changed, 5 insertions(+), 224 deletions(-) delete mode 100644 mm/page_vma_mapped.c diff --git a/include/linux/rmap.h b/include/linux/rmap.h index b76343610653..15321fb1df6b 100644 --- a/include/linux/rmap.h +++ b/include/linux/rmap.h @@ -9,7 +9,6 @@ #include #include #include -#include /* * The anon_vma heads a list of private "related" vmas, to scan if @@ -233,31 +232,6 @@ static inline bool page_check_address_transhuge(struct page *page, } #endif -/* Avoid racy checks */ -#define PVMW_SYNC (1 << 0) -/* Look for migarion entries rather than present PTEs */ -#define PVMW_MIGRATION (1 << 1) - -struct page_vma_mapped_walk { - struct page *page; - struct vm_area_struct *vma; - unsigned long address; - pmd_t *pmd; - pte_t *pte; - spinlock_t *ptl; - unsigned int flags; -}; - -static inline void page_vma_mapped_walk_done(struct page_vma_mapped_walk *pvmw) -{ - if (pvmw->pte) - pte_unmap(pvmw->pte); - if (pvmw->ptl) - spin_unlock(pvmw->ptl); -} - -bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw); - /* * Used by swapoff to help locate where page is expected in vma. */ diff --git a/mm/Makefile b/mm/Makefile index 474fa3431059..14fa1c83b504 100644 --- a/mm/Makefile +++ b/mm/Makefile @@ -23,10 +23,8 @@ KCOV_INSTRUMENT_vmstat.o := n mmu-y := nommu.o mmu-$(CONFIG_MMU) := gup.o highmem.o memory.o mincore.o \ - mlock.o mmap.o mprotect.o mremap.o msync.o \ - page_vma_mapped.o pagewalk.o pgtable-generic.o \ - rmap.o vmalloc.o - + mlock.o mmap.o mprotect.o mremap.o msync.o rmap.o \ + vmalloc.o pagewalk.o pgtable-generic.o ifdef CONFIG_CROSS_MEMORY_ATTACH mmu-$(CONFIG_MMU) += process_vm_access.o diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 87303c6bacf4..e6de801fa477 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1878,12 +1878,9 @@ static void freeze_page(struct page *page) static void unfreeze_page(struct page *page) { int i; - if (PageTransHuge(page)) { - remove_migration_ptes(page, page, true); - } else { - for (i = 0; i < HPAGE_PMD_NR; i++) - remove_migration_ptes(page + i, page + i, true); - } + + for (i = 0; i < HPAGE_PMD_NR; i++) + remove_migration_ptes(page + i, page + i, true); } static void __split_huge_page_tail(struct page *head, int tail, diff --git a/mm/page_vma_mapped.c b/mm/page_vma_mapped.c deleted file mode 100644 index dc1a54826cf2..000000000000 --- a/mm/page_vma_mapped.c +++ /dev/null @@ -1,188 +0,0 @@ -#include -#include -#include -#include -#include - -#include "internal.h" - -static inline bool check_pmd(struct page_vma_mapped_walk *pvmw) -{ - pmd_t pmde; - /* - * Make sure we don't re-load pmd between present and !trans_huge check. - * We need a consistent view. - */ - pmde = READ_ONCE(*pvmw->pmd); - return pmd_present(pmde) && !pmd_trans_huge(pmde); -} - -static inline bool not_found(struct page_vma_mapped_walk *pvmw) -{ - page_vma_mapped_walk_done(pvmw); - return false; -} - -static bool map_pte(struct page_vma_mapped_walk *pvmw) -{ - pvmw->pte = pte_offset_map(pvmw->pmd, pvmw->address); - if (!(pvmw->flags & PVMW_SYNC)) { - if (pvmw->flags & PVMW_MIGRATION) { - if (!is_swap_pte(*pvmw->pte)) - return false; - } else { - if (!pte_present(*pvmw->pte)) - return false; - } - } - pvmw->ptl = pte_lockptr(pvmw->vma->vm_mm, pvmw->pmd); - spin_lock(pvmw->ptl); - return true; -} - -static bool check_pte(struct page_vma_mapped_walk *pvmw) -{ - if (pvmw->flags & PVMW_MIGRATION) { -#ifdef CONFIG_MIGRATION - swp_entry_t entry; - if (!is_swap_pte(*pvmw->pte)) - return false; - entry = pte_to_swp_entry(*pvmw->pte); - if (!is_migration_entry(entry)) - return false; - if (migration_entry_to_page(entry) - pvmw->page >= - hpage_nr_pages(pvmw->page)) { - return false; - } - if (migration_entry_to_page(entry) < pvmw->page) - return false; -#else - WARN_ON_ONCE(1); -#endif - } else { - if (!pte_present(*pvmw->pte)) - return false; - - /* THP can be referenced by any subpage */ - if (pte_page(*pvmw->pte) - pvmw->page >= - hpage_nr_pages(pvmw->page)) { - return false; - } - if (pte_page(*pvmw->pte) < pvmw->page) - return false; - } - - return true; -} - -/** - * page_vma_mapped_walk - check if @pvmw->page is mapped in @pvmw->vma at - * @pvmw->address - * @pvmw: pointer to struct page_vma_mapped_walk. page, vma, address and flags - * must be set. pmd, pte and ptl must be NULL. - * - * Returns true if the page is mapped in the vma. @pvmw->pmd and @pvmw->pte point - * to relevant page table entries. @pvmw->ptl is locked. @pvmw->address is - * adjusted if needed (for PTE-mapped THPs). - * - * If @pvmw->pmd is set but @pvmw->pte is not, you have found PMD-mapped page - * (usually THP). For PTE-mapped THP, you should run page_vma_mapped_walk() in - * a loop to find all PTEs that map the THP. - * - * For HugeTLB pages, @pvmw->pte is set to the relevant page table entry - * regardless of which page table level the page is mapped at. @pvmw->pmd is - * NULL. - * - * Retruns false if there are no more page table entries for the page in - * the vma. @pvmw->ptl is unlocked and @pvmw->pte is unmapped. - * - * If you need to stop the walk before page_vma_mapped_walk() returned false, - * use page_vma_mapped_walk_done(). It will do the housekeeping. - */ -bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw) -{ - struct mm_struct *mm = pvmw->vma->vm_mm; - struct page *page = pvmw->page; - pgd_t *pgd; - pud_t *pud; - - /* The only possible pmd mapping has been handled on last iteration */ - if (pvmw->pmd && !pvmw->pte) - return not_found(pvmw); - - /* Only for THP, seek to next pte entry makes sense */ - if (pvmw->pte) { - if (!PageTransHuge(pvmw->page) || PageHuge(pvmw->page)) - return not_found(pvmw); - goto next_pte; - } - - if (unlikely(PageHuge(pvmw->page))) { - /* when pud is not present, pte will be NULL */ - pvmw->pte = huge_pte_offset(mm, pvmw->address); - if (!pvmw->pte) - return false; - - pvmw->ptl = huge_pte_lockptr(page_hstate(page), mm, pvmw->pte); - spin_lock(pvmw->ptl); - if (!check_pte(pvmw)) - return not_found(pvmw); - return true; - } -restart: - pgd = pgd_offset(mm, pvmw->address); - if (!pgd_present(*pgd)) - return false; - pud = pud_offset(pgd, pvmw->address); - if (!pud_present(*pud)) - return false; - pvmw->pmd = pmd_offset(pud, pvmw->address); - if (pmd_trans_huge(*pvmw->pmd)) { - pvmw->ptl = pmd_lock(mm, pvmw->pmd); - if (!pmd_present(*pvmw->pmd)) - return not_found(pvmw); - if (likely(pmd_trans_huge(*pvmw->pmd))) { - if (pvmw->flags & PVMW_MIGRATION) - return not_found(pvmw); - if (pmd_page(*pvmw->pmd) != page) - return not_found(pvmw); - return true; - } else { - /* THP pmd was split under us: handle on pte level */ - spin_unlock(pvmw->ptl); - pvmw->ptl = NULL; - } - } else { - if (!check_pmd(pvmw)) - return false; - } - if (!map_pte(pvmw)) - goto next_pte; - while (1) { - if (check_pte(pvmw)) - return true; -next_pte: do { - pvmw->address += PAGE_SIZE; - if (pvmw->address >= - __vma_address(pvmw->page, pvmw->vma) + - hpage_nr_pages(pvmw->page) * PAGE_SIZE) - return not_found(pvmw); - /* Did we cross page table boundary? */ - if (pvmw->address % PMD_SIZE == 0) { - pte_unmap(pvmw->pte); - if (pvmw->ptl) { - spin_unlock(pvmw->ptl); - pvmw->ptl = NULL; - } - goto restart; - } else { - pvmw->pte++; - } - } while (pte_none(*pvmw->pte)); - - if (!pvmw->ptl) { - pvmw->ptl = pte_lockptr(mm, pvmw->pmd); - spin_lock(pvmw->ptl); - } - } -}