Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1662503rwb; Fri, 23 Sep 2022 16:47:03 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5BFD6LSfYk4PgyHl+YL+3lr/KAwoVlJRmfC9bykw4g2g7hnKGNpfhQxO/c5bs0F+4AmswZ X-Received: by 2002:aa7:dd0a:0:b0:44e:a27b:fec with SMTP id i10-20020aa7dd0a000000b0044ea27b0fecmr10499339edv.168.1663976823233; Fri, 23 Sep 2022 16:47:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663976823; cv=none; d=google.com; s=arc-20160816; b=yjZtGu0Xz1HHqmTWqeAuV/oN0R/hYa0PjD5XV4sL6JDodAhw90qIY9N3gxDN1nh2fn Fbu3da2yRnjSwdDDuipIj1C8JboexjvrQV6zjN9WMVAPClh4u6oK9QqzrFxcj7oXo7Vq Uw7n5mahEP7gyAbDm5H9lUysTO8EPlhwG57QHVekZzm0gEsq7LZs834ZlO4WhqKxLQ40 AXsLW1gmiLaXtSsdjAIbFOYVFpdUtd13WK/F+CkfDcwJ6SKPSv8Hb8PBkubAYcR3KgKs zKgOSdUovatjJmGKNDUt7EB8FiHk5pdvVaUdzp533StpUtPR6LMx8ntv7+5oBr+kCFs9 9o/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:content-transfer-encoding:in-reply-to :from:references:cc:to:content-language:user-agent:mime-version:date :message-id:dkim-signature; bh=5kMEPhzVXTTbbICaU8r7DWXEcfo3/fUnkZgSNRbVGrQ=; b=vF2uE0BW0Ni+zpX70Dbr7T67EUt/t8Ku/I34mtKFjHhuLqY6nDu+ei/DCsN9BxJjDd tZhB7wAubH+WiGClkjxvvwxO+8y9v1kDZKZ2KATiMYuMkNchWAWYJKWEu8o1ZOzUECKw YTQ09jYPbqoeseK5Offrj9dfJe9rPdETR/SpkYH9FzdvlPSz4rOQIdMRCKDWyLEpaA2W eT/lazVZU3Gesf9HfmxU1rwLBvOyIt0s+Yf1pQuJgh9jw5yh3wJDLRv1bahqJYIyHJFj LUra0BgKLxjMQKDZ+m5d6AeTim8HjK8CjQmJjMe/6s4heqOA6n6M94TeX4YbI9bIT0Np nzIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b=Ds5pkHy8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=deltatee.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g4-20020a17090669c400b0073d8e4e8c77si6995877ejs.1005.2022.09.23.16.46.32; Fri, 23 Sep 2022 16:47:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b=Ds5pkHy8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=deltatee.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232860AbiIWXOT (ORCPT + 99 others); Fri, 23 Sep 2022 19:14:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230495AbiIWXOR (ORCPT ); Fri, 23 Sep 2022 19:14:17 -0400 Received: from ale.deltatee.com (ale.deltatee.com [204.191.154.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 132921288B8; Fri, 23 Sep 2022 16:14:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=deltatee.com; s=20200525; h=Subject:In-Reply-To:From:References:Cc:To: MIME-Version:Date:Message-ID:content-disposition; bh=5kMEPhzVXTTbbICaU8r7DWXEcfo3/fUnkZgSNRbVGrQ=; b=Ds5pkHy8uJ8iHLx1IhVZslc3Zr t+/v6e2S0GOtygp04iEzUQ4muWRW49cSuHskBcPhKEmScyKVVNbv1b0IEIEm4288vPB2ORsUShnrR 5b0ZNRvCvlMo3b/OgyG61P2rlIrRtuEe3C4OiOnSLdRflOjXh5VLRa20wpoNzxJ6JNQGv6rSbiZWU AD0pz04P15zsrIEz9+33+KxiyTKqT+9rfjT16tZREnE4SsZ6WCMRf/n7BHgLJrLNv2vLvF2cOEW+t jBCLX28uFxceZJK6OCyyhhrZ6v4TJQcfX0pMKJQ7kJ5MvS616Y2UkZGuSWQKg0hDO0SjNHIt790HB GyuZbEuw==; Received: from s0106a84e3fe8c3f3.cg.shawcable.net ([24.64.144.200] helo=[192.168.0.10]) by ale.deltatee.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1obrs5-0090pq-Lv; Fri, 23 Sep 2022 17:14:14 -0600 Message-ID: Date: Fri, 23 Sep 2022 17:14:11 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.13.0 Content-Language: en-CA To: Jason Gunthorpe Cc: linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, linux-mm@kvack.org, Christoph Hellwig , Greg Kroah-Hartman , Dan Williams , =?UTF-8?Q?Christian_K=c3=b6nig?= , John Hubbard , Don Dutile , Matthew Wilcox , Daniel Vetter , Minturn Dave B , Jason Ekstrand , Dave Hansen , Xiong Jianxin , Bjorn Helgaas , Ira Weiny , Robin Murphy , Martin Oliveira , Chaitanya Kulkarni , Ralph Campbell , Stephen Bates References: <20220922163926.7077-1-logang@deltatee.com> <20220922163926.7077-2-logang@deltatee.com> <64f8da81-7803-4db4-73da-a158295cbc9c@deltatee.com> <2327d393-af5c-3f4c-b9b9-6852b9d72f90@deltatee.com> <3840c1c6-3a5c-2286-e577-949f0d4ea7a6@deltatee.com> From: Logan Gunthorpe In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 24.64.144.200 X-SA-Exim-Rcpt-To: jgg@ziepe.ca, linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, linux-mm@kvack.org, hch@lst.de, gregkh@linuxfoundation.org, dan.j.williams@intel.com, christian.koenig@amd.com, jhubbard@nvidia.com, ddutile@redhat.com, willy@infradead.org, daniel.vetter@ffwll.ch, dave.b.minturn@intel.com, jason@jlekstrand.net, dave.hansen@linux.intel.com, jianxin.xiong@intel.com, helgaas@kernel.org, ira.weiny@intel.com, robin.murphy@arm.com, martin.oliveira@eideticom.com, ckulkarnilinux@gmail.com, rcampbell@nvidia.com, sbates@raithlin.com X-SA-Exim-Mail-From: logang@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 Subject: Re: [PATCH v10 1/8] mm: introduce FOLL_PCI_P2PDMA to gate getting PCI P2PDMA pages X-SA-Exim-Version: 4.2.1 (built Sat, 13 Feb 2021 17:57:42 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022-09-23 17:07, Jason Gunthorpe wrote: > On Fri, Sep 23, 2022 at 05:01:26PM -0600, Logan Gunthorpe wrote: >> >> >> >> On 2022-09-23 16:58, Jason Gunthorpe wrote: >>> On Fri, Sep 23, 2022 at 02:11:03PM -0600, Logan Gunthorpe wrote: >>>> >>>> >>>> On 2022-09-23 13:53, Jason Gunthorpe wrote: >>>>> On Fri, Sep 23, 2022 at 01:08:31PM -0600, Logan Gunthorpe wrote: >>>>> I'm encouraging Dan to work on better infrastructure in pgmap core >>>>> because every pgmap implementation has this issue currently. >>>>> >>>>> For that reason it is probably not so relavent to this series. >>>>> >>>>> Perhaps just clarify in the commit message that the FOLL_LONGTERM >>>>> restriction is to copy DAX until the pgmap page refcounts are fixed. >>>> >>>> Ok, I'll add that note. >>>> >>>> Per the fix for the try_grab_page(), to me it doesn't fit well in >>>> try_grab_page() without doing a bunch of cleanup to change the >>>> error handling, and the same would have to be added to try_grab_folio(). >>>> So I think it's better to leave it where it was, but move it below the >>>> respective grab calls. Does the incremental patch below look correct? >>> >>> Oh? I was thinking of just a very simple thing: >> >> Really would like it to return -EREMOTEIO instead of -ENOMEM as that's the >> error used for bad P2PDMA page everywhere. > > I'd rather not see GUP made more fragile just for that.. Not sure how that's more fragile... You're way seems more dangerous given the large number of call sites we are adding it to when it might not apply. > >> Plus the concern that some of the callsites of try_grab_page() might not have >> a get or a pin and thus it's not safe which was the whole point of the change >> anyway. > > try_grab_page() calls folio_ref_inc(), that is only legal if it knows > the page is already a valid pointer under the PTLs, so it is safe to > check the pgmap as well. My point is it doesn't get a reference or a pin unless FOLL_PIN or FOLL_GET is set and the documentation states that neither might be set, in which case folio_ref_inc() will not be called... Logan