Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4635620rdb; Tue, 12 Dec 2023 05:27:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IEPctAsnF+o2s6n0Rbg8VqlSLl0WgUowz7x9aR9TDhrBoUCkxi++TH2rcV8WWALtrvu6ZmR X-Received: by 2002:a92:ca4a:0:b0:35d:59a2:bb6 with SMTP id q10-20020a92ca4a000000b0035d59a20bb6mr5789509ilo.76.1702387638755; Tue, 12 Dec 2023 05:27:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702387638; cv=none; d=google.com; s=arc-20160816; b=dz393lGXTfFmX4ENLgmLLixKgrlG+BB9v6LmflobXzaMbZ83yC3lWo0dszCwsNK2sU IHvpq+El1CmZubhsSbXs9KlN4wdf+kllF3Zqjsf0l9rc2xtk63BvFVOCpaEfepZs0SqI e1fOTsDeCrLOby4XbXn03RJ19K8pXSixyrqOXRZFKChgkZrYlDqa6Q4V0Y1C+7dCu9t+ /z0zoWTT/8MNtXbF4n6hjury2YbwtffNQ9cEmYV1yytHNUsD6vquzvTTzrQ6mUOZpBHi VbEGAoDUhDgo9D8ell3fPwf1q3g9U7sTUksPkOSmBMrphAnv53zkDxabrBa204qpATKM CuYg== 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:subject:user-agent:mime-version:date:message-id; bh=et/AEkxViDTJrzDoptmmqOyJeAcnESbGRmOqtMjgK1E=; fh=+9m/H4YgZhbGejhr6bC1tlnbg9sphzPCVmEnknDZdJA=; b=CO2z10sTHiH+LbpREeH6ymZkcml1826/95odN2/K7BPDvPWWzG2mgdsR/m/MKbqdbU I0D5y/yD7sMbfXGc8nfy8/PGekPC2aq60Q3uh4N+kiWGZu33+oYbkLuKcQH94CfBOff+ DW6hniiAsmGihOElz+lcfxamHKVpI9u0OWvj4/nQG34err0qnZDxdLfkScjBYwrdQ262 s/3+Tg2REE1hFrCSzVTaMowlx+3sZS9KhtC90cCMczsTvff3ERBvlgwl2RL81XskuIuw 9p5QejNEg0RIZJv5n6w39nZqy9PtvStncKxtKeMa9lVIN3OXvuu/y0ZDkMl4W6cCIJKs 1aeQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id n190-20020a6327c7000000b005c659eb004asi7783269pgn.485.2023.12.12.05.27.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 05:27:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 7843980A4162; Tue, 12 Dec 2023 05:27:15 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232471AbjLLN0z (ORCPT + 99 others); Tue, 12 Dec 2023 08:26:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232253AbjLLN0y (ORCPT ); Tue, 12 Dec 2023 08:26:54 -0500 Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FB3BA8; Tue, 12 Dec 2023 05:26:59 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R181e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046060;MF=guwen@linux.alibaba.com;NM=1;PH=DS;RN=23;SR=0;TI=SMTPD_---0VyMZ.ND_1702387614; Received: from 30.221.129.163(mailfrom:guwen@linux.alibaba.com fp:SMTPD_---0VyMZ.ND_1702387614) by smtp.aliyun-inc.com; Tue, 12 Dec 2023 21:26:55 +0800 Message-ID: <6064a6d7-8790-cf15-2d2e-eddb04e4e668@linux.alibaba.com> Date: Tue, 12 Dec 2023 21:26:53 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH v3 31/35] net: smc: optimize smc_wr_tx_get_free_slot_index() To: Yury Norov , linux-kernel@vger.kernel.org, Karsten Graul , Wenjia Zhang , Jan Karcher , "D. Wythe" , Tony Lu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-s390@vger.kernel.org, netdev@vger.kernel.org Cc: Jan Kara , Mirsad Todorovac , Matthew Wilcox , Rasmus Villemoes , Andy Shevchenko , Maxim Kuvyrkov , Alexey Klimov , Bart Van Assche , Sergey Shtylyov , Alexandra Winter References: <20231212022749.625238-1-yury.norov@gmail.com> <20231212022749.625238-32-yury.norov@gmail.com> From: Wen Gu In-Reply-To: <20231212022749.625238-32-yury.norov@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.3 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 12 Dec 2023 05:27:15 -0800 (PST) On 2023/12/12 10:27, Yury Norov wrote: > Simplify the function by using find_and_set_bit() and make it a simple > almost one-liner. > > While here, drop explicit initialization of *idx, because it's already > initialized by the caller in case of ENOLINK, or set properly with > ->wr_tx_mask, if nothing is found, in case of EBUSY. > > CC: Tony Lu > Signed-off-by: Yury Norov > Reviewed-by: Alexandra Winter > --- > net/smc/smc_wr.c | 10 +++------- > 1 file changed, 3 insertions(+), 7 deletions(-) > > diff --git a/net/smc/smc_wr.c b/net/smc/smc_wr.c > index 0021065a600a..b6f0cfc52788 100644 > --- a/net/smc/smc_wr.c > +++ b/net/smc/smc_wr.c > @@ -170,15 +170,11 @@ void smc_wr_tx_cq_handler(struct ib_cq *ib_cq, void *cq_context) > > static inline int smc_wr_tx_get_free_slot_index(struct smc_link *link, u32 *idx) > { > - *idx = link->wr_tx_cnt; > if (!smc_link_sendable(link)) > return -ENOLINK; > - for_each_clear_bit(*idx, link->wr_tx_mask, link->wr_tx_cnt) { > - if (!test_and_set_bit(*idx, link->wr_tx_mask)) > - return 0; > - } > - *idx = link->wr_tx_cnt; > - return -EBUSY; > + > + *idx = find_and_set_bit(link->wr_tx_mask, link->wr_tx_cnt); > + return *idx < link->wr_tx_cnt ? 0 : -EBUSY; > } > > /** Thank you! Yury. Reviewed-by: Wen Gu