Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1360357rwb; Thu, 11 Aug 2022 22:33:32 -0700 (PDT) X-Google-Smtp-Source: AA6agR7d9kbpoyOx7erBj8nOrdHzHKyaiw2u6xcjxuFvf9WFhc6/ePjYjMMO2xvDwd0v/ZvjLnYx X-Received: by 2002:a05:6402:3552:b0:43d:a634:3997 with SMTP id f18-20020a056402355200b0043da6343997mr2048861edd.389.1660282412301; Thu, 11 Aug 2022 22:33:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660282412; cv=none; d=google.com; s=arc-20160816; b=e+LYDqhLnhmsfaYGRB+pzklAbx/yaFLEkBqVonZyDJ/yD4XQ06YR9WJe3Z57MF/xQH 4hHzIvZeHQRv4zBbewlYny4aVKnW8pWaawdStqP0UhFMeezCX1IQzgugLXugNDV2XtcC 0zwU7OSJ7IMtd4HENpsnja4YjR1pXhcA1rKdJYo5huo8915YcZpUpgyjaqw3MUpzZTvh ivSlLKk6YCEvX6dcOP9b59TRYL7oJ5p1LKdoSG/vPWOCUd6JlPDqFMVzSk5Pl/Zl5dbM uqVmLU8qwAn04XEv2puMo0wi0Yfro1RKkIceAqzGJ2npg5U6WYa4zowRsU3x9sMQYMtK BtPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=dSSxH9259ht4OSP79rBPOtjoSZ0nKEpP3TOMj+1e/a8=; b=uhz1plMyhWubcEwnWW77ACM/AJzGs5Wyqli6bGCV9UE5lzLeHTb/SysDYXaxMCbJzD p5Hcfy8hxRseqlV+sIN/IGLIQsRCTeintGpEjYER1Y6ZPkdHVrC2dz5DXUIsZxgxKCBB 37rRnpx5mMfkjy60jaOcgaIeVutl1CIR7UO4COZa8Nyp/yr1Q3jCCBgAVuHPPrw7Ggvp OQeHpIOJOtEemlYWkAw9+/AEM3zOKp0l4kr6oEgq6nUyOy7KY1Gr3B0u216AdcZ96hPY nTHcfx9weSN4nyDD34pHTDNGnkyuOqKU4vrJqUOWPRdPEfzMTxTdlzdpg2IYVXOCrggT knhA== ARC-Authentication-Results: i=1; mx.google.com; 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 l14-20020a50d6ce000000b00440072d0ae3si1260284edj.196.2022.08.11.22.33.04; Thu, 11 Aug 2022 22:33:32 -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; 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 S236513AbiHLEyS (ORCPT + 99 others); Fri, 12 Aug 2022 00:54:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236172AbiHLEyO (ORCPT ); Fri, 12 Aug 2022 00:54:14 -0400 Received: from smtp.smtpout.orange.fr (smtp-14.smtpout.orange.fr [80.12.242.14]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 256CB2F029 for ; Thu, 11 Aug 2022 21:54:12 -0700 (PDT) Received: from [192.168.1.18] ([90.11.190.129]) by smtp.orange.fr with ESMTPA id MMgToznoetFxAMMgToIj8m; Fri, 12 Aug 2022 06:54:10 +0200 X-ME-Helo: [192.168.1.18] X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Fri, 12 Aug 2022 06:54:10 +0200 X-ME-IP: 90.11.190.129 Message-ID: Date: Fri, 12 Aug 2022 06:54:09 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH] aio: Save a few cycles in 'lookup_ioctx()' Content-Language: fr To: bcrl@kvack.org, viro@zeniv.linux.org.uk Cc: linux-aio@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org References: <0c3fcdaec33bb12b2367860dfab7ed4224ea000c.1635974999.git.christophe.jaillet@wanadoo.fr> From: Christophe JAILLET In-Reply-To: <0c3fcdaec33bb12b2367860dfab7ed4224ea000c.1635974999.git.christophe.jaillet@wanadoo.fr> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, 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 Le 03/11/2021 à 22:31, Christophe JAILLET a écrit : > Use 'percpu_ref_tryget_live_rcu()' instead of 'percpu_ref_tryget_live()' to > save a few cycles when it is known that the rcu lock is already > taken/released. > > Signed-off-by: Christophe JAILLET > --- > fs/aio.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/aio.c b/fs/aio.c > index 9c81cf611d65..d189ea13e10a 100644 > --- a/fs/aio.c > +++ b/fs/aio.c > @@ -1062,7 +1062,7 @@ static struct kioctx *lookup_ioctx(unsigned long ctx_id) > id = array_index_nospec(id, table->nr); > ctx = rcu_dereference(table->table[id]); > if (ctx && ctx->user_id == ctx_id) { > - if (percpu_ref_tryget_live(&ctx->users)) > + if (percpu_ref_tryget_live_rcu(&ctx->users)) > ret = ctx; > } > out: Hi, gentle reminder. Is this patch useful? When I first posted it, percpu_ref_tryget_live_rcu() was really new. Now it is part of linux since 5.16. Saving a few cycles in a function with "lookup" in its name looks always good to me. CJ