Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1123561rwe; Thu, 1 Sep 2022 12:58:14 -0700 (PDT) X-Google-Smtp-Source: AA6agR4YO5WCIGbdcm3ZYAzU3I7bYihJcgaOqJtlB5LvMAOZWKlpuTlOp1vt8/zQPeG4+LkVTKIP X-Received: by 2002:a63:6ac8:0:b0:42a:3638:86ac with SMTP id f191-20020a636ac8000000b0042a363886acmr27292166pgc.582.1662062293708; Thu, 01 Sep 2022 12:58:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662062293; cv=none; d=google.com; s=arc-20160816; b=oc+3y0aUWbtyxT+DCTctVHtzWw91Yq+S6YwXd+4doK/w+p+P2xz/XVMxf9zloSBeWF snx0bCRww4/17xsuZbHB9P+2Vt/wLBQWgM7ceMmaJhTZaHxkC4FRdmPpdXr4wvBRbX8P kB1TFUmLjqG6Q255xZXck1SrpY9mUGvzCrnJPtgZ7IKz1OUstHxPc2jRly+66Iv9Sozn iPVudZvSm/kqO44AGJScaK+mwWZqwYB4NBXjrME9C1DGVaVrJMgCNPrFNByPFEa/yhpA ihFPj7C0i/bY946WcpqAs1Eyz06lKSOS0A2iJgvy9RBTrL/gdOeOYKcIKGtyg9Pjy4T0 Nufg== 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=mn3VERy0s8rwu2J3nmnzKseb1Xv+6b55gPqcv2R29Do=; b=zx0oasNfN+GWZv1rlm5dEVPvvCP5sPZftqT3h4UBfHx/si4W7jwfIRgZMrQ/9nZv1H xLGvzpopIZEwfQ8Nie24NZ2j/euD4w/bm4kmSK8Bxim40Ytxhth4cVMz3TZVV2pExl3B fWxwEWBSCFd3RcELWX3ntz2N3U2dPha8SqJx+R5BS1zKK3z7AqJuFsjU/PDU0GO2v425 z9/yEwJMMAf2Yff04v7nTj6FJMDZwL+727KSDvV6tX7wCh+QpH10bZDwrb2EnYFrVLxp KfYeo2jaYT+y3jdUQqUV2DkCnRDpF/NBVQu2xhDTb0khwF0Ul7aTDze8i1RR/A1qg90Z O55Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b=YzaqHznk; 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 lt4-20020a17090b354400b001fe2ab750b6si6385pjb.146.2022.09.01.12.57.46; Thu, 01 Sep 2022 12:58:13 -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=YzaqHznk; 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 S233663AbiIATRH (ORCPT + 99 others); Thu, 1 Sep 2022 15:17:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232301AbiIATRF (ORCPT ); Thu, 1 Sep 2022 15:17:05 -0400 Received: from ale.deltatee.com (ale.deltatee.com [204.191.154.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EA1075FCF; Thu, 1 Sep 2022 12:17:03 -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=mn3VERy0s8rwu2J3nmnzKseb1Xv+6b55gPqcv2R29Do=; b=YzaqHznkMBYAnCSOLqSHdegCox YKGC4eoem9/8GT5zgWrOSDaNjktJxP8yRvpJYQxa1Z8TVgSJMiKxRYBzMwVpxfst2k9K0nTOV1HBS g+ph5690L3SgBn1e1YgO7JjiEYivUW+H3wpACNHc9roxwPBpKqP9k77Y82r0mkv/FNfPaaPUHfTvB p4qZfGw6uCBlrSY263wg1z6zYHA/Re3+5UA8DJ6RvGYmERMmO74bYgDyuhsaCDe3OouNe43APnOcv 6drCz4JVkp2sBvXA1RP/eGJ/WdeAGxetZaWgUxT+1aOmV3OaCU44xJq4EEu+L4J8FIFcXmhtYUgpU 1D7gy7Vw==; 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 1oTpgS-00Dx2S-Se; Thu, 01 Sep 2022 13:17:01 -0600 Message-ID: Date: Thu, 1 Sep 2022 13:16:54 -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 12:36, Greg Kroah-Hartman wrote: > On Thu, Sep 01, 2022 at 12:14:25PM -0600, Logan Gunthorpe wrote: >> 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. > > The issue is the classic one with the devm helpers. They do not lend > themselves to resource management issues that require ordering or other > sort of dependencies. Please do not use them here, just put in a remove > callback as you eventually will need it anyway, as you have a strong > requirement for what gets freed when, and the devm api does not provide > for that well. This surprises me. Can you elaborate on this classic issue? I've definitely seen uses of devm that expect the calls will be torn down in reverse order they are added. The existing p2pdma code will certainly fail quite significantly if a devm_kzalloc() releases its memory before the devm_memmap_pages() cleans up. There's also already an action that is used to cleanup before the last devm_kzalloc() call happens. If ordering is not guaranteed, then devm seems fairly broken and unusable and I'd have to drop all uses from this code and go back to the error prone method. Also what's the point of devm_add_action_or_reset() if it doesn't guarantee the ordering or the release? But if it's that important I can make the change to these patches for v10. Logan