Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1492763ybl; Tue, 13 Aug 2019 13:39:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqyG6VAda9+d4FJ76tlyP+Adefws2vPrjstTa43DMTPzTscCHI9a1PgF+5d1X8QMF0TFHFxg X-Received: by 2002:a17:90b:911:: with SMTP id bo17mr3730383pjb.40.1565728782523; Tue, 13 Aug 2019 13:39:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565728782; cv=none; d=google.com; s=arc-20160816; b=fhFVqFZHDTIOvN90t34lGWr77eWs4fWGLXf1OeobBdRU30QaFZhtqTlOkBjoNcUELh 3/by56VNV2zGyW8yKVNwBIoxLs/JeawsnKgUgCVlV+JnoZgWL1wsjcCjZ7eG7jfFzPoJ 4KsMNwFHnhn+u5bSuUSWFjWv8cehomElacsc9h7LZabKXPBrBMy6Cmucn5ESHku/3WFI LCixCaHd4qMBdFBsYgGCNgnOfHsRGXo3AT//5pHHkam4UsUEL/RTqpvwqAdlDYe/QEdG d9mqwsMnhOPXy1TA2qx2ujkz/ozWjNie0Y/Id1IaNqQhwcLFdhAiFQ7mlSoO1FvgXCcL r+gQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=NV3jojbB8hb1iG4/Oq/uoBtjHRdhqqhXUrPyuWwozIc=; b=Uq54dBWYnyHh94IyWd/HXt/b7c+v/0mqJNDgRq4+DgGt/x9PArgZ3zDtc0Y57Vs3D4 0pQdEnjKOzhr6cSBggqH0WF4KTv1Y6+5mxcrVqMsiSJjoNPgxGlWtjE3ZaUycPJgMa1o xiyYdv0pn+RhhT0/4/FBOduZ8wFS/fBbc+7NT3L33Vk2k9+FNCp3do6spCtWSfBR4Pz0 0YNg0LEhdY2Ek4EcXhekTRIF8J6HtnwXfZ7MSTv/V7vGIWEW3wd99PJGreWsM18SM7NZ Im4pKNMbnteAopYw3tieGRjwq1hyCJnFGR0cDId5HPV+/lrYjxrqhzy+8SSog9Obz+JX oGAQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o131si66609637pgo.445.2019.08.13.13.39.21; Tue, 13 Aug 2019 13:39:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726267AbfHMUjA (ORCPT + 99 others); Tue, 13 Aug 2019 16:39:00 -0400 Received: from mga11.intel.com ([192.55.52.93]:6361 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725869AbfHMUjA (ORCPT ); Tue, 13 Aug 2019 16:39:00 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Aug 2019 13:38:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,382,1559545200"; d="scan'208";a="376423872" Received: from iweiny-desk2.sc.intel.com ([10.3.52.157]) by fmsmga006.fm.intel.com with ESMTP; 13 Aug 2019 13:38:59 -0700 Date: Tue, 13 Aug 2019 13:38:59 -0700 From: Ira Weiny To: Jason Gunthorpe Cc: Andrew Morton , Dan Williams , Matthew Wilcox , Jan Kara , Theodore Ts'o , John Hubbard , Michal Hocko , Dave Chinner , linux-xfs@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-nvdimm@lists.01.org, linux-ext4@vger.kernel.org, linux-mm@kvack.org Subject: Re: [RFC PATCH v2 16/19] RDMA/uverbs: Add back pointer to system file object Message-ID: <20190813203858.GA12695@iweiny-DESK2.sc.intel.com> References: <20190809225833.6657-1-ira.weiny@intel.com> <20190809225833.6657-17-ira.weiny@intel.com> <20190812130039.GD24457@ziepe.ca> <20190812172826.GA19746@iweiny-DESK2.sc.intel.com> <20190812175615.GI24457@ziepe.ca> <20190812211537.GE20634@iweiny-DESK2.sc.intel.com> <20190813114842.GB29508@ziepe.ca> <20190813174142.GB11882@iweiny-DESK2.sc.intel.com> <20190813180022.GF29508@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190813180022.GF29508@ziepe.ca> User-Agent: Mutt/1.11.1 (2018-12-01) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Tue, Aug 13, 2019 at 03:00:22PM -0300, Jason Gunthorpe wrote: > On Tue, Aug 13, 2019 at 10:41:42AM -0700, Ira Weiny wrote: > > > And I was pretty sure uverbs_destroy_ufile_hw() would take care of (or ensure > > that some other thread is) destroying all the MR's we have associated with this > > FD. > > fd's can't be revoked, so destroy_ufile_hw() can't touch them. It > deletes any underlying HW resources, but the FD persists. I misspoke. I should have said associated with this "context". And of course uverbs_destroy_ufile_hw() does not touch the FD. What I mean is that the struct file which had file_pins hanging off of it would be getting its file pins destroyed by uverbs_destroy_ufile_hw(). Therefore we don't need the FD after uverbs_destroy_ufile_hw() is done. But since it does not block it may be that the struct file is gone before the MR is actually destroyed. Which means I think the GUP code would blow up in that case... :-( I was thinking it was the other way around. And in fact most of the time I think it is. But we can't depend on that... > > > > This is why having a back pointer like this is so ugly, it creates a > > > reference counting cycle > > > > Yep... I worked through this... and it was giving me fits... > > > > Anyway, the struct file is the only object in the core which was reasonable to > > store this information in since that is what is passed around to other > > processes... > > It could be passed down in the uattr_bundle, once you are in file operations What is "It"? The struct file? Or the file pin information? > handle the file is guarenteed to exist, and we've now arranged things I don't understand what you mean by "... once you are in file operations handle... "? > so the uattr_bundle flows into the umem, as umems can only be > established under a system call. "uattr_bundle" == uverbs_attr_bundle right? The problem is that I don't think the core should be handling uverbs_attr_bundles directly. So, I think you are driving at the same idea I had WRT callbacks into the driver. The drivers could provide some generic object (in RDMA this could be the uverbs_attr_bundle) which represents their "context". The GUP code calls back into the driver with file pin information as it encounters and pins pages. The driver, RDMA in this case, associates this information with the "context". But for the procfs interface, that context then needs to be associated with any file which points to it... For RDMA, or any other "FD based pin mechanism", it would be up to the driver to "install" a procfs handler into any struct file which _may_ point to this context. (before _or_ after memory pins). Then the procfs code can walk the FD array and if this handler is installed it knows there is file pin information associated with that struct file and it can be printed... This is not impossible. But I think is a lot harder for drivers to make right... Ira