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 6A8D4ECAAD5 for ; Thu, 1 Sep 2022 18:14:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D5D9E8003C; Thu, 1 Sep 2022 14:14:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D0C7D8000D; Thu, 1 Sep 2022 14:14:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BAD1F8003C; Thu, 1 Sep 2022 14:14:39 -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 A84418000D for ; Thu, 1 Sep 2022 14:14:39 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 7E2A180FC2 for ; Thu, 1 Sep 2022 18:14:39 +0000 (UTC) X-FDA: 79864317078.28.1663BA7 Received: from ale.deltatee.com (ale.deltatee.com [204.191.154.188]) by imf02.hostedemail.com (Postfix) with ESMTP id 8A68A80063 for ; Thu, 1 Sep 2022 18:14:37 +0000 (UTC) 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=sWRKw2yHnva/fkslMEKIBYXYtsFYh9CE67WvtTKYh9o=; b=LUIvBgXNanbwZx0H1YeUvZgz+W ul/GPgxn/izyWHImD9lqPZLOeLp2e5DPV9+wMaetQl9lN8rbG69efLBarhCWXjJEqFRIUZ/a89fuP J2vlO4iHchGWdU3cW+ChfYCl/ChEYQKScgeFtoa49hZHGEdtT6Y85OqSzoLVMTuBGJioNmnxaH/y4 UCjYLZRzU+iuvnnVzftig3939k08pTGaZkFTrGdK4tP1yGmwfkBG1jNR1SuDAFuT/Zqv/GQSQO8S7 EQTKoaT6u/1UuhYU+UA+7NfA+KpWCAmFvy5SIcDH9GOZ2nun6awzVDrZFqUtbfU/RUz0nIA+/OJuT aVwiAEMg==; 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 1oToi1-00Dvye-Mb; Thu, 01 Sep 2022 12:14:34 -0600 Message-ID: Date: Thu, 1 Sep 2022 12:14:25 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.13.0 Content-Language: en-CA To: Greg Kroah-Hartman 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 , Dan Williams , Jason Gunthorpe , =?UTF-8?Q?Christian_K=c3=b6nig?= , 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 References: <20220825152425.6296-1-logang@deltatee.com> <20220825152425.6296-8-logang@deltatee.com> <4a4bca1e-bebf-768f-92d4-92eb8ae714e1@deltatee.com> From: Logan Gunthorpe In-Reply-To: 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: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, linux-mm@kvack.org, hch@lst.de, dan.j.williams@intel.com, jgg@ziepe.ca, christian.koenig@amd.com, jhubbard@nvidia.com, ddutile@redhat.com, willy@infradead.org, daniel.vetter@ffwll.ch, 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, sbates@raithlin.com X-SA-Exim-Mail-From: logang@deltatee.com Subject: Re: [PATCH v9 7/8] PCI/P2PDMA: Allow userspace VMA allocations through sysfs 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) ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662056079; a=rsa-sha256; cv=none; b=xdvtPMfbRlkf+a/KdWcuzhdG/yvlVAjjGzk+nMC8HLtQkwBdkJhKL+hLCcHH2FJpr042h5 u3ERANdRi192pQxgRZB9deLCBRiHvhRQ2jqP2ybPlBsiT5kaQVf4z/60/lSxUBf9ZP68HW fdpzZEubzUYzbgnLjOVKeSi7THnbEfQ= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=deltatee.com header.s=20200525 header.b=LUIvBgXN; spf=pass (imf02.hostedemail.com: domain of logang@deltatee.com designates 204.191.154.188 as permitted sender) smtp.mailfrom=logang@deltatee.com; dmarc=pass (policy=none) header.from=deltatee.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662056079; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=sWRKw2yHnva/fkslMEKIBYXYtsFYh9CE67WvtTKYh9o=; b=pP/bgbhWkPyw25aKBW+WIAIxULha7tz+MKR1Mn2XDsJykvu430lEjlYxkGTO/lkSUsi8yp tA0McdpJuRAi7s/pVIIzzJfdskFBfIOmCIWQ5021gOKifK/T3lE6XAPpVRFydlEcUmchwh 52sOulp3b4h/KbkRSLPjTBIM3/Y6STo= X-Stat-Signature: i5obukrkwwfffcmhe1t9h34i4tkto7p1 X-Rspam-User: X-Rspamd-Queue-Id: 8A68A80063 X-Rspamd-Server: rspam07 Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=deltatee.com header.s=20200525 header.b=LUIvBgXN; spf=pass (imf02.hostedemail.com: domain of logang@deltatee.com designates 204.191.154.188 as permitted sender) smtp.mailfrom=logang@deltatee.com; dmarc=pass (policy=none) header.from=deltatee.com X-HE-Tag: 1662056077-125494 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 2022-09-01 10:42, Greg Kroah-Hartman wrote: > On Thu, Sep 01, 2022 at 10:32:55AM -0600, Logan Gunthorpe wrote: >> On 2022-09-01 10:20, Greg Kroah-Hartman wrote: >>> On Thu, Aug 25, 2022 at 09:24:24AM -0600, Logan Gunthorpe wrote: >>>> + /* >>>> + * Removing the alloc attribute from sysfs will call >>>> + * unmap_mapping_range() on the inode, teardown any existing userspace >>>> + * mappings and prevent new ones from being created. >>>> + */ >>>> + sysfs_remove_file_from_group(&pdev->dev.kobj, &p2pmem_alloc_attr.attr, >>>> + p2pmem_group.name); >>> >>> Wait, why are you manually removing the sysfs file here? It's part of >>> the group, if you do this then it is gone for forever, right? Why >>> manually do this the sysfs core should handle this for you if the device >>> is removed. >> >> We have to make sure the mappings are all removed before the cleanup of >> devm_memremap_pages() which will wait for all the pages to be freed. > > Then don't use devm_ functions. Why not just use the manual functions > instead as you know when you want to tear this down. Well we haven't plugged in a remove call into p2pdma, that would be more work and more interfaces touching the PCI code. Note: this code isn't a driver but a set of PCI helpers available to other PCI drivers. Everything that's setup is using the devm interfaces and gets torn down with the same. So I don't really see the benefit of making the change you propose. Logan