Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1690183rwb; Fri, 23 Sep 2022 17:19:19 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7LMG2n8zZVDy2+AN1JCpXG0cyP5M63aGij0wRw54l+zARyGyibcZ3CGgcX+5rJA9x8I2CZ X-Received: by 2002:a17:907:2cca:b0:77d:6542:d912 with SMTP id hg10-20020a1709072cca00b0077d6542d912mr9289161ejc.528.1663978759443; Fri, 23 Sep 2022 17:19:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663978759; cv=none; d=google.com; s=arc-20160816; b=NKqtflbx4eaJjF23UEBg9SWrIdybuv8a1dQOGdKsIPodtsxSOELXvF38/8IAiKfVjo SnBrt27ujuZX6SMDPoPu/ZSGN55/0i2nH6F7D/lXTBHfNtK/xDvm+9+FBe1WPi07VcdF gDv10/r9IwG8F53wiT+WcqAZotnEhK3v6p1gjcuXXOYXA7+fpfbo/w/Aghzh4Rssb1DX v+fNKHdfKJQjjzTwH8l8y2lm4BFsJhPkgiSNuB/potK13IE5YmTAdXNB5juwHltxBl3O JtE8qTyZobzv2dfid+rK3QB5OzpS8T0VAmPXSAWb4dFjnePzIAhfD5pJLSQHZLLXciAv NW8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=5ASiwm1avkHZc/hoLIIFI/eZ/ZpBbfiIv79qS4VlyJQ=; b=BLLocBH4Q1KVYzEDOd/JAQhzXTx7pjNZBgm0ILZvKsZCUmChF3ckzb0A/u5rrib5KA OjLXDMO0G3rhgh6RtcyJUeIBdG7MarPfWLAnZsCk0CklFozlNu7u4XQLUno5aoZoqYH7 nbTK0wRNgnv5RkrwG5PymtpKkyqcFxcYAdTwgSAZDMpxPkpUsGgs06SGl85GOQ6sQUMh X1d9sBDz1VfdqfttZkbiNGOYQ3n8BYgypuaMScy2ivjrOle2WIAhKZcololvMYo1puGc E4UJRX1b2+nei/+s+Ejh44MmrUKURuywy7j/FNeUC1abN2fvsrTGVvuvrHsfES2hIZjE 79lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=S5exWhlg; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id wt1-20020a170906ee8100b0072f1c8d0e62si9554871ejb.95.2022.09.23.17.18.54; Fri, 23 Sep 2022 17:19:19 -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=@ziepe.ca header.s=google header.b=S5exWhlg; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232901AbiIWXVo (ORCPT + 99 others); Fri, 23 Sep 2022 19:21:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232315AbiIWXVj (ORCPT ); Fri, 23 Sep 2022 19:21:39 -0400 Received: from mail-qt1-x835.google.com (mail-qt1-x835.google.com [IPv6:2607:f8b0:4864:20::835]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BB9F12059C for ; Fri, 23 Sep 2022 16:21:38 -0700 (PDT) Received: by mail-qt1-x835.google.com with SMTP id b23so974183qtr.13 for ; Fri, 23 Sep 2022 16:21:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=5ASiwm1avkHZc/hoLIIFI/eZ/ZpBbfiIv79qS4VlyJQ=; b=S5exWhlgK2IwN/41jFZWVgtUOIPgOVHZzklRjzN/LhjEdicvHTUHfUAsCYVTnPVnJ2 pLEkXf8ppCaivB8zKkiV5xHWOxHPCLi3Oh+ndtGqO5/3PUUide2X+tNk9f/o4UzdzyYs l723v+ePlu64jTV7J6j32h1l2vV58qu0PGnwnjWq1iAlo8weVGw4X7p2xu80tzvCf8Bc ooZJQ9qz1n896baC9VOTDnZDGs1Udgq290N5MKBgwJb9UGx/0yIR9beq7q1pXKyuOrOG qyywJClQqtur0GI4MaezATtC6BZH247PjXoZSk168tI57X6i1340gKDYtNSceLs7zRnN PqMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=5ASiwm1avkHZc/hoLIIFI/eZ/ZpBbfiIv79qS4VlyJQ=; b=EVriCRUibLuIilfbBiv0Y6aG64LauZtlsxxes7H8BsXCJgBhDR+oEVOuO6Q7MST1GR qfhSnhLoZN5Mj4T5bIgjfTvmGvL9hLd/CZlzHk6v3PIs8SKmosyBTPBky71daa8VQ92s JRMpvK8g7vsygIDFTNrDiRtv5U1HsTvI5GEA7vBt34jkB5V1XT5VqEywpGhET8hijNsU gzWP0gcw83b19Jk1MtNwCXpdywTVz5LkkE9QnFaI5ZEUBAFne/nAM2CuGQd01OGrlQAO 5BOsTfiw82Adb/h0l886VVkppybz8L5hOz893BkpH4q2OQ35B4RaepYR4ljCou6AHXb1 /Reg== X-Gm-Message-State: ACrzQf3QRRCiTkdnOMuMRHc6dm/CRNSC13e5ifIOlbRgRnBafd79qpYy 088ei1Qn8b0Xn1KD+jGp+VcOTg== X-Received: by 2002:a05:622a:174b:b0:35d:1be5:c65e with SMTP id l11-20020a05622a174b00b0035d1be5c65emr6445841qtk.422.1663975297167; Fri, 23 Sep 2022 16:21:37 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-142-162-113-129.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.162.113.129]) by smtp.gmail.com with ESMTPSA id t83-20020a374656000000b006ce9d6e51f4sm6650434qka.67.2022.09.23.16.21.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Sep 2022 16:21:36 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.95) (envelope-from ) id 1obrzD-0035zj-Lo; Fri, 23 Sep 2022 20:21:35 -0300 Date: Fri, 23 Sep 2022 20:21:35 -0300 From: Jason Gunthorpe To: Logan 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 , Christian =?utf-8?B?S8O2bmln?= , 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 Subject: Re: [PATCH v10 1/8] mm: introduce FOLL_PCI_P2PDMA to gate getting PCI P2PDMA pages Message-ID: 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 23, 2022 at 05:14:11PM -0600, Logan Gunthorpe wrote: > > > 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. No, that is the point, it *always* applies. A devmap struct page of the wrong type should never exit gup, from any path, no matter what. We have two central functions that validate a page is OK to return, that *everyone* must call. If you don't put it there then we will probably miss copying it into a call site eventually. > > 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... That isn't how GUP is structured, all the calls to try_grab_page() are in places where PIN/GET might be set and are safe for that usage. If we know PIN/GET is not set then we don't even need to call the function because it is a NOP. Jason