Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1306719ybl; Wed, 14 Aug 2019 14:33:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqw2msd0IHIhcPe0dCzjtpyWC+hfvK/ooNZ6HUmKm6p6lTkO09QUxW1EPsjAAbh1CmTwWweS X-Received: by 2002:a17:90a:fd8c:: with SMTP id cx12mr1627464pjb.95.1565818383366; Wed, 14 Aug 2019 14:33:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565818383; cv=none; d=google.com; s=arc-20160816; b=P+31s57LO5uzYzeqZq6R4FYYKQT3DL0QQFvcvWGn4TIUhAcnoC6ryoL04Kk9YbEWVy 8cVvwHBifmfg4qvSiuiFKFcY19KXNXWyTVCaSXSUkkJciwPhX9TnY0gXLhEmPcuDeqw+ Qz6ndF49UX4Pj9GeT5js0EuNRjNvgEKnX6Ku4SH4qjTiVdjlQ41RkwKB2oHbfQwUdegH Nygt2C9ZjPh4Nf10cWudALjs4SACUgPwJg5Q5RqMrQsm2IABUfvSn9JyH3BLGxAI5k1O F4ftKvxIXQMcRUmvE/E2/OCVkMBQ+N61jORBjBKEjLTeXt7ZN4c006KPxnYA4hDLm71b DRDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=q5g/jOMKlOwEYLFivYM3g535tx3Zkm1ReT5LriUi6Cs=; b=S2uMAj9D8Gy9l5JLBZOKUpD+AqcCDDD8JfmGxIdfCyH7ITrOhxdVmmtwP0DZSueGlu Y5WyOUhOauvx9LOtsCzhuqMPrZiNp5YZe5gjwZzzWuUX7HSAkZZhsYcxYuEvxoi67djD ddNnOoMkwWuDp++FHI85ucDqsRr+mj6K6/027lVEcS/U+FwoZffGeke82uXLbPjPFANq wC8pIPobICahSH8uMPWH/gUDngdzbY36ifD2txtEw+HmurhLBhVmCfpU01aNyLffNasd INZw1Hzq82aEBa8TOIBqZ+jji09aWIvRXki53qd1rKf93bwNusbgYT67kY35ghCg5uQv WuAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=bWazUH1o; 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=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a26si534492pgb.276.2019.08.14.14.32.47; Wed, 14 Aug 2019 14:33:03 -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=@nvidia.com header.s=n1 header.b=bWazUH1o; 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=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727083AbfHNUcV (ORCPT + 99 others); Wed, 14 Aug 2019 16:32:21 -0400 Received: from hqemgate15.nvidia.com ([216.228.121.64]:6708 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726221AbfHNUcU (ORCPT ); Wed, 14 Aug 2019 16:32:20 -0400 Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Wed, 14 Aug 2019 13:32:31 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Wed, 14 Aug 2019 13:32:20 -0700 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Wed, 14 Aug 2019 13:32:20 -0700 Received: from rcampbell-dev.nvidia.com (10.124.1.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 14 Aug 2019 20:32:13 +0000 Subject: Re: [PATCH v3 hmm 02/11] mm/mmu_notifiers: do not speculatively allocate a mmu_notifier_mm To: Jason Gunthorpe , CC: Andrea Arcangeli , Christoph Hellwig , John Hubbard , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , "Kuehling, Felix" , "Alex Deucher" , =?UTF-8?Q?Christian_K=c3=b6nig?= , "David (ChunMing) Zhou" , Dimitri Sivanich , , , , , , , Gavin Shan , Andrea Righi , Jason Gunthorpe References: <20190806231548.25242-1-jgg@ziepe.ca> <20190806231548.25242-3-jgg@ziepe.ca> X-Nvconfidentiality: public From: Ralph Campbell Message-ID: Date: Wed, 14 Aug 2019 13:32:13 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <20190806231548.25242-3-jgg@ziepe.ca> X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1565814751; bh=q5g/jOMKlOwEYLFivYM3g535tx3Zkm1ReT5LriUi6Cs=; h=X-PGP-Universal:Subject:To:CC:References:X-Nvconfidentiality:From: Message-ID:Date:User-Agent:MIME-Version:In-Reply-To: X-Originating-IP:X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=bWazUH1oIGAphw/LWLwGrPnKZAno5v5obKf5t/eNR0RapozA5skQevZ5NNUWMTqSs kQOZhem/RWC7YrXGqUQcoX9RNPOMaSjczbb19BupGsQlBWLQzrHehLyn5MRQxPoeRz uRp+VPoBZXaU5WWDPyHzy/zn86IiYdKiYmtZuXSgMvZILtqwXmEIOyiTigq4o1+c8b VlbXt4UAjtud+BNmrZDyOUAgEsUrePtigZDeaGw1BwQ9WQfGiUlfYRa7z7VO+ymAOg wk1HgI2Ck8lmve8YFdkbz1IbY9uFTOy/smB0ozBuN1+Xs3FmWnPICy4oobSEcCxgmw VWUvGnEtlLyrQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/6/19 4:15 PM, 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 to me. Reviewed-by: Ralph Campbell