Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp7688889ioo; Fri, 3 Jun 2022 11:20:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxv1FIQnfaK/LO0qIajYqWmiBjSV5kOe6h46Jurxen9Ho0ZSk3b9N6d4j9bc51/hrTY8Uk3 X-Received: by 2002:a17:90a:46c3:b0:1df:77a4:471e with SMTP id x3-20020a17090a46c300b001df77a4471emr12308484pjg.224.1654280406646; Fri, 03 Jun 2022 11:20:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654280406; cv=none; d=google.com; s=arc-20160816; b=hR0oI0BexOGedR7XGipN6Orb6rHEldhbjYw6FXe0HSmk4EMqMJzHtMsPMgKZ5/eG6M AmvOKL5L5g6gatEODpcyWOl7zUKOj9+hCsejr0gCEYFTGxJ1Ag60oDNzb6LFRE4L11NV 8wE+u6RecF0puXwLoti6k6odUViBMy9xVYduuS6KL5vh9TQft2OEPu/RbrJn7iFrdalQ 1skBIoZy5X8WKamfqSW9pxVoJvaCPaXZW0ncIFLBb4NKsXGvMN78LDec+6bLVkXR+MRX ozx9GcCoLT+x/OkyHzXj+pCaT11pHV0uElQ3xrc/B2qyUMazEx97D2yofMfUaq91mZ/8 x3zA== 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=W4T5PIIcGVVrvnJ3j+rtildRWdfS99SqV9DDMh3z6VA=; b=xA7KDUsayNGKotkhCGSnZx1xyHgX54x7xPiDrPoR1LZS/qphnl9Kl8pny9gO5nI6k9 3vaIUfpc+bLR70eAo6OexyiJAzuTSu2h9bebf7BORKWvQxj3bgFCsg5I4w7RNS8M13gf X8g9P6b5bybegONUS1HRMerXfroFn9ulJneKri6aO8TjCNH7tmBYMIKur61XDsbPDzau EX8rtL8AtW4leT2GM671TxZA5T7tjm1ZFV188lb4Vs/qqX5S5t3tPgjgiBlu9aiG1y3k 6h8GJMst91mErsTdDBG3xCUO9MjV854iX7UwA5ZmptEV4JX9Tva75mVC8On5VsQwVQOS s0uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b=mFcvfvBd; 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 19-20020a621413000000b0050cff7b2666si9671811pfu.241.2022.06.03.11.19.51; Fri, 03 Jun 2022 11:20:06 -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=mFcvfvBd; 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 S236912AbiFBQQ0 (ORCPT + 99 others); Thu, 2 Jun 2022 12:16:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232075AbiFBQQY (ORCPT ); Thu, 2 Jun 2022 12:16:24 -0400 Received: from ale.deltatee.com (ale.deltatee.com [204.191.154.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB408AE4C; Thu, 2 Jun 2022 09:16:22 -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=W4T5PIIcGVVrvnJ3j+rtildRWdfS99SqV9DDMh3z6VA=; b=mFcvfvBdKsB2BJNNUrV2R2TggK 1Px0GYS7XkvGiTWTnZL/2iur+Kwoi7+M1jX7ntdXKfQJgxbmlrV2IKqir+oid4k4eEGTQLkoy4Ej6 5ZG9+5TOIBSiRlulo/Z8oASkCGdc8NEe+OT+P7LSZ2mv/eVC6P+tVixruEzq8ynubixg6CxcQoxPy F8HWcOevW1q3ZFYm1r8abYAOFD8Od08vH+hmLVbSXTbE3X0tUfar47n3TwHAH5FaK7Pdl9jU28pUr /4DQK3TDmrdpP1fNME8UkG4a7Pk0pi6CcP00XrNuudfB9AScd2GS+ujbPOIupoHRYNc++RS2G7b5x +U5oZZ4A==; 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 1nwnUh-00ENsn-U9; Thu, 02 Jun 2022 10:16:20 -0600 Message-ID: <400baba7-1cd6-09d4-4de9-2a73f08afc79@deltatee.com> Date: Thu, 2 Jun 2022 10:16:10 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.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, iommu@lists.linux-foundation.org, Stephen Bates , Christoph Hellwig , Dan Williams , =?UTF-8?Q?Christian_K=c3=b6nig?= , 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 References: <20220407154717.7695-1-logang@deltatee.com> <20220407154717.7695-21-logang@deltatee.com> <20220527125501.GD2960187@ziepe.ca> <20220527190307.GG2960187@ziepe.ca> <20220602000038.GK2960187@ziepe.ca> From: Logan Gunthorpe In-Reply-To: <20220602000038.GK2960187@ziepe.ca> 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, iommu@lists.linux-foundation.org, sbates@raithlin.com, hch@lst.de, dan.j.williams@intel.com, christian.koenig@amd.com, jhubbard@nvidia.com, ddutile@redhat.com, willy@infradead.org, daniel.vetter@ffwll.ch, andrzej.jakowski@intel.com, 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, bhelgaas@google.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=-4.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 Subject: Re: [PATCH v6 20/21] PCI/P2PDMA: Introduce pci_mmap_p2pmem() 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-06-01 18:00, Jason Gunthorpe wrote: > 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. Oh is that what we want? With the current method the mmaps are unmapped on unbind so that it doesn't block indefinitely. It seems more typical for resources to be dropped quickly on unbind and processes that are using them will get an error on next use. Logan