Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1045188rwe; Thu, 1 Sep 2022 11:32:23 -0700 (PDT) X-Google-Smtp-Source: AA6agR4mVwnuRiQ89bX+5chXyMDZnJIyMnWQvIhc5H8Us86OzpOGJ8XrV77l6OoKMsp04dwZpu71 X-Received: by 2002:a17:906:8442:b0:73d:a2fc:a87 with SMTP id e2-20020a170906844200b0073da2fc0a87mr24235966ejy.625.1662057143347; Thu, 01 Sep 2022 11:32:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662057143; cv=none; d=google.com; s=arc-20160816; b=o3VIlzkDSXOIo4yqLrHE06pTgN2UFh8uPPIYTYofsZfsoXtmxPUxvOAVeXgOJ6IOh7 7N6SmcAQegjPKaIF2c3JMglUXDabkFc9H4bnon3h1h208g5mBIVvb+mliNerUGJ1D28U n2Et+yZ/uLNpEHabJDFFwpu/fiGvTF8pm6Pl0UWW1QFJ2vhefEfoXc3lTlCM2u9nAYQu g27c5cfIRzz+ENjpqcjW1oNOJR8qp4c7eeTFYa+dKTdXnnRzU2IrSz5GkUSLmPX1JHy6 DwHawLVqtImI6tQMInmK0k2R3CCfLuBsloJRM/39sjR2kAdjPw1Ozy3yGRtGujU59AhL 83Jg== 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=sWRKw2yHnva/fkslMEKIBYXYtsFYh9CE67WvtTKYh9o=; b=RFiX0i9fSF30Yfx7AYbpYOIIEQZnwsRm5p4EqwuSH95FHKSjqEadeU9MnStobWFsaC 1hFYot8h0UKKnN/rxLSQZQ/2i2GL1nZSSz1Z4ZIYHgqBE/eLXhCPB36IkCYGh+9U68Q4 /jhlnYSbwgi3fcV62ndX1EIkn9E5/G4GzbKtBaVXzDUJLpYzYhfsXddJK6QSpGjkDeWI fVsaG6qf8YJtEPean7whKlPpKkjiWL31gVh34MpUdyV3HCW8eEH68Z0/LZxmhxSmOBtn Xg3detChbWaaquewhCTLboO/bGfL7kF3W3QkDh5tKCrpwpKWBNA+QhQksdbE09GGN1Sb UTLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b=LUIvBgXN; 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 hu9-20020a170907a08900b0073da774ff40si5413ejc.122.2022.09.01.11.31.55; Thu, 01 Sep 2022 11:32:23 -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=LUIvBgXN; 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 S233903AbiIASOi (ORCPT + 99 others); Thu, 1 Sep 2022 14:14:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229781AbiIASOg (ORCPT ); Thu, 1 Sep 2022 14:14:36 -0400 Received: from ale.deltatee.com (ale.deltatee.com [204.191.154.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE71C4BA7C; Thu, 1 Sep 2022 11:14:35 -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=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 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Spam-Level: X-Spam-Status: No, score=-2.1 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 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) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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