Received: by 10.213.65.68 with SMTP id h4csp4123246imn; Tue, 10 Apr 2018 09:33:58 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/hBTJlMLuS70rR7v+NbWz+g6kmMPLXBFrP6Dnm2GapNPC+9cWM/w0MI55g/BAd7ye0Q2RR X-Received: by 2002:a17:902:be15:: with SMTP id r21-v6mr1164732pls.237.1523378038762; Tue, 10 Apr 2018 09:33:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523378038; cv=none; d=google.com; s=arc-20160816; b=Dpv0iui4Ga5y+GRKmT27/dKu/4jSrTL6aaYVfwyQEMgbN55J7Vj2X6jchIgvXmUxv1 WaXCt641F4QadE+bbzbVP7FTbLvL5RPh426Cb7cSVbDLuObCMmFqkOEKLHp3RTCjkugq A/ROlDdHMvSbcC6sbK7XU1aOrp+dtzMeyB6pY9/UYxOBWZaFc0jIikx7qI4FTij1/MOr gBcGcQLPcklCRIZs6QY5OwVkF0U6D+d0s8LpjNX8BUZJBg11v7mWCstDovPjjBng4n4F 0nteQH5dHN05S6Yx/X4uT++7MAdMLuiVKJt0rRJftjTZu6DasUMloZxsCvUPvVy3GSie ax8w== 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=8HuNrK1EnuVmbycU54HYRVTP4z/b1+ZDH2VGGvMZgns=; b=t1K7o0YzyAv7k0gjvI5eOEGdY/6i655FFuXG7gsHycwdaN6alKtboA30rWwwubBh4w B8QT6K3f57yqGLZQZe5uGGOV9yWTldIrGs5xcbJfhLf8d6PcZonnwbszojPLDXrT0ntu 8cIXztibbBJTXqc4zJA4At9ibGDENTCBL9tyiH5FVBo7scfxj60mYQFLLX2XnWudZ3xe m371JcS+T7dhm8BKCm0A5T5g52noyAbDHTsFEF7svS/6u714cYNVUV+M0zOCHiUfcEZ4 GpemE6e9t4e/QJ2F69b9krrxFYXP+Y1UGQE3KwlvEaRc6VKEp5ZtowI0deq5/J+nzIlC jufQ== 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 c10-v6si3038248pla.602.2018.04.10.09.33.20; Tue, 10 Apr 2018 09:33:58 -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 S1751888AbeDJQaf (ORCPT + 99 others); Tue, 10 Apr 2018 12:30:35 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:44904 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751504AbeDJQac (ORCPT ); Tue, 10 Apr 2018 12:30:32 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w3AGQLkx123267 for ; Tue, 10 Apr 2018 12:30:32 -0400 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0a-001b2d01.pphosted.com with ESMTP id 2h8wf2kchm-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Tue, 10 Apr 2018 12:30:29 -0400 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 10 Apr 2018 17:30:21 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 10 Apr 2018 17:30:14 +0100 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w3AGUDDn10355006; Tue, 10 Apr 2018 16:30:13 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2E420A4057; Tue, 10 Apr 2018 17:22:32 +0100 (BST) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0D48AA404D; Tue, 10 Apr 2018 17:22:31 +0100 (BST) Received: from [9.101.4.33] (unknown [9.101.4.33]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 10 Apr 2018 17:22:30 +0100 (BST) Subject: Re: [PATCH v9 16/24] mm: Introduce __page_add_new_anon_rmap() To: David Rientjes 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 References: <1520963994-28477-1-git-send-email-ldufour@linux.vnet.ibm.com> <1520963994-28477-17-git-send-email-ldufour@linux.vnet.ibm.com> From: Laurent Dufour Date: Tue, 10 Apr 2018 18:30:12 +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: 18041016-0012-0000-0000-000005C93CA7 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18041016-0013-0000-0000-000019456923 Message-Id: <0a19747c-8516-d322-9c4f-b6ec41b4dea7@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-04-10_05:,, 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=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1804100157 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/04/2018 01:57, David Rientjes wrote: > On Tue, 13 Mar 2018, Laurent Dufour wrote: > >> When dealing with speculative page fault handler, we may race with VMA >> being split or merged. In this case the vma->vm_start and vm->vm_end >> fields may not match the address the page fault is occurring. >> >> This can only happens when the VMA is split but in that case, the >> anon_vma pointer of the new VMA will be the same as the original one, >> because in __split_vma the new->anon_vma is set to src->anon_vma when >> *new = *vma. >> >> So even if the VMA boundaries are not correct, the anon_vma pointer is >> still valid. >> >> If the VMA has been merged, then the VMA in which it has been merged >> must have the same anon_vma pointer otherwise the merge can't be done. >> >> So in all the case we know that the anon_vma is valid, since we have >> checked before starting the speculative page fault that the anon_vma >> pointer is valid for this VMA and since there is an anon_vma this >> means that at one time a page has been backed and that before the VMA >> is cleaned, the page table lock would have to be grab to clean the >> PTE, and the anon_vma field is checked once the PTE is locked. >> >> This patch introduce a new __page_add_new_anon_rmap() service which >> doesn't check for the VMA boundaries, and create a new inline one >> which do the check. >> >> When called from a page fault handler, if this is not a speculative one, >> there is a guarantee that vm_start and vm_end match the faulting address, >> so this check is useless. In the context of the speculative page fault >> handler, this check may be wrong but anon_vma is still valid as explained >> above. >> >> Signed-off-by: Laurent Dufour > > I'm indifferent on this: it could be argued both sides that the new > function and its variant for a simple VM_BUG_ON() isn't worth it and it > would should rather be done in the callers of page_add_new_anon_rmap(). > It feels like it would be better left to the caller and add a comment to > page_add_anon_rmap() itself in mm/rmap.c. Well there are 11 calls to page_add_new_anon_rmap() which will need to be impacted and future ones too. By introducing __page_add_new_anon_rmap() my goal was to make clear that this call is *special* and that calling it is not the usual way. This also implies that most of the time the check is done (when build with the right config) and that we will not miss some.