From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E044C07E9D for ; Fri, 23 Sep 2022 23:07:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A26048002E; Fri, 23 Sep 2022 19:07:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9D54880016; Fri, 23 Sep 2022 19:07:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8766A8002E; Fri, 23 Sep 2022 19:07:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 7664280016 for ; Fri, 23 Sep 2022 19:07:07 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 551B28029F for ; Fri, 23 Sep 2022 23:07:07 +0000 (UTC) X-FDA: 79944887694.01.8CB11E8 Received: from mail-qv1-f50.google.com (mail-qv1-f50.google.com [209.85.219.50]) by imf03.hostedemail.com (Postfix) with ESMTP id 063932002E for ; Fri, 23 Sep 2022 23:07:06 +0000 (UTC) Received: by mail-qv1-f50.google.com with SMTP id ml1so896907qvb.1 for ; Fri, 23 Sep 2022 16:07:06 -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=EIl/nh29zH96tBjnO04+Za75Ipkt6sGk6uA16GsQuRo=; b=N+P38VAwzWrwNueTpnqYlcaO4Wwnh/yvGq5CrXQr+MEOIhsLJzkhHRaRGlZLxg+iey DYr2P/LNZNK9n8+I1zZMzIFj51vuzJpoC/m6kBz0D1tYPDZ6pEQe8GzyI442cqFVxiHs wgixALrJy9vDVOcBb3BWDjBnsAdri1GFyNtMW7PTfPV/gW7darPtzbWpjT5+YijAFkh2 sYZcC248zBfiR8rnutPUSujZoc23CLex/qcIRD66Y3nxp7dTNL45L/IGXi6TOqDyE6yp clE87f/yyT0iJMg+J2x0ANJoOmOZGBzm4thw9YJeTmp1I8o7NCi4TQmNWzW+JQtcekVG cktQ== 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=EIl/nh29zH96tBjnO04+Za75Ipkt6sGk6uA16GsQuRo=; b=DvUvWhavJvbfFOxc0/0vk2ZkQv8GZVxUfMfbVAa6Jy0+IBZmtIefX5jlkxOOIITZPc u3LiUCGCPNw13sUkjdskZBY7t/4IgLTMJMvKGVM5cErJrRpGqKx+vP61gT7YNrtyrPM6 dwWbkntD7QpLYFdgQnLoOXvuGt2NshVO74h5+yfxqPZ1j9wZInc2xEJ/1pO32GYKJNPw p/pbc5oEuQOcS6w8Tz/Dkbw139de60t1voYI2azTNRcoYmYauBPgZ7EXKybbtDZI0DUw RfnTDXaU/mlTjDJbnjs+ahZergr2q87peg10SV1h8O6oPCORe8pdFNxefcXC5StcvRDr WT2Q== X-Gm-Message-State: ACrzQf0zuv6oiOJgcklmJuCyIPaKu6/jGLSpaQc9a2Jzl6TFNEnyxTLn FLIGu/cLHwGnPJYY6fYOl/LhUQ== X-Google-Smtp-Source: AMsMyM4x5J2YZQ9LKsbzLk51XuSjAC/sL+Lbezcs8blw3lr1IQ0ZrvcYT8N/ZbZG9tkfXdkD76Kbrw== X-Received: by 2002:a05:6214:2467:b0:4a2:e191:46b7 with SMTP id im7-20020a056214246700b004a2e19146b7mr9012870qvb.112.1663974426313; Fri, 23 Sep 2022 16:07:06 -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 b13-20020a05622a020d00b0035a6f14b3cesm6656906qtx.27.2022.09.23.16.07.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Sep 2022 16:07:05 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.95) (envelope-from ) id 1obrlA-0035kF-QP; Fri, 23 Sep 2022 20:07:04 -0300 Date: Fri, 23 Sep 2022 20:07:04 -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: <3840c1c6-3a5c-2286-e577-949f0d4ea7a6@deltatee.com> ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663974427; a=rsa-sha256; cv=none; b=MAB7OVO7NCGr7W339asYy9YW3yjy72+iBfhLmhVtxW09blQjC+X/+YTCoz/y9yN9AU9GXc ls2jkttzbsAfRW7SGZDfnz2qzKbc5MhsRU+26eXaG1oK6YOwdVD4HDBliCoIe0RNWSlqpn qQOc111sKHF49idgJZOXWqOZeiiFUIU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663974427; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=EIl/nh29zH96tBjnO04+Za75Ipkt6sGk6uA16GsQuRo=; b=ne+B0LHzYPpYw45KmNw/DhWu/de7PGxSAvzklzWFgxgXHZrMofkIUNt/4uvPS+ijtYrpZe TVu9af6CATrdOaJq/U6KVYIKWcynVzRsB1YsOk7dP53EQXXhROapxQ94NohXeqCpEuq7HL lQHyKZ/nNXs7fTflS7UUsdaxvyywOBI= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=ziepe.ca header.s=google header.b=N+P38VAw; spf=pass (imf03.hostedemail.com: domain of jgg@ziepe.ca designates 209.85.219.50 as permitted sender) smtp.mailfrom=jgg@ziepe.ca; dmarc=none X-Stat-Signature: k1frw5m8r9u4983abqb56z9qzatnohfy X-Rspamd-Queue-Id: 063932002E Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=ziepe.ca header.s=google header.b=N+P38VAw; spf=pass (imf03.hostedemail.com: domain of jgg@ziepe.ca designates 209.85.219.50 as permitted sender) smtp.mailfrom=jgg@ziepe.ca; dmarc=none X-Rspamd-Server: rspam02 X-Rspam-User: X-HE-Tag: 1663974426-494718 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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.. > 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. Jason