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 A411AC433EF for ; Tue, 5 Jul 2022 17:42:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B0B896B0071; Tue, 5 Jul 2022 13:42:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ABA906B0073; Tue, 5 Jul 2022 13:42:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9A9046B0074; Tue, 5 Jul 2022 13:42:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 8BF2B6B0071 for ; Tue, 5 Jul 2022 13:42:37 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 4C28D20A59 for ; Tue, 5 Jul 2022 17:42:37 +0000 (UTC) X-FDA: 79653765954.11.DA955EC Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf09.hostedemail.com (Postfix) with ESMTP id D433414005B for ; Tue, 5 Jul 2022 17:42:36 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 01C0361876; Tue, 5 Jul 2022 17:42:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4620C341C7; Tue, 5 Jul 2022 17:42:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657042955; bh=18T9JrVrQmGUhIeB/JuQTrGy9yUM/iGt2yUQiwv239s=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=E+wsESQzjBq0Jm7GRcNunkZNg/B9u9pWxluE8Hvyw5c8ngmjtRMeYZplVgH18CEMg +CWBPqMRpf6vtqHc8uVHP4AxL8xobnRkwM4XtCynMLc+/O8b28/frnTwxcKPJt8aG2 gLkaIa6aOTwyOr/X8xpnr7Wu6h8BVukKTtB9ibvU= Date: Tue, 5 Jul 2022 19:42:32 +0200 From: Greg Kroah-Hartman To: Logan Gunthorpe Cc: Christoph Hellwig , Jason Gunthorpe , 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 , Dan Williams , Christian =?iso-8859-1?Q?K=F6nig?= , 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 , Bjorn Helgaas Subject: Re: [PATCH v7 20/21] PCI/P2PDMA: Introduce pci_mmap_p2pmem() Message-ID: References: <20220629175906.GU23621@ziepe.ca> <20220705075108.GB17451@lst.de> <20220705135102.GE23621@ziepe.ca> <20220705161240.GB13721@lst.de> <20220705164315.GB14484@lst.de> <20220705165039.GB14566@lst.de> <1bd43ef7-0403-bd25-087c-d54d5af677e4@deltatee.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1bd43ef7-0403-bd25-087c-d54d5af677e4@deltatee.com> ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657042957; a=rsa-sha256; cv=none; b=4lgQzvROBoxViNh2KTY5dzZSppOBrQRVFrDdbOWgGz1RND239eBYtUlJR3q3OUDzgNrTjh 4TF7Y0y5xqUJy5QOMaxPn2VyxHzPEOg12SMIPaJ8/3Q4xE/LbChGJsKxzVmYhAayi6+9fe lljG9yLfDcyqvHO5ZhF3dk0DDsuxCts= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=korg header.b=E+wsESQz; dmarc=pass (policy=none) header.from=linuxfoundation.org; spf=pass (imf09.hostedemail.com: domain of gregkh@linuxfoundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657042957; 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=ZZ183XwVsELBVPB7JnEyzJPWbbXM+pLVSpBuXVG55QQ=; b=GSI8ye2ybPqtrwX1pi1dYBBl1/i473wjvbZWPjWoBh/SRzP2FVcWm+nBphM1AB2Y0CEuZB E7SrNyyR2f6EldqU5YleMcXld3T9LgtwKRGp2z8cx/MEbL3dnl6cAhFOiLbwp+fnjy770O PWo3GOsGZP99vfUr9IqR7OXsd2lsNfk= Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=korg header.b=E+wsESQz; dmarc=pass (policy=none) header.from=linuxfoundation.org; spf=pass (imf09.hostedemail.com: domain of gregkh@linuxfoundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org X-Rspam-User: X-Stat-Signature: fnwopy5gqw1j1obszrrgf78m8hefcsdo X-Rspamd-Queue-Id: D433414005B X-Rspamd-Server: rspam04 X-HE-Tag: 1657042956-280268 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 Tue, Jul 05, 2022 at 11:32:23AM -0600, Logan Gunthorpe wrote: > > > On 2022-07-05 11:21, Greg Kroah-Hartman wrote: > > On Tue, Jul 05, 2022 at 06:50:39PM +0200, Christoph Hellwig wrote: > >> [note for the newcomers, this is about allowing mmap()ing the PCIe > >> P2P memory from the generic PCI P2P code through sysfs, and more > >> importantly how to revoke it on device removal] > > > > We allow mmap on PCIe config space today, right? Why is this different > > from what pci_create_legacy_files() does today? > > > >> On Tue, Jul 05, 2022 at 10:44:49AM -0600, Logan Gunthorpe wrote: > >>> We might be able to. I'm not sure. I'll have to figure out how to find > >>> that inode from the p2pdma code. I haven't found an obvious interface to > >>> do that. > >> > >> I think the right way to approach this would be a new sysfs API > >> that internally calls unmap_mapping_range internally instead of > >> exposing the inode. I suspect that might actually be the right thing > >> to do for iomem_inode as well. > > > > Why do we need something new and how is this any different from the PCI > > binary files I mention above? We have supported PCI hotplug for a very > > long time, do the current PCI binary sysfs files not work properly with > > mmap and removing a device? > > The P2PDMA code allocates and hands out struct pages to userspace that > are backed with ZONE_DEVICE memory from a device's BAR. This is quite > different from the existing binary files mentioned above which neither > support struct pages nor allocation. Why would you want to do this through a sysfs interface? that feels horrid...