Received: by 10.192.165.148 with SMTP id m20csp1346547imm; Thu, 10 May 2018 09:16:39 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpmFyOzKeNWgsa5CsUijGVD0NJvlwYFvZZQNQDP1Bff8amWuiGsSWwnpdxDflzqMGY8gFax X-Received: by 2002:a62:5c06:: with SMTP id q6-v6mr1978922pfb.118.1525968999195; Thu, 10 May 2018 09:16:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525968999; cv=none; d=google.com; s=arc-20160816; b=SAJy016ou/IF5ZULxHmAW5C7pAar+NCsw4s0pi/RgZs0akNpLrhOveKxjwezzeqFTa SqAHiGDd/PPF5g+XzuS0jYzKFX7gF1alMkPDd7EubEyyEqiB/ZRMPn1IQkrhG16hpb1z JLA65q/pYPkTjzXehiOR7ykvjmWXGgxd+m27f8KTGyQC/ctgjmNI4U0oE9GsG9qjDw66 o+1WlhfsFzFWV3MjHyOGh9+jzNkPM9LFX29p0YVG8ThkHA6J64LqcvNjNIUBVD0T774T 2hKSl5UDhiTGpma7kD2T8Dqj0OShrQ2hV4Ofn1oj3UN2fGXflPArOvYVmuFHe3l5HzMC 9a8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=cAFNPgBltEljwDYf1rWt0ChPvZaLt1Z5kDq4a0fMAao=; b=EWAHhMo7pCd039QfI+GRD/Fa01vRqOaMdkn2pkMIsFHIbmKvK4NHdET95U4KOdK3f1 GQQplRUyx3tsVGUhMWAkh1YkW3NDQSA4MdXgGmQAQLFbruzV2S1fa3uC/wlPioc3MSLR 6TrV22L8V5mVaCEXr5JEY43s3sPUET8vTAR+8n2Qgv7c7Q20K+SVsJnJPFN4TWAQYb/p /lutQDDAj2B91dar30XefbM7x3jZnPWxE3uY6VJGCkzxKEDCPbbp1pjUOV0wB0giezob 2r19gr/wAxHz+toYikXCu8gq33PhKSA5raq+zT4I0cTotZcQ+Qc4iLtfTq8qOrpgmu9I 3rEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=c8jFuzd0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g31-v6si1086044pld.3.2018.05.10.09.16.24; Thu, 10 May 2018 09:16:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=c8jFuzd0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966581AbeEJQPK (ORCPT + 99 others); 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 Received: by mail-wm0-f66.google.com with SMTP id a8-v6so4756078wmg.5 for ; Thu, 10 May 2018 09:15:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=cAFNPgBltEljwDYf1rWt0ChPvZaLt1Z5kDq4a0fMAao=; b=c8jFuzd0TtUCqlMGEnmlfAqavNZ5hCM23nYklxwS5iUQMaB7EP7bHpKsUVVjNp6Ozs CAtCL6niUeCeOgwIgZf6894j8z/RAX4S2hTh7JWb1G6E/1mdgYyhh6CmVSQc/f0EnIKE m/eSr3HuhFGcnSZNk0uG9ZDjA55eR6RSTURK0UKDXk2arGJgGClt9whaht4UyYgtLC/J 5MCqp/+01hxU8YaTsJzAjLimVWxfAVFed54d5KIOx6fAANTZg5WU4X7ES7yXaudIrBRV Z+WYBRwnlN7oJKoGY1FI+9vVfAF+k6NK/14JJmkoYiwPGs/mDUPLjttEA1pNTBiMLDyr pwpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=cAFNPgBltEljwDYf1rWt0ChPvZaLt1Z5kDq4a0fMAao=; b=Rg2VSU50jxzb8soM6MWKrP7fgf18UMGco1CUe2dUAszViNTtRHS6knFFWSuLaZco+L ZeoK7FII/WKtNGy51SyUAiRyN3wILCtz2EBfYbCR8WA71PXHccCVikX4puBzhzxlSWAI HdwRIPJPPU+ayC4ZN1KFmwmFD7/bHdSpQWoEKmprTPg6c4Jv564/uj5Jv5bJw5cvrXnb mH09eCLaQq0sepoH8XYypfGR7lHPIMcz9/hKbU91aHmPGpF5W4Rq7oI6tBuheR9RShrW IdVewt4ePzqh3evowKYRo64xF4SpqbVEpnszuNcv0b5O/gF8k844mYl4f/p+dk6mLcGq nbqw== X-Gm-Message-State: ALKqPwfIa1cHjf4cIYSAVTeaZD5sIPHekJE5YoIgjrnDbSbzjW8LV0vv Bk7ScZijDb4bW0iW9JuQV2t+7HzEmXw1GFme0hE= X-Received: by 2002:a1c:ee58:: with SMTP id m85-v6mr1776813wmh.44.1525968905469; Thu, 10 May 2018 09:15:05 -0700 (PDT) MIME-Version: 1.0 Received: by 10.28.221.131 with HTTP; Thu, 10 May 2018 09:15:05 -0700 (PDT) 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 Precedence: bulk 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 ?