Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp6435884ybh; Thu, 8 Aug 2019 00:01:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqy10qKW0j1pd9JoL2/0PSbG456CYjxDVuc/4pL+IN9Gf6sOJxBbvBeEunptH4O2gTIu2NU8 X-Received: by 2002:a17:90a:2190:: with SMTP id q16mr2421062pjc.23.1565247705966; Thu, 08 Aug 2019 00:01:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565247705; cv=none; d=google.com; s=arc-20160816; b=yUlKxs4WaKpz9TiIWWTgDKHmmAxCFKfFqkwM5eO5LsChc5P4AOBgddbKYmyWqEdMUh TiqUPxD63N/HuYM+hJHaufHN2vZC2UJWoNV7eSR409+gAiLONRzl+ZWXH7G3EdCOOT+D eap6rLP9hLTWhWKk9HUP8CSiFcGE/bn1CUMhVu12GI2IcItNSx1JREY1pYRZqVN4tn2U 6QHLywjaOTIFRxZyhPU2mQfxpa/fXwN9bRvNFB5Vwlb/YMQ7IzWYmlyxqcn9KDznVf9h 4rSHqWvO96pOJhSBzIKguF3a8xxanwchBi8V5nYkIFNR7S5CYFn/z2LDjd59oSoOJdD0 QfrQ== 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=4PGz37ROPIjgASVITDVN9LnvP6bYDz+C4QCRlM2A9h4=; b=MDDJcX4rK/NB3C1Kp+IoKADXoQ7ArpOqLnhyiGx+1MXk3Ujfhj1Hb4X6gxajwryLCq go9UY9qEv8br/tE/dlf7nA9Bdd+Bx6W0/rx/ZTx8gaE5FJX9m9NnJCypmvuf0I5BhkXz sNEyK7X/15S/agiX0LiWSBPC7uXYUZ1v38CL5cZ75e+KJyk6cVEnydkRWG1g8T4zBoQ3 Z79gbmJSk+hlizO+XEIQcwmzG1U1rBGdtfOvXv0/0VOpe0XKCEzrHhmzZeZjH9axUUlB 38BL5YH2fjE0CAv6JLksbZxgVoQ5QsDdF3/TJCVIysgqfvWKpeT1qCpRYuaTDMwnThR2 K94g== 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 z9si43774843pgk.46.2019.08.08.00.01.29; Thu, 08 Aug 2019 00:01:45 -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 S1731184AbfHHG7h (ORCPT + 99 others); Thu, 8 Aug 2019 02:59:37 -0400 Received: from verein.lst.de ([213.95.11.211]:43750 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725796AbfHHG7h (ORCPT ); Thu, 8 Aug 2019 02:59:37 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id D398268AEF; Thu, 8 Aug 2019 08:59:33 +0200 (CEST) Date: Thu, 8 Aug 2019 08:59:33 +0200 From: Christoph Hellwig To: Dan Williams Cc: Jason Gunthorpe , Christoph Hellwig , =?iso-8859-1?B?Suly9G1l?= Glisse , Ben Skeggs , Felix Kuehling , Ralph Campbell , "linux-mm@kvack.org" , "nouveau@lists.freedesktop.org" , "dri-devel@lists.freedesktop.org" , "amd-gfx@lists.freedesktop.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH 04/15] mm: remove the pgmap field from struct hmm_vma_walk Message-ID: <20190808065933.GA29382@lst.de> References: <20190806160554.14046-1-hch@lst.de> <20190806160554.14046-5-hch@lst.de> <20190807174548.GJ1571@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Wed, Aug 07, 2019 at 11:47:22AM -0700, Dan Williams wrote: > > Unrelated to this patch, but what is the point of getting checking > > that the pgmap exists for the page and then immediately releasing it? > > This code has this pattern in several places. > > > > It feels racy > > Agree, not sure what the intent is here. The only other reason call > get_dev_pagemap() is to just check in general if the pfn is indeed > owned by some ZONE_DEVICE instance, but if the intent is to make sure > the device is still attached/enabled that check is invalidated at > put_dev_pagemap(). > > If it's the former case, validating ZONE_DEVICE pfns, I imagine we can > do something cheaper with a helper that is on the order of the same > cost as pfn_valid(). I.e. replace PTE_DEVMAP with a mem_section flag > or something similar. The hmm literally never dereferences the pgmap, so validity checking is the only explanation for it. > > + /* > > + * We do put_dev_pagemap() here so that we can leverage > > + * get_dev_pagemap() optimization which will not re-take a > > + * reference on a pgmap if we already have one. > > + */ > > + if (hmm_vma_walk->pgmap) > > + put_dev_pagemap(hmm_vma_walk->pgmap); > > + > > Seems ok, but only if the caller is guaranteeing that the range does > not span outside of a single pagemap instance. If that guarantee is > met why not just have the caller pass in a pinned pagemap? If that > guarantee is not met, then I think we're back to your race concern. It iterates over multiple ptes in a non-huge pmd. Is there any kind of limitations on different pgmap instances inside a pmd? I can't think of one, so this might actually be a bug.