Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1922902ybe; Thu, 12 Sep 2019 01:30:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqyvsw/aUX5f22/9YxDGRz1U7lqkfXTvgX8GNrXpHZs2R8f8YrUoYnfbai+j5myEu1ucX+1Z X-Received: by 2002:a17:906:350f:: with SMTP id r15mr33567227eja.136.1568277045523; Thu, 12 Sep 2019 01:30:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568277045; cv=none; d=google.com; s=arc-20160816; b=wkCGWTd+agl1fTCkvPLQ/+WP1KsqGQCVTICnmoQ+8k1fI0oBiQFDl1pOGYP+AzkDil 3yb0/f7vOSg0kFlR9fqtWWBlModBGgouuQs9frDTsxsp3p0jPjQrBeqhnFqUZb1tDvEY rPFSPreUWFoVP6gJDMM6hgCIYbRJKG+oiDBt4FwSdLYw1i8jbJoEo3dRyQJvI2PCP74y qOqWF1ciohwSrwwt/fiv5fCSwgqIGM7gfjRHhB/eQDw3HcfV9QX34qbC72Mg9os4vlwr NAJw/ke8WDx1sQxdfAqAus112TWkCopOjiYmILSEJnFYH/erFw2pZF7/RsfDRgw/aLCR gymg== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=OeE9YcTq/b+9y0gybJUQvpM9/6hAyOP3OmcgTQJlC0M=; b=WqJZw2xSQB0rWOYG8RraI2KInmCRk6Ru5jgKfr1Umel3//CpQr3Ku4w8QQg9qZkjbk JonCluMfUOYASWk+Gs1nho1//EOsix7JokCRZwjAl4f4bZehYf6DSEeOcgp6oicaY02R KKLdjHqv7fYKZ4vFSJig8rNbckZ4aU+JR91s03Dn6cUp+R20QFBF2VFeRlHf6VCBhGL0 m8/mNw+nT98yfTVH7AyQbrVrKQW+8pLhyR1D3q3ahkaFVX+YjHXfuWDyWusc9uWIqAI7 RuCoEWzpvHbk5wZSgGnGzb6EAg8N0/fuarjpw8VBCT9WOHKvqDAXxC8mGAV4h/hK9LDx 2fcg== 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 y11si4444262edm.302.2019.09.12.01.30.22; Thu, 12 Sep 2019 01:30: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 S1730227AbfILI0w (ORCPT + 99 others); Thu, 12 Sep 2019 04:26:52 -0400 Received: from verein.lst.de ([213.95.11.211]:45338 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725765AbfILI0v (ORCPT ); Thu, 12 Sep 2019 04:26:51 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 6EA70227A81; Thu, 12 Sep 2019 10:26:48 +0200 (CEST) Date: Thu, 12 Sep 2019 10:26:48 +0200 From: Christoph Hellwig To: Ralph Campbell Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, =?iso-8859-1?B?Suly9G1l?= Glisse , Jason Gunthorpe , Andrew Morton , Christoph Hellwig Subject: Re: [PATCH 2/4] mm/hmm: allow snapshot of the special zero page Message-ID: <20190912082648.GB14368@lst.de> References: <20190911222829.28874-1-rcampbell@nvidia.com> <20190911222829.28874-3-rcampbell@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190911222829.28874-3-rcampbell@nvidia.com> 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, Sep 11, 2019 at 03:28:27PM -0700, Ralph Campbell wrote: > Allow hmm_range_fault() to return success (0) when the CPU pagetable > entry points to the special shared zero page. > The caller can then handle the zero page by possibly clearing device > private memory instead of DMAing a zero page. > > Signed-off-by: Ralph Campbell > Cc: "J?r?me Glisse" > Cc: Jason Gunthorpe > Cc: Christoph Hellwig > --- > mm/hmm.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/hmm.c b/mm/hmm.c > index 06041d4399ff..7217912bef13 100644 > --- a/mm/hmm.c > +++ b/mm/hmm.c > @@ -532,7 +532,7 @@ static int hmm_vma_handle_pte(struct mm_walk *walk, unsigned long addr, > return -EBUSY; > } else if (IS_ENABLED(CONFIG_ARCH_HAS_PTE_SPECIAL) && pte_special(pte)) { > *pfn = range->values[HMM_PFN_SPECIAL]; > - return -EFAULT; > + return is_zero_pfn(pte_pfn(pte)) ? 0 : -EFAULT; Any chance to just use a normal if here: if (!is_zero_pfn(pte_pfn(pte))) return -EFAULT; return 0;