Received: by 10.213.65.68 with SMTP id h4csp2912396imn; Mon, 2 Apr 2018 16:58:34 -0700 (PDT) X-Google-Smtp-Source: AIpwx495LVWjRjmgXYtIpXviLTJtnW0oj+U+xTK1owKSj/wFWUy2MWN2Otc2xsyd9ymuWfKch3is X-Received: by 2002:a17:902:bc45:: with SMTP id t5-v6mr11650005plz.343.1522713514605; Mon, 02 Apr 2018 16:58:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522713514; cv=none; d=google.com; s=arc-20160816; b=aM3sG3igXYH024eQTah/ymYHcNnoqkOq4/uuqNK0b49WWEibIanpepTxJWambael3z L4KQ/UylwohIkDN9rihYVUBaMmLh+v9qSEwUeyksSzNHquWAJFef8rPQEdAeLkwOZF5g lMbq2GLrnYtP9av/ElzOmfdmCs41NnL1L1bfI630grDWWBtZv0+48AYo6fypzLBpMKcQ IWWcrVmY3NfUwCV1an2krLg1/+zANS1nkWtT8OxkzXH8Z5DGGAHOq4V/VmNmnjuh8tPR Xbftr24TXVrW0Kkxgz9LAtU5ZmbAkkJIa9TCcDtSoLYWYh7AmWsSdRpPsXpBDImoF/AM eSlg== 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=v6qG88peUM176LU7xTZa7ACZuxf07DcuIQiTgRRE1i0=; b=KP0+RZ9mjk1azlHiy5bEtSlyp/eaiawegHEROA3JXjHQcWtt7gLVFbm1fytpNaWANV ajNjnZ6OB5o4jzsDgRkbFZMR+dHd9q7+XqXM0xXHZm+pC4S4LKDqWVqWlqJ3pzdM6XwK xOQF0QVBLfYaQN/Yzcid2/kRUOhlBhu+O0bc2Aod7dA16oR7Vvw4cnTDbguYomMl/pQs kzf4mXNVH02ED1lCQN0Wpf368H29kbCFNhMN7uY6BP+t7esU/sKAyyChxKOwlWmM753h CvfQSIiV4omVDnh8oFPNVpe9h3CENMu4YqmoX9igSYJeadGlWHdMXRkIBIbSn3MWgBgS cf7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=qK0e/0BZ; 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 11-v6si1410885plb.658.2018.04.02.16.58.19; Mon, 02 Apr 2018 16:58:34 -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=qK0e/0BZ; 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 S1754680AbeDBX5H (ORCPT + 99 others); Mon, 2 Apr 2018 19:57:07 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:44808 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754550AbeDBX5G (ORCPT ); Mon, 2 Apr 2018 19:57:06 -0400 Received: by mail-pl0-f67.google.com with SMTP id b6-v6so4346911pla.11 for ; Mon, 02 Apr 2018 16:57:06 -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=v6qG88peUM176LU7xTZa7ACZuxf07DcuIQiTgRRE1i0=; b=qK0e/0BZ62xUH0MOJzAN7xGDYHosaCQzHP5Tg7mImZKHMPvuPuNNSP8qxPK17t7b07 9dKXJBgnl67w2Y1/CrCm66Nd9lWncVphbStLg6bzJ0ffgROOpIludHUITkqQRjbVOaIR fzk28IAgOlUh02paghNsTFyuw7UHkILl1wf6gUgBMNlZl7LztynMdg+p536edHH27gDg 8zgpYm3BQlqmeiibieqWVJuj05FYmjf/IxXSyj7lIDcz4Ttv+2rf30YU3PpwDM8ekWX9 AR/uAYkZhfhyt6quMn8tEF+U1EvGWMLupaW1oIFjwI/y0q15edyxtkj8wIwg/XVAqVUt Ov7A== 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=v6qG88peUM176LU7xTZa7ACZuxf07DcuIQiTgRRE1i0=; b=gJkp3DOYX3Z9hBYb6o/eopPrVjt1REhfKOUubjDBcVjuBusVvqNnHZh9ZTCw4FkYG4 TAA/tnU4N5ky7yLPP55ryXNuIaRXHcI96R9j7Ne12D/Mo5wFeREAFBQ6aIigE55NWRsb DVOwwQ82Nlefxh8f5srfL3vEtv0eM7AqjW6GOsdDu48riruLk9z8ZZmUo9lXmnvfvekO JOroq+sqSNh5m5z7GEmVVJo2j+C1o7VL61RGwomiurh8GVzyZLcCvhmko3Zza1AH6leo odqLMndQRRXn5gkpdKtBds0NzoWw46nypn08vuFiSy8hlJQ8eK+dYFrzH1aiIJCaRCus Mjgw== X-Gm-Message-State: AElRT7FtlDrF+Uu4bbIjxfwUWiVgaAe8xLvWyWu5XqUyRaTwi3hoO6Ju pDkvAYL0IXnhrpVAp0wZsJdYWQ== X-Received: by 10.99.112.92 with SMTP id a28mr7405193pgn.17.1522713425320; Mon, 02 Apr 2018 16:57:05 -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 c28sm2639438pfe.27.2018.04.02.16.57.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Apr 2018 16:57:04 -0700 (PDT) Date: Mon, 2 Apr 2018 16:57:03 -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 16/24] mm: Introduce __page_add_new_anon_rmap() In-Reply-To: <1520963994-28477-17-git-send-email-ldufour@linux.vnet.ibm.com> Message-ID: References: <1520963994-28477-1-git-send-email-ldufour@linux.vnet.ibm.com> <1520963994-28477-17-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: > 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.