Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp921185ybl; Tue, 13 Aug 2019 04:50:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqztnNDHGSt9lZWNNwslrNdRUlzLow78zxoJJYHfRrvun/kQPbqnpTspS341cqJ+AhwzsPvH X-Received: by 2002:a17:90a:256d:: with SMTP id j100mr1839923pje.126.1565697009012; Tue, 13 Aug 2019 04:50:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565697009; cv=none; d=google.com; s=arc-20160816; b=qmzLGLL0PEhYCAC5D31neCKPD0k19nBFPS2Dw5zymtkt1UgFzJICK5UmZowEVKOobP zuOsFCkqPyBPS/ACiqvjnQMKRV1nv0GWplTsrG+tkd8O+yWkoWae7w/mDV3Ndz5Fzz0f pp/o9DejzTxkXXH1BXw32GSRcHUjrozAdK4d8C7XrOx3Rh7MEUXT8cPp1kPT6a1RS0Da VX9RrwgeGaYPqHLKkcPmLlsWw8SWL4J193mrfrpy2SpBG6CG7tItLJyFhui8aHVKnhMm gGrTEqS7++vSYt3TYUC2gYka7UShgB0Rd5NRE/rIMC4VDEas/zqY/L/pmzxMj7jwv4zO Bo4g== 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:dkim-signature; bh=Zt45e40hCF0YCbbLZ0aQGoNlrA/sQl/2BzKPlIDcczo=; b=UjICqxfDYFVN9O5Of7DooohPYC6O8eNFTXGOjZcUFMTLV1ohTXAuEPXxgrbjH9Pjco 01Iaw8a1RREkL2ev5Ywu6gBOk1FYjutBiSFXEPfAv0Q6GpWg+NeSfnXD73MZFgfg6YwB 8JfQC4urER5nA65p5e0+q6wHG1y+3L7D10pciiY5WepPdwR0b3Uv3Ne1AJMDe5MkBSKg T9WOlgOFNvC0wF25oqvWJhyXtigjcaa29OLpQ4dM6TeBBQVbKAAKNFepaVYUZdGCjRqk MgSotlv/awdN6hlF5E8zU6FAQG0JtI1A0jTWyFPceYV+ONH1qWZZjLDdbp3VJTZ8eg3m rzsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=D9yc6YFG; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z30si491504pga.346.2019.08.13.04.49.55; Tue, 13 Aug 2019 04:50:08 -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; dkim=pass header.i=@ziepe.ca header.s=google header.b=D9yc6YFG; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727555AbfHMLso (ORCPT + 99 others); Tue, 13 Aug 2019 07:48:44 -0400 Received: from mail-qt1-f195.google.com ([209.85.160.195]:34860 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727517AbfHMLso (ORCPT ); Tue, 13 Aug 2019 07:48:44 -0400 Received: by mail-qt1-f195.google.com with SMTP id u34so6687412qte.2 for ; Tue, 13 Aug 2019 04:48:43 -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:user-agent; bh=Zt45e40hCF0YCbbLZ0aQGoNlrA/sQl/2BzKPlIDcczo=; b=D9yc6YFGEplkH0AEJkqbv5QQ/YqFFErgaOhlLwwyajnLxYCmzuYuYjTPu5K8IzHc7W EHziDWuZnP0EJUoJorsIB/Vle5Jq4HW1ZePpJfpxeJ3PiL6g9IJgSG7a6i4U9+NgvGWa Ai92AkBB6qVdNZzDPFs/+bpyxdePG4eiTSYai6xHFsXo6eqanU0phpcPPEHhvrx1/xET /OrVUPcq3jLH3XTfzYOI9j16wl1cGoll9zeKlcNrafKlJBFPS3Xu3jF23bvmZsNJxEuE b6+41/KGpH+t1xSORBP9OYFknrdMrMYelZfdaoojCQpOYGYaQ11oiLC8AtSSDLjOlbXi Q++A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Zt45e40hCF0YCbbLZ0aQGoNlrA/sQl/2BzKPlIDcczo=; b=WmJVQw3aGJQ6KsK+MvotGEJEH48TttXz/lOz60fYT1S1/fy5AuUhLE1bxJkIchtdd2 c2wkpm2YXXotLw+m7uJLL3QrYpl2ok4BWp+zKORfhWnh5OqqRLA5ksR3//KKfTfvyBIa fmIKuHZ+r/mhRhmyosRTc+/tIuX0jX9j1B1tRrLaKj6XRbCJh37QArMmKDvC9eR38N9R UgXRTI7ZV6CaqRU3B8HXzYhKGMD/RfF+kr4hWpKPnWucVHLJeW8ZzD8DhhrFf0K8b+JQ UD4+hbw3RCyUx6GHnSvMUspilZpSF2frFsvchISu0Iwzo6nahUGTgRKzfna0fZC9T6Rx w1eA== X-Gm-Message-State: APjAAAUkuJUABHztW3Yq1Cm9gbcFir5luh2PI9MdI+Ce7GZvQzUh/wiq olLMdMYFlcdifplPWFZMCLZlcA== X-Received: by 2002:a0c:ae35:: with SMTP id y50mr33835040qvc.204.1565696923435; Tue, 13 Aug 2019 04:48:43 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-156-34-55-100.dhcp-dynamic.fibreop.ns.bellaliant.net. [156.34.55.100]) by smtp.gmail.com with ESMTPSA id m38sm12868061qta.43.2019.08.13.04.48.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Aug 2019 04:48:42 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1hxVIA-0007l2-Ec; Tue, 13 Aug 2019 08:48:42 -0300 Date: Tue, 13 Aug 2019 08:48:42 -0300 From: Jason Gunthorpe To: Ira Weiny 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: <20190813114842.GB29508@ziepe.ca> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190812211537.GE20634@iweiny-DESK2.sc.intel.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Mon, Aug 12, 2019 at 02:15:37PM -0700, Ira Weiny wrote: > On Mon, Aug 12, 2019 at 02:56:15PM -0300, Jason Gunthorpe wrote: > > On Mon, Aug 12, 2019 at 10:28:27AM -0700, Ira Weiny wrote: > > > On Mon, Aug 12, 2019 at 10:00:40AM -0300, Jason Gunthorpe wrote: > > > > On Fri, Aug 09, 2019 at 03:58:30PM -0700, ira.weiny@intel.com wrote: > > > > > From: Ira Weiny > > > > > > > > > > In order for MRs to be tracked against the open verbs context the ufile > > > > > needs to have a pointer to hand to the GUP code. > > > > > > > > > > No references need to be taken as this should be valid for the lifetime > > > > > of the context. > > > > > > > > > > Signed-off-by: Ira Weiny > > > > > drivers/infiniband/core/uverbs.h | 1 + > > > > > drivers/infiniband/core/uverbs_main.c | 1 + > > > > > 2 files changed, 2 insertions(+) > > > > > > > > > > diff --git a/drivers/infiniband/core/uverbs.h b/drivers/infiniband/core/uverbs.h > > > > > index 1e5aeb39f774..e802ba8c67d6 100644 > > > > > +++ b/drivers/infiniband/core/uverbs.h > > > > > @@ -163,6 +163,7 @@ struct ib_uverbs_file { > > > > > struct page *disassociate_page; > > > > > > > > > > struct xarray idr; > > > > > + struct file *sys_file; /* backpointer to system file object */ > > > > > }; > > > > > > > > The 'struct file' has a lifetime strictly shorter than the > > > > ib_uverbs_file, which is kref'd on its own lifetime. Having a back > > > > pointer like this is confouding as it will be invalid for some of the > > > > lifetime of the struct. > > > > > > Ah... ok. I really thought it was the other way around. > > > > > > __fput() should not call ib_uverbs_close() until the last reference on struct > > > file is released... What holds references to struct ib_uverbs_file past that? > > > > Child fds hold onto the internal ib_uverbs_file until they are closed > > The FDs hold the struct file, don't they? Only dups, there are other 'child' FDs we can create > > Now this has unlocked updates to that data.. you'd need some lock and > > get not zero pattern > > You can't call "get" here because I'm 99% sure we only get here when struct > file has no references left... Nope, like I said the other FDs hold the uverbs_file independent of the struct file it is related too. This is why having a back pointer like this is so ugly, it creates a reference counting cycle Jason