From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966584AbeEJQPK (ORCPT ); Thu, 10 May 2018 12:15:10 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:55902 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966443AbeEJQPG (ORCPT ); Thu, 10 May 2018 12:15:06 -0400 X-Google-Smtp-Source: AB8JxZqMc7428hyj8SYmtzIdZPUR9k+lP2OYlJHyEbw9zG6g8rfc76bItipCUrW3iA2sNJbMka39uI7PZATkwKLMwR0= MIME-Version: 1.0 In-Reply-To: <1523975611-15978-7-git-send-email-ldufour@linux.vnet.ibm.com> References: <1523975611-15978-1-git-send-email-ldufour@linux.vnet.ibm.com> <1523975611-15978-7-git-send-email-ldufour@linux.vnet.ibm.com> From: vinayak menon Date: Thu, 10 May 2018 21:45:05 +0530 Message-ID: Subject: Re: [PATCH v10 06/25] mm: make pte_unmap_same compatible with SPF To: Laurent Dufour Cc: Andrew Morton , Michal Hocko , Peter Zijlstra , kirill@shutemov.name, ak@linux.intel.com, dave@stgolabs.net, jack@suse.cz, Matthew Wilcox , benh@kernel.crashing.org, mpe@ellerman.id.au, paulus@samba.org, Thomas Gleixner , Ingo Molnar , hpa@zytor.com, Will Deacon , Sergey Senozhatsky , Andrea Arcangeli , Alexei Starovoitov , kemi.wang@intel.com, sergey.senozhatsky.work@gmail.com, Daniel Jordan , David Rientjes , Jerome Glisse , Ganesh Mahendran , linux-kernel@vger.kernel.org, linux-mm@kvack.org, haren@linux.vnet.ibm.com, khandual@linux.vnet.ibm.com, npiggin@gmail.com, bsingharora@gmail.com, Paul McKenney , Tim Chen , linuxppc-dev@lists.ozlabs.org, x86@kernel.org, Vinayak Menon Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 17, 2018 at 8:03 PM, Laurent Dufour wrote: > pte_unmap_same() is making the assumption that the page table are still > around because the mmap_sem is held. > This is no more the case when running a speculative page fault and > additional check must be made to ensure that the final page table are still > there. > > This is now done by calling pte_spinlock() to check for the VMA's > consistency while locking for the page tables. > > This is requiring passing a vm_fault structure to pte_unmap_same() which is > containing all the needed parameters. > > As pte_spinlock() may fail in the case of a speculative page fault, if the > VMA has been touched in our back, pte_unmap_same() should now return 3 > cases : > 1. pte are the same (0) > 2. pte are different (VM_FAULT_PTNOTSAME) > 3. a VMA's changes has been detected (VM_FAULT_RETRY) > > The case 2 is handled by the introduction of a new VM_FAULT flag named > VM_FAULT_PTNOTSAME which is then trapped in cow_user_page(). > If VM_FAULT_RETRY is returned, it is passed up to the callers to retry the > page fault while holding the mmap_sem. > > Acked-by: David Rientjes > Signed-off-by: Laurent Dufour > --- > include/linux/mm.h | 1 + > mm/memory.c | 39 ++++++++++++++++++++++++++++----------- > 2 files changed, 29 insertions(+), 11 deletions(-) > > diff --git a/include/linux/mm.h b/include/linux/mm.h > index 4d1aff80669c..714da99d77a3 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -1208,6 +1208,7 @@ static inline void clear_page_pfmemalloc(struct page *page) > #define VM_FAULT_NEEDDSYNC 0x2000 /* ->fault did not modify page tables > * and needs fsync() to complete (for > * synchronous page faults in DAX) */ > +#define VM_FAULT_PTNOTSAME 0x4000 /* Page table entries have changed */ This has to be added to VM_FAULT_RESULT_TRACE ?