Received: by 10.213.65.68 with SMTP id h4csp1074276imn; Tue, 27 Mar 2018 14:19:28 -0700 (PDT) X-Google-Smtp-Source: AIpwx48EGs23GshuzOYqrVh91mOtZHbyk7EZfwx2lTDakb4SLM6yromnv2GUjOVv+1FKBVOE/zUT X-Received: by 10.98.166.196 with SMTP id r65mr725853pfl.110.1522185568443; Tue, 27 Mar 2018 14:19:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522185568; cv=none; d=google.com; s=arc-20160816; b=NcSAubQiNwVgdRnmYlk+dYXuyOjv/QsgdAwoUl23wGTOoSSKsfm9l9c+g/2yUSlr4u XWYZL2DztwcHcQ4vCy/1v6gAo72/arXTCy/3Y3Mbs83HHs/XPHrvb2LJKuQZGtJorYsY ZFiEal5NRC2PRXUylpLiHeTpeVe1Hhl2nROabGEKJzls0QMmV/lqcI+U88xmb/fn6CMj +DszcmTKB8jHnp1/yaCn+FGUef0B3xPiyxDHfuw5f2YXtFFQRct6vGv+g+fc9sUokCNf HK8fkbKP4pB5MTz1RDb6KJVGEMi4qJ9IVS5HmKaLFtdH+Rp/4XMUdH2xYWAOM8cwGc4r KkoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=rO392jKdWdshYt2Q7vTb4kXm9J3X2bY7WGqS3T+bnXo=; b=R6RK0DvRVJ5KRNTWmAWSikKEbqOvvtCKYKK6InVj2OqOrkVjENOdFAAeX11SQD/arK F29c1Pg8IATbXFcY5AP3k1W6UlXRO9yrsGPIzUuZdd7K2R0FA9VFDkd6r0IpX/PW1tf5 fH+Tj8DaCgE3iExv0f7nDrTjNRRUPI1dQ9ZDgxrOJ8guOgPDVt3a/UfG+97tVAvzK9ZZ Yb03xSMc9WUPxR/syZ8aY0lWtdDPWZetimEEgaAboKsZq14M90h0BYGri1ifDQTkyGyu fn3fioTAOwvxcbDAFBb0STzmp+Lh+mk0D9t9O1qx1wLKaqfnIcCA96LkmZH+J76uElmy HTdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=bbMdTy5l; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n7si1431204pga.199.2018.03.27.14.19.13; Tue, 27 Mar 2018 14:19:28 -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=@google.com header.s=20161025 header.b=bbMdTy5l; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752055AbeC0VSV (ORCPT + 99 others); Tue, 27 Mar 2018 17:18:21 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:38708 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750965AbeC0VSU (ORCPT ); Tue, 27 Mar 2018 17:18:20 -0400 Received: by mail-pg0-f65.google.com with SMTP id a15so121899pgn.5 for ; Tue, 27 Mar 2018 14:18:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=rO392jKdWdshYt2Q7vTb4kXm9J3X2bY7WGqS3T+bnXo=; b=bbMdTy5lJdOvS5NUy0G/0MDbO3mzyIg9hbwkq7fTvYWiIDyOqEqPcYLnh6lRNABqFk 3xLk+HSz/LyjLafZ6whU9NeyJywf/TYaIXAwc3wxFqZR0edy4akZmLS2KAIu/Gr147bQ gtWu21xXfPLaWhyV4cwhkTMt4TvYoysQ4nkUWpGHd6WXwdm4ScwRUhmu1G112OkyRQAS dDRTN5Y7pENTIgNTn4BLIbq+q6euqONTzDLBJ+dzjxJkyjLGAHBSxKTJBO8R4t4kidSE sLRtvw5dohnCbfquPpy+xC7FrmuBR7ybUq+2nXBgrUhBG8da4ftccGheXreROIZCjW+H tozA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=rO392jKdWdshYt2Q7vTb4kXm9J3X2bY7WGqS3T+bnXo=; b=GV7G/uHn8EsIrGzF1PaUAJCIbqqA6PLNL9Jic400atUJAnlsCecze8xIdB+7GGWpll dSODNt/61p5PiQMei+pB3XaeH5svVMPuLgdwWfUmf2HG+qxyFTXU1BTdCxQy+QENi/XA ULs8jrZQUUc1HIO+QqNw4Km16KfuDyi1sD1ltd8z5MEbJyc8g9AIYeb3L+iBuklXu6v7 vIDcIg1ZkQx8+G/fVptQ6F6XaSOJfFyaXZO2uzU7HJQUXWHvhQcVof5vAD9KUiHnq/nx 1uPVnu56a5x1eaeXiud3qzuRxagIPPUE90PbP5zQaXbAfXxUaaPYmdFpsqOnRCNp7Qig Axqg== X-Gm-Message-State: AElRT7EaPSk8FS5fD/WJnBHjCV3TRbmOQlf79/8/VBMpMB9ygdkN1DVx W7nJTBxVA+HPbgw/f9QMDf89pQ== X-Received: by 10.99.96.130 with SMTP id u124mr626750pgb.252.1522185499405; Tue, 27 Mar 2018 14:18:19 -0700 (PDT) Received: from [2620:15c:17:3:3a5:23a7:5e32:4598] ([2620:15c:17:3:3a5:23a7:5e32:4598]) by smtp.gmail.com with ESMTPSA id s7sm3907939pgq.48.2018.03.27.14.18.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Mar 2018 14:18:18 -0700 (PDT) Date: Tue, 27 Mar 2018 14:18:17 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Laurent Dufour cc: paulmck@linux.vnet.ibm.com, peterz@infradead.org, akpm@linux-foundation.org, kirill@shutemov.name, ak@linux.intel.com, mhocko@kernel.org, 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 , 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, Tim Chen , linuxppc-dev@lists.ozlabs.org, x86@kernel.org Subject: Re: [PATCH v9 06/24] mm: make pte_unmap_same compatible with SPF In-Reply-To: <1520963994-28477-7-git-send-email-ldufour@linux.vnet.ibm.com> Message-ID: References: <1520963994-28477-1-git-send-email-ldufour@linux.vnet.ibm.com> <1520963994-28477-7-git-send-email-ldufour@linux.vnet.ibm.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 13 Mar 2018, Laurent Dufour wrote: > diff --git a/include/linux/mm.h b/include/linux/mm.h > index 2f3e98edc94a..b6432a261e63 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -1199,6 +1199,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 */ > > #define VM_FAULT_ERROR (VM_FAULT_OOM | VM_FAULT_SIGBUS | VM_FAULT_SIGSEGV | \ > VM_FAULT_HWPOISON | VM_FAULT_HWPOISON_LARGE | \ > diff --git a/mm/memory.c b/mm/memory.c > index 21b1212a0892..4bc7b0bdcb40 100644 > --- a/mm/memory.c > +++ b/mm/memory.c > @@ -2309,21 +2309,29 @@ static 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 mm_struct *mm, pmd_t *pmd, > - pte_t *page_table, pte_t orig_pte) > +static inline int pte_unmap_same(struct vm_fault *vmf) > { > - int same = 1; > + int ret = 0; > + > #if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT) > if (sizeof(pte_t) > sizeof(unsigned long)) { > - spinlock_t *ptl = pte_lockptr(mm, pmd); > - spin_lock(ptl); > - same = pte_same(*page_table, orig_pte); > - spin_unlock(ptl); > + 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; > } > #endif > - pte_unmap(page_table); > - return same; > + pte_unmap(vmf->pte); > + return ret; > } > > static inline void cow_user_page(struct page *dst, struct page *src, unsigned long va, struct vm_area_struct *vma) > @@ -2913,7 +2921,8 @@ int do_swap_page(struct vm_fault *vmf) > int exclusive = 0; > int ret = 0; Initialization is now unneeded. Otherwise: Acked-by: David Rientjes