Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp6641581ybh; Thu, 8 Aug 2019 03:28:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqyFZ1iWWMO89gvP1TcE36kCJKNjgk7Wj8J/h7+JaXXqCvgNa2+gBBTQ6WkZMqhK4X8abG3G X-Received: by 2002:a17:90a:ad41:: with SMTP id w1mr3312199pjv.52.1565260099381; Thu, 08 Aug 2019 03:28:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565260099; cv=none; d=google.com; s=arc-20160816; b=KDoU7Drx10WOP1xa2m8UgvIrJw0nwjO3usySr/EmYh1HA0UqSiIv8JPFeCJXCU1e+E uLRPMOQS3Bb+3n86zbrR3S9GCdvMlI+fG1ZXxGRw+k0evsPKgLd338M/yZ+MZjcg1cwn T3dqCXPfzaAh953SRnkiSTLFZlVJazHxZHIBCNEJpZcQBxHbAc4X3WJjlIVUOolevFAx sQzZyBGiGVR4GTqwbq74TKjCk1nli29cdRvZtz1hwmDmZu3cb8PlhpguI1eQz6k6l5yX aKm7Z7TAB9PSg13s/XvgokuqpwC3/oklVxGwNwNwThMKOaC9yHaMHilDDBYjvf3HfDGA V9Rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=kW8zuazzNE9wLabfrrhykpKeWzoQ/jJUoB11n83RL58=; b=qplR8duuZpfoBWrn3a2jzU3Qn7gRR/MfWOZeeVU+zz2XStv7urfz1wXhGRoGAbYpCo lVDQHu60z0ZoJl+voRPUKIFTjq3nHEQTWvYOH4brGvZ2loC5Fi0MaBOVXjZ9+WcAp8CB ix/t3difSRGURciXt1bM7DkjvEyxlbluyQJi957LIz7h85WJbg0TWd8XUOvZDxyKoRSW 3IyEGRRhaCUUTrre4YehJY/xwXo5jmAtxHB0e24hiGhlGwLqm3qGPhg2hq5Z6v/DK5sj pRP/MWOh8Wm7uXYi4YbiE56GNX+JX7rNhR61nh4/xt82ryH8+0QVaUxxylz0szswlc2A SCKA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v16si53631007pfi.142.2019.08.08.03.28.04; Thu, 08 Aug 2019 03:28:19 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390015AbfHHK0z (ORCPT + 99 others); Thu, 8 Aug 2019 06:26:55 -0400 Received: from verein.lst.de ([213.95.11.211]:45417 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389947AbfHHK0z (ORCPT ); Thu, 8 Aug 2019 06:26:55 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 8BF8768B02; Thu, 8 Aug 2019 12:26:52 +0200 (CEST) Date: Thu, 8 Aug 2019 12:26:52 +0200 From: Christoph Hellwig To: Jason Gunthorpe Cc: linux-mm@kvack.org, Andrea Arcangeli , Christoph Hellwig , John Hubbard , =?iso-8859-1?B?Suly9G1l?= Glisse , Ralph Campbell , "Kuehling, Felix" , Alex Deucher , Christian =?iso-8859-1?Q?K=F6nig?= , "David (ChunMing) Zhou" , Dimitri Sivanich , dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, iommu@lists.linux-foundation.org, intel-gfx@lists.freedesktop.org, Gavin Shan , Andrea Righi , Jason Gunthorpe Subject: Re: [PATCH v3 hmm 02/11] mm/mmu_notifiers: do not speculatively allocate a mmu_notifier_mm Message-ID: <20190808102652.GC648@lst.de> References: <20190806231548.25242-1-jgg@ziepe.ca> <20190806231548.25242-3-jgg@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190806231548.25242-3-jgg@ziepe.ca> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 06, 2019 at 08:15:39PM -0300, Jason Gunthorpe wrote: > From: Jason Gunthorpe > > A prior commit e0f3c3f78da2 ("mm/mmu_notifier: init notifier if necessary") > made an attempt at doing this, but had to be reverted as calling > the GFP_KERNEL allocator under the i_mmap_mutex causes deadlock, see > commit 35cfa2b0b491 ("mm/mmu_notifier: allocate mmu_notifier in advance"). > > However, we can avoid that problem by doing the allocation only under > the mmap_sem, which is already happening. > > Since all writers to mm->mmu_notifier_mm hold the write side of the > mmap_sem reading it under that sem is deterministic and we can use that to > decide if the allocation path is required, without speculation. > > The actual update to mmu_notifier_mm must still be done under the > mm_take_all_locks() to ensure read-side coherency. > > Signed-off-by: Jason Gunthorpe Looks good, Reviewed-by: Christoph Hellwig