Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752093AbdHHKmT (ORCPT ); Tue, 8 Aug 2017 06:42:19 -0400 Received: from merlin.infradead.org ([205.233.59.134]:33182 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751921AbdHHKmS (ORCPT ); Tue, 8 Aug 2017 06:42:18 -0400 Date: Tue, 8 Aug 2017 12:42:01 +0200 From: Peter Zijlstra To: Anshuman Khandual Cc: Laurent Dufour , paulmck@linux.vnet.ibm.com, akpm@linux-foundation.org, kirill@shutemov.name, ak@linux.intel.com, mhocko@kernel.org, dave@stgolabs.net, jack@suse.cz, Matthew Wilcox , linux-kernel@vger.kernel.org, linux-mm@kvack.org, haren@linux.vnet.ibm.com, npiggin@gmail.com, bsingharora@gmail.com, Tim Chen Subject: Re: [RFC v5 02/11] mm: Prepare for FAULT_FLAG_SPECULATIVE Message-ID: <20170808104201.sh7iyanrjs2wjz3y@hirez.programming.kicks-ass.net> References: <1497635555-25679-1-git-send-email-ldufour@linux.vnet.ibm.com> <1497635555-25679-3-git-send-email-ldufour@linux.vnet.ibm.com> <7e770060-32b2-c136-5d34-2f078800df21@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7e770060-32b2-c136-5d34-2f078800df21@linux.vnet.ibm.com> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1467 Lines: 37 On Tue, Aug 08, 2017 at 03:54:01PM +0530, Anshuman Khandual wrote: > On 06/16/2017 11:22 PM, Laurent Dufour wrote: > > From: Peter Zijlstra > > > > When speculating faults (without holding mmap_sem) we need to validate > > that the vma against which we loaded pages is still valid when we're > > ready to install the new PTE. > > > > Therefore, replace the pte_offset_map_lock() calls that (re)take the > > PTL with pte_map_lock() which can fail in case we find the VMA changed > > since we started the fault. > > Where we are checking if VMA has changed or not since the fault ? Not there yet, this is what you call a preparatory patch. They help review in that you can consider smaller steps. > > diff --git a/mm/memory.c b/mm/memory.c > > index fd952f05e016..40834444ea0d 100644 > > --- a/mm/memory.c > > +++ b/mm/memory.c > > @@ -2240,6 +2240,12 @@ static inline void wp_page_reuse(struct vm_fault *vmf) > > pte_unmap_unlock(vmf->pte, vmf->ptl); > > } > > > > +static bool pte_map_lock(struct vm_fault *vmf) > > +{ > > + vmf->pte = pte_offset_map_lock(vmf->vma->vm_mm, vmf->pmd, vmf->address, &vmf->ptl); > > + return true; > > +} > > This is always true ? Then we should not have all these if (!pte_map_lock(vmf)) > check blocks down below. Later patches will make it possible to return false. This patch is about the placing this call. Having this in a separate patch makes it easier to review all those new error conditions.