Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp842160iog; Wed, 29 Jun 2022 11:17:38 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tFncnQRo2PNyddZWeH+BeaHI6N0et7THwu4Ck/UFtIrxm51r09vCLwG2FE0C+9X9dbLClV X-Received: by 2002:a05:6a00:14c7:b0:525:89c1:35fb with SMTP id w7-20020a056a0014c700b0052589c135fbmr11297915pfu.36.1656526657783; Wed, 29 Jun 2022 11:17:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656526657; cv=none; d=google.com; s=arc-20160816; b=Ok82yBBFriWiLzJo7+lH+9hDKQox5iH0l4gC3sjWcEik8HnW0RTEYXP33hbdqepkXH rgO7G+8TOZkjlAMbiBoZbYDZghSdKjFKRJzljPjpWg55ShyKwGIv5eN3gIMny7OgesrM T0K7JtDQ3NXsUJ+zrzpBryQnqF+b+Dnezm/sm/2av8T6ESQedyFJECknury5lCdFgHHv Gknvd7ng9IZw0d9sxheMX3cbPzLXl+mlE3cInoy/0A87DEAtC1iVoZ9or8K+06jeVXG2 qqP0skuyiivA8YqCDfe0or6Vl2gkEXDib+gyQ3lwlizD6DH556YbPD4btCyraSOTpbiV YMsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ngWx43aEx+7T9A14R2LGOmGQG6CiD1NPE7ELlQTW2Yo=; b=aPkCCqqBJ46+OaQri3A0Jf+ob/GiytKHDF8Pgm2cQwaKRxS+GNdjQDZGqoCB2280+Q xc/VoZh5tgHfB824ZHwAIYRIpqZZ7SrbG8MOSQRlEevdbPmYu8u/xjZVYkSgFZaQtjmj UWLyOdYJRrB2AoxHTRM93zO2XVl0x0wShC8HAkK4lz8d89T3lmKbMLwCY8vMwx1euY/l qUjAKo1Fg7OyXdY9CUKsQF+C1XyI5+KrCbuH69emBen083UgE21ZHsPdfkbFoI0jxGwj ONttxth3Ho0EobXzOTKmuaAhezuTKcTgbdPKZSb/vbsADTq+VGTYF/MMlh7F8tsiEQKo fkcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=SKmcghAf; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k8-20020a170902694800b00161ba2ffeb8si21460835plt.557.2022.06.29.11.17.24; Wed, 29 Jun 2022 11:17:37 -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=@ziepe.ca header.s=google header.b=SKmcghAf; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232013AbiF2R7O (ORCPT + 99 others); Wed, 29 Jun 2022 13:59:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231720AbiF2R7K (ORCPT ); Wed, 29 Jun 2022 13:59:10 -0400 Received: from mail-qv1-xf2b.google.com (mail-qv1-xf2b.google.com [IPv6:2607:f8b0:4864:20::f2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3E58335 for ; Wed, 29 Jun 2022 10:59:08 -0700 (PDT) Received: by mail-qv1-xf2b.google.com with SMTP id t16so26048173qvh.1 for ; Wed, 29 Jun 2022 10:59:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ngWx43aEx+7T9A14R2LGOmGQG6CiD1NPE7ELlQTW2Yo=; b=SKmcghAf6nlxb3TYM9q+L2K6WvoAOg3jhiALBKso44zP0sXfB8bfiUedLcgKzgwJgh iTJCket4ICkaBkiO0QMT6a7oZweniTqMyqfh5UKIWBSdtteoys0WU0gLpwmQxcuZ4T0C B5EZV3F+pSyyuE/TubvDD1bjbB6DXWKJyou3V2eDANW0FMx1qb5IymBGqRBGbaBO/qpz ziWT+UQffo2LDKQOaJhYTyVo3/P9yrGTwX9E3INhoqRXiDqc6Jau79+OQONuVBZZne7a MzNQ3dTgqHtk/dbWQmfNzsZcoGEiW6sxYQ0kC+3zRe5EegJZ5dxZXRpFz6xNN0CByfx0 8ESA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ngWx43aEx+7T9A14R2LGOmGQG6CiD1NPE7ELlQTW2Yo=; b=j4hAKGerX6Vda0llVG3FBTQUpE4m9xGkzJJludp0EgQQ2VWMB8/qfO/5E/5YBZYpQc XXdiOiIyEXGkE89ZoFDvoPmIRF9Kuer3VlL06W0FwiX71DpmcfpKyPY9YbMGkvopsZZu gjrV0sCzxMl9YqbJf/5mNEZrx8ojdejY2CxygFf/e3ZhQ7bJcz1saA+kG1g0y4rUsjFG TBOZTomK4oDQHqzr4jDkqAQQbjLzEKn5NRybhTkNThJ7jaUdePm8op4jXpPkIcEa8WCb 5vXgnccXx529sdJo57gLCJhiH+wB8iFDcZ09hHfwlcZEPFFuii8G0Cs4I3+LANuor0hv PDwQ== X-Gm-Message-State: AJIora/3ZcTErbasb4k6DQsFkcRiE4h/RtARtUPdEF7+FgSufsZ6XTXm JrIqPnYWR/m3M043iqaFNvw+Ww== X-Received: by 2002:a05:6214:ac2:b0:46e:7e2a:ada with SMTP id g2-20020a0562140ac200b0046e7e2a0adamr8831887qvi.81.1656525547889; Wed, 29 Jun 2022 10:59:07 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-142-162-113-129.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.162.113.129]) by smtp.gmail.com with ESMTPSA id c13-20020a05620a164d00b006a6a4b43c01sm12832373qko.38.2022.06.29.10.59.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jun 2022 10:59:07 -0700 (PDT) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1o6bxy-003bBJ-Q7; Wed, 29 Jun 2022 14:59:06 -0300 Date: Wed, 29 Jun 2022 14:59:06 -0300 From: Jason Gunthorpe To: Logan Gunthorpe Cc: Christoph Hellwig , 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 =?utf-8?B?S8O2bmln?= , 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: <20220629175906.GU23621@ziepe.ca> References: <20220615161233.17527-1-logang@deltatee.com> <20220615161233.17527-21-logang@deltatee.com> <20220629064854.GD17576@lst.de> <99242789-66a6-bbd2-b56a-e47891f4522e@deltatee.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <99242789-66a6-bbd2-b56a-e47891f4522e@deltatee.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 29, 2022 at 10:00:09AM -0600, Logan Gunthorpe wrote: > > > > On 2022-06-29 00:48, Christoph Hellwig wrote: > > On Wed, Jun 15, 2022 at 10:12:32AM -0600, Logan Gunthorpe wrote: > >> A pseudo mount is used to allocate an inode for each PCI device. The > >> inode's address_space is used in the file doing the mmap so that all > >> VMAs are collected and can be unmapped if the PCI device is unbound. > >> After unmapping, the VMAs are iterated through and their pages are > >> put so the device can continue to be unbound. An active flag is used > >> to signal to VMAs not to allocate any further P2P memory once the > >> removal process starts. The flag is synchronized with concurrent > >> access with an RCU lock. > > > > Can't we come up with a way of doing this without all the pseudo-fs > > garbagage? I really hate all the overhead for that in the next > > nvme patch as well. > > I assume you still want to be able to unmap the VMAs on unbind and not > just hang? > > I'll see if I can come up with something to do the a similar thing using > vm_private data or some such. I've tried in the past, this is not a good idea. There is no way to handle failures when a VMA is dup'd and if you rely on private_data you almost certainly have to alloc here. Then there is the issue of making the locking work on invalidation which is crazy ugly. > I was not a fan of the extra code for this either, but I was given to > understand that it was the standard way to collect and cleanup VMAs. Christoph you tried tried to clean it once globally, what happened to that? All that is needed here is a way to get a unique inode for the PCI memory. Jason