From cf71c34ecb126e507f425fe3ae06e437c20ca43a Mon Sep 17 00:00:00 2001 From: Minchan Kim Date: Mon, 11 Mar 2019 11:42:36 +0900 Subject: [PATCH] Revert "mm: make pte_unmap_same compatible with SPF" This reverts commit 7224f45453000022bb07762cbae3dbc46ff0b13c. Bug: 128240262 Change-Id: Ifdf06b5394bcfb111468fd7f220434a343fb48e8 Signed-off-by: Minchan Kim [dereference23: Forward port to msm-5.4] Signed-off-by: Alexander Winkowski --- include/linux/mm_types.h | 1 - mm/memory.c | 39 +++++++++++---------------------------- 2 files changed, 11 insertions(+), 29 deletions(-) diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 41580bcd286a..e1f7840db114 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -705,7 +705,6 @@ enum vm_fault_reason { VM_FAULT_FALLBACK = (__force vm_fault_t)0x000800, VM_FAULT_DONE_COW = (__force vm_fault_t)0x001000, VM_FAULT_NEEDDSYNC = (__force vm_fault_t)0x002000, - VM_FAULT_PTNOTSAME = (__force vm_fault_t)0x004000, VM_FAULT_HINDEX_MASK = (__force vm_fault_t)0x0f0000, }; diff --git a/mm/memory.c b/mm/memory.c index 658c0580a973..1eb1ab086a06 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -2229,29 +2229,21 @@ static inline bool pte_map_lock(struct vm_fault *vmf) * parts, do_swap_page must check under lock before unmapping the pte and * proceeding (but do_wp_page is only called after already making such a check; * and do_anonymous_page can safely check later on). - * - * pte_unmap_same() returns: - * 0 if the PTE are the same - * VM_FAULT_PTNOTSAME if the PTE are different - * VM_FAULT_RETRY if the VMA has changed in our back during - * a speculative page fault handling. */ -static inline int pte_unmap_same(struct vm_fault *vmf) +static inline int pte_unmap_same(struct mm_struct *mm, pmd_t *pmd, + pte_t *page_table, pte_t orig_pte) { - int ret = 0; - + int same = 1; #if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT) if (sizeof(pte_t) > sizeof(unsigned long)) { - if (pte_spinlock(vmf)) { - if (!pte_same(*vmf->pte, vmf->orig_pte)) - ret = VM_FAULT_PTNOTSAME; - spin_unlock(vmf->ptl); - } else - ret = VM_FAULT_RETRY; + spinlock_t *ptl = pte_lockptr(mm, pmd); + spin_lock(ptl); + same = pte_same(*page_table, orig_pte); + spin_unlock(ptl); } #endif - pte_unmap(vmf->pte); - return ret; + pte_unmap(page_table); + return same; } static inline bool cow_user_page(struct page *dst, struct page *src, @@ -2967,19 +2959,10 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) pte_t pte; int locked; int exclusive = 0; - vm_fault_t ret; + vm_fault_t ret = 0; - ret = pte_unmap_same(vmf); - if (ret) { - /* - * If pte != orig_pte, this means another thread did the - * swap operation in our back. - * So nothing else to do. - */ - if (ret == VM_FAULT_PTNOTSAME) - ret = 0; + if (!pte_unmap_same(vma->vm_mm, vmf->pmd, vmf->pte, vmf->orig_pte)) goto out; - } entry = pte_to_swp_entry(vmf->orig_pte); if (unlikely(non_swap_entry(entry))) {