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 701ECC33CB2 for ; Wed, 15 Jan 2020 15:36:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 483A424656 for ; Wed, 15 Jan 2020 15:36:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729092AbgAOPgS (ORCPT ); Wed, 15 Jan 2020 10:36:18 -0500 Received: from verein.lst.de ([213.95.11.211]:51570 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728901AbgAOPgS (ORCPT ); Wed, 15 Jan 2020 10:36:18 -0500 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) Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org 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.