Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1339755rwb; Thu, 11 Aug 2022 22:02:33 -0700 (PDT) X-Google-Smtp-Source: AA6agR43qZih+W3SE2jK+unDofy86jM9dGkgOPhaB/pCETg6tWhP3dPVAk3pY416aZCZyMyXPoH8 X-Received: by 2002:aa7:d0d8:0:b0:441:4671:49d6 with SMTP id u24-20020aa7d0d8000000b00441467149d6mr2123082edo.252.1660280552906; Thu, 11 Aug 2022 22:02:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660280552; cv=none; d=google.com; s=arc-20160816; b=KhVLE5MPef+lUPx+f9uGTe4Fdd+OFggD1/hVF0RuPsHLtZ67S8D0eWrPLjpAecMxD6 fL0Z4UrEhf+Ey+2xRGHZwZppxYwvp8lZ5LmuaGwdL6cGa7AgPdJYREzV5zQuxpJq5bxM +/uT1lMtaZkvDBxkrQmrvRjUK/DNwSZ3KyPrHP9WBxdlLw1thAelq1sBug7bLHt2jyeY D0t/6db1RF85xV7H3O39/KpP+fM9WK2Ml/sSzkyPcnSGTxZ3gQ9ml5sZ+u1Zu2HXX6r3 W2qnIZSLByRkzOYk1227U89/jE8a5Zu7gJAwesHMpacuMEa+pyCYyLV9g1lCJyknbH99 IRDw== 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=2PFcFkMvaqLPYbxURGVGdIgkEoJQVWoKF6+NbosZSHM=; b=cp9lrsfntW4jdGvUWoUtilyS1vYLuKAA0yXaM7322ugDypLJEU6VSJzcLGuA01+dfo RDEVglt2lukh1iWEehPTGBZGhJoc1uHUZiJmW2bYmV7lDLxEm7YBeaiGgAWAl0RMz4WN vuCWPxI4BoVTAC9Bhko5EmoNdgjP3EPGDt2fJb5yOteXYaTiXVWEcat0HGhrOYXYjrGc eZuJENcomNDjbmZ+sHOQED6payZ5S2HCO/MdKnAZL3rT91Q4n41r+xZnpWuZBmQ2i9RW d5ZzHGwimOeAnhGTD7gu6MXHnl/H699D7HBX/z4blxX9QL3lQcImMREqPjVAep8WS7oT 8Vew== 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 u23-20020a1709067d1700b007308f39b5afsi854314ejo.407.2022.08.11.22.02.07; Thu, 11 Aug 2022 22:02: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 S235114AbiHLEwJ (ORCPT + 99 others); Fri, 12 Aug 2022 00:52:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229519AbiHLEwH (ORCPT ); Fri, 12 Aug 2022 00:52:07 -0400 Received: from smtp.smtpout.orange.fr (smtp04.smtpout.orange.fr [80.12.242.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 513DC11A1A for ; Thu, 11 Aug 2022 21:52:05 -0700 (PDT) Received: from [192.168.1.18] ([90.11.190.129]) by smtp.orange.fr with ESMTPA id MMeQoMXpzAOp2MMeRohJUk; Fri, 12 Aug 2022 06:52:03 +0200 X-ME-Helo: [192.168.1.18] X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Fri, 12 Aug 2022 06:52:03 +0200 X-ME-IP: 90.11.190.129 Message-ID: Date: Fri, 12 Aug 2022 06:52:02 +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] scsi: target: Save a few cycles in 'transport_lookup_[cmd|tmr]_lun()' Content-Language: en-US To: martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org References: From: Christophe JAILLET In-Reply-To: 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, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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:24, 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 > --- > drivers/target/target_core_device.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c > index 44bb380e7390..bfd5d5606522 100644 > --- a/drivers/target/target_core_device.c > +++ b/drivers/target/target_core_device.c > @@ -77,7 +77,7 @@ transport_lookup_cmd_lun(struct se_cmd *se_cmd) > > se_lun = rcu_dereference(deve->se_lun); > > - if (!percpu_ref_tryget_live(&se_lun->lun_ref)) { > + if (!percpu_ref_tryget_live_rcu(&se_lun->lun_ref)) { > se_lun = NULL; > goto out_unlock; > } > @@ -154,7 +154,7 @@ int transport_lookup_tmr_lun(struct se_cmd *se_cmd) > if (deve) { > se_lun = rcu_dereference(deve->se_lun); > > - if (!percpu_ref_tryget_live(&se_lun->lun_ref)) { > + if (!percpu_ref_tryget_live_rcu(&se_lun->lun_ref)) { > se_lun = NULL; > goto out_unlock; > } 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