From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD317C33CB1 for ; Wed, 15 Jan 2020 15:36:18 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 976AF2053B for ; Wed, 15 Jan 2020 15:36:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 976AF2053B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 313738E0007; Wed, 15 Jan 2020 10:36:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 29D608E0006; Wed, 15 Jan 2020 10:36:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1B3438E0007; Wed, 15 Jan 2020 10:36:18 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0113.hostedemail.com [216.40.44.113]) by kanga.kvack.org (Postfix) with ESMTP id 015868E0006 for ; Wed, 15 Jan 2020 10:36:17 -0500 (EST) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id A4784180AD81D for ; Wed, 15 Jan 2020 15:36:17 +0000 (UTC) X-FDA: 76380269994.24.mint82_5401693576339 X-HE-Tag: mint82_5401693576339 X-Filterd-Recvd-Size: 2570 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by imf29.hostedemail.com (Postfix) with ESMTP for ; Wed, 15 Jan 2020 15:36:17 +0000 (UTC) Received: by verein.lst.de (Postfix, from userid 2407) id B420968B20; Wed, 15 Jan 2020 16:36:14 +0100 (CET) Date: Wed, 15 Jan 2020 16:36:14 +0100 From: Christoph Hellwig To: Jason Gunthorpe Cc: Christoph Hellwig , linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, Waiman Long , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Will Deacon , Andrew Morton , linux-ext4@vger.kernel.org, cluster-devel@redhat.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: RFC: hold i_rwsem until aio completes Message-ID: <20200115153614.GA31296@lst.de> References: <20200114161225.309792-1-hch@lst.de> <20200114192700.GC22037@ziepe.ca> <20200115065614.GC21219@lst.de> <20200115132428.GA25201@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200115132428.GA25201@ziepe.ca> User-Agent: Mutt/1.5.17 (2007-11-01) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Jan 15, 2020 at 09:24:28AM -0400, Jason Gunthorpe wrote: > > Your requirement seems a little different, and in fact in many ways > > similar to the percpu_ref primitive. > > I was interested because you are talking about allowing the read/write side > of a rw sem to be held across a return to user space/etc, which is the > same basic problem. > > precpu refcount looks more like a typical refcount with a release that > is called by whatever context does the final put. The point above is > to basically move the release of a refcount into a synchrnous path by > introducing some barrier to wait for the refcount to go to zero. In > the above the barrier is the down_write() as it is really closer to a > rwsem than a refcount. No, percpu_ref is a little different than the name suggests, as it has a magic initial reference, and then the other short term reference. To actually tear it down now just a normal put of the reference is needed, but an explicit percpu_ref_kill or percpu_ref_kill_and_confirm. Various callers (including all I added) would like that operation to be synchronous and currently hack that up, so a version of the percpu_ref that actually waits for the other references to away like we hacked up various places seems to exactly suit your requirements.