Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp4634729imm; Mon, 14 May 2018 10:17:41 -0700 (PDT) X-Google-Smtp-Source: AB8JxZomXW9aSfYaLAtpGW49/1WiJtTkwOaaNYNLHhAmX5MEIeKhIrWLHqfyQ5GENoFK8/gE9J9+ X-Received: by 2002:a17:902:7c94:: with SMTP id y20-v6mr3008420pll.202.1526318261617; Mon, 14 May 2018 10:17:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526318261; cv=none; d=google.com; s=arc-20160816; b=nLl9+cdmlXpN9l5N2MP6G3arwFKy0+JgGtxmC5ALexGfUcsKPdU79D2lCXKSiZW+RB cE6RvY4wrRGwzlbyxe6wVTthQ+sH38O6ypykQsTwmR10xLW1Ys/PL13ZY9oQBukUn9YS MZcOJ+NonNioWekTrLMEYsab1wvUZLrtfwH2abuvXBocbBrfK9RmsOQkQfIqQoV+focr dfoF4HapYIK1vj1+ylloMu8tPREFiOP/44pyRhrrNfeIEcKB6sU1WLncVxLKKlQszXsd ZC5QLpkgZ3MAE5273lUheHNAXXQwKoljAqlGu8O3SAG8GN7USAVP8JDIZpfUAM/jwPcm 6QXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date:from :references:cc:to:subject:arc-authentication-results; bh=rdLAF2bXSSQoJolD22Nhw88oUJVMqw31Oep6fTJIYSo=; b=Wxoe89r4dSSEN17GgjVySFoUEQKm6ldtgEcutf9QT0Gmu4F7jf8JwTxPI091W6plzB NgfykYXCH8NCNa5wz6gbdbUf8DZuf2y9SqUK7uQejsH5nwyAckDHK80zIvUFbVxXkM0h s+0Q/xwUWchYOTnO4QFQEx++LrwQWWIov8wxzl1akppgJUHG6Ws/IZdYXXOOoR982x+r 8N/9tRQ2GGHtO95CejDANjRr9j7c8CPHFGed3OFOO69qtttyXeMLuhSapBTOKEtTKzBG VhXoqKew0Xpsmjvcib/Eq9pDFl/6QEmEqg+anaZHZjQ46BLapgwJCz1LTIEw6F7UsJYw tmnw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 69-v6si10343267plc.436.2018.05.14.10.17.27; Mon, 14 May 2018 10:17:41 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932610AbeENPKF (ORCPT + 99 others); Mon, 14 May 2018 11:10:05 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:43836 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752311AbeENPKD (ORCPT ); Mon, 14 May 2018 11:10:03 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w4EF6T0u140953 for ; Mon, 14 May 2018 11:10:03 -0400 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 2hyct506ev-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 14 May 2018 11:10:03 -0400 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 14 May 2018 16:10:00 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 14 May 2018 16:09:50 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w4EF9no52294246; Mon, 14 May 2018 15:09:49 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DD70452047; Mon, 14 May 2018 15:00:00 +0100 (BST) Received: from [9.101.4.33] (unknown [9.101.4.33]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 8D6B552043; Mon, 14 May 2018 14:59:59 +0100 (BST) Subject: Re: [PATCH v10 06/25] mm: make pte_unmap_same compatible with SPF To: vinayak menon 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 References: <1523975611-15978-1-git-send-email-ldufour@linux.vnet.ibm.com> <1523975611-15978-7-git-send-email-ldufour@linux.vnet.ibm.com> From: Laurent Dufour Date: Mon, 14 May 2018 17:09:48 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 18051415-0008-0000-0000-000004F65F67 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18051415-0009-0000-0000-00001E8ABF88 Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-05-14_04:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1805140156 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/05/2018 18:15, vinayak menon wrote: > 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 ? Indeed there is no chance that the macro VM_FAULT_RESULT_TRACE would have to translate that code to a string since VM_FAULT_PTNOTSAME is currently only returned by pte_unmap_same() and then converted by its only caller do_swap_page() to return 0. So VM_FAULT_PTNOTSAME is not expected to be seen outside of these services which are never using VM_FAULT_RESULT_TRACE(). This being said, this may be a good idea to add it in the case of future potential usage.