Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp5955559ioo; Wed, 1 Jun 2022 17:01:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7xpwQG0JrkAHV4bZFKRcw9LUjRWJ9//Ui7G2kUfuFrf+dJTJaGX9tADCN5pMQaUShqUya X-Received: by 2002:a05:6a00:1a89:b0:518:fbf6:9276 with SMTP id e9-20020a056a001a8900b00518fbf69276mr2028183pfv.74.1654128091925; Wed, 01 Jun 2022 17:01:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654128091; cv=none; d=google.com; s=arc-20160816; b=aoQ/TWug/v47trN8Acw988fNsY7P8pAbuuEOeAzpjcdNA/eTIH2hkJNojtkkmyR1kI SaWI0OGI+qzdwrOBCdt64/Tx90507jNOwmQ+Soligdrl5Mo145dO8a/6RvtGH+20BSmi RETb5eBBlXSamPRVIr5lfE5m/FMJ3fFUBn+UlUn2QKt6d4tNaFNYH77uqgIgxQBvIUcZ 4DIfbPCjKyWPN9LwB80kVa2C+0cJZ3ncbZJaA4sT5oc2+IQA59bucJSoVeAFBc9g0CX5 g6yMFAytW4urwGOcrnVOa3XLdWLeI1LVCoJH40pS/HRa2Tu3oGk+qVRm3f0hFJqyRpj+ TnRw== 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=XHclFl6TiOnpsdbRTbpf8I5ef93NwLHxOT7ZftAP5OQ=; b=XUBb4EmJbhtO+pSA5ZwEKsiD3TNDnQLhZhdeaL6+0O1Ug9WmpFlKXgvtRUYRsuW/nB DEuKtwuQxeGfqlJxdpbjYh97C7Bz46HP8qX0K0wEY0/b9hQpI5RsvmykUawz5VtWfVtv HzVeFiX44tKkl5MnSzOXf3yQuzR4wfT4vQMEojT4IogXvvOzHXWJ5YcDCLVdwLsk430f KOnqPCpRcoK6C93j4GH4qHSzDsUTLf0gIHPIm1EWmdCTStIII1t8v3q7+y//VUbhFGzG EtRkNJ+dGa08SZuWQ5u1OEXPO/udqSY/mc68q8BZ9HFastwlVfpoKflTkVR3wWdqewy1 /BCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=PNI9gR5O; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id b7-20020a056a000a8700b005183f5deeebsi3955432pfl.302.2022.06.01.17.01.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 17:01:31 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=PNI9gR5O; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3137A29ADE4; Wed, 1 Jun 2022 17:00:54 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232624AbiFBAAr (ORCPT + 99 others); Wed, 1 Jun 2022 20:00:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232608AbiFBAAm (ORCPT ); Wed, 1 Jun 2022 20:00:42 -0400 Received: from mail-qt1-x830.google.com (mail-qt1-x830.google.com [IPv6:2607:f8b0:4864:20::830]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30C6E2941D7 for ; Wed, 1 Jun 2022 17:00:41 -0700 (PDT) Received: by mail-qt1-x830.google.com with SMTP id k6so2386334qtq.3 for ; Wed, 01 Jun 2022 17:00:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=XHclFl6TiOnpsdbRTbpf8I5ef93NwLHxOT7ZftAP5OQ=; b=PNI9gR5OxCMLK2wesmPP7beTza1LVUIA9KonYJGbDAFowaWR1+gOMSPFQyILlCbdK9 gUfn5ltQQND4Igpr1PcoJgKaxcD5dBAwzrvhneuGmR5cB6Xf3NpyEwE9pIIgcm5WsDfj OMBTPHZn69Csi4sdfYc+o9dQdNtlWVyz5OxRR+X8nyDPYF6K2ahO4BRlxiavJkdgkk5b vBCAgX831wn8MMIkjC+ZBM62WCGcevuCk6vOX7Pr2o1vHeySgvRlg6SFXHlD9BjBBgRR tgzeldcoyTnuS2Xyrkl/LEo9UbgD40oyCdtA/wA5nQPC/hTnaLXrjoV5QjIEjd2lSEr7 qhiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=XHclFl6TiOnpsdbRTbpf8I5ef93NwLHxOT7ZftAP5OQ=; b=aov+lckOAeXwUWBad85nMd/33VqHHC9mUccZRmzI5qWEGkSxAPD2wnbyiijUiRylie kDbQC0STF4gYsO5jagLSem2moDWG4abjlrIbI3QqOdBU9Y7pj2awfO5tFlXcnGy+gYTl N0WrTsVsn2qiAEzbMgEV6YWAp8qoLlQTKfpo0iQVcv+RCrJeSD2z2NNVsZsn87+YtOo0 LDKJD86jA4wjz2fln/W3g5Fag1pmObrzsjSv+6zMmMpBhK5P/dl5TMXlJuaUXXf2+A93 VjaNc/ACy52OYVtw8o+e0CdBHO1LctyLiGYOm1EPJmGZ7+xtqSAAad5CKBos0R4TyXIA KRew== X-Gm-Message-State: AOAM5332/e38c/b4bVtESzEKVtqclsyQrSdcLy/ahIAXXDWo5IMEnrZn eTsewgrN+vCWsfke3WzYTdbiuA== X-Received: by 2002:a05:622a:313:b0:2f3:b9a1:dd4a with SMTP id q19-20020a05622a031300b002f3b9a1dd4amr1870963qtw.536.1654128040009; Wed, 01 Jun 2022 17:00:40 -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 b16-20020a05620a04f000b006a38debe62csm1867208qkh.89.2022.06.01.17.00.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 17:00:39 -0700 (PDT) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1nwYGU-00GCY4-Af; Wed, 01 Jun 2022 21:00:38 -0300 Date: Wed, 1 Jun 2022 21:00:38 -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, iommu@lists.linux-foundation.org, Stephen Bates , Christoph Hellwig , Dan Williams , Christian =?utf-8?B?S8O2bmln?= , John Hubbard , Don Dutile , Matthew Wilcox , Daniel Vetter , Jakowski Andrzej , Minturn Dave B , Jason Ekstrand , Dave Hansen , Xiong Jianxin , Bjorn Helgaas , Ira Weiny , Robin Murphy , Martin Oliveira , Chaitanya Kulkarni , Ralph Campbell , Bjorn Helgaas Subject: Re: [PATCH v6 20/21] PCI/P2PDMA: Introduce pci_mmap_p2pmem() Message-ID: <20220602000038.GK2960187@ziepe.ca> References: <20220407154717.7695-1-logang@deltatee.com> <20220407154717.7695-21-logang@deltatee.com> <20220527125501.GD2960187@ziepe.ca> <20220527190307.GG2960187@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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, May 27, 2022 at 04:41:08PM -0600, Logan Gunthorpe wrote: > > > > IIRC this is the last part: > > > > https://lore.kernel.org/linux-mm/20220524190632.3304-1-alex.sierra@amd.com/ > > > > And the earlier bit with Christoph's pieces looks like it might get > > merged to v5.19.. > > > > The general idea is once pte_devmap is not set then all the > > refcounting works the way it should. This is what all new ZONE_DEVICE > > users should do.. > > Ok, I don't actually follow how those patches relate to this. > > Based on your description I guess I don't need to set PFN_DEV and Yes > perhaps not use vmf_insert_mixed()? And then just use vm_normal_page()? I'm not sure ATM the best function to use, but yes, a function that doesn't set PFN_DEV is needed here. > But the refcounting of the pages seemed like it was already sane to me, > unless you mean that the code no longer has to synchronize_rcu() before > returning the pages... Right. It also doesn't need to call unmap range or keep track of the inode, or do any of that stuff unless it really needs mmap revokation semantics (which I doubt this use case does) unmap range was only necessary because the refcounting is wrong - since the pte's don't hold a ref on the page in PFN_DEV mode it is necessary to wipe all the PTE explicitly before going ahead to decrement the refcount on this path. Just stuff the pages into the mmap, and your driver unprobe will automatically block until all the mmaps are closed - no different than having an open file descriptor or something. Jason