Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp387976rdf; Tue, 21 Nov 2023 05:41:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IFZMgGaWsbUpR/VmrCr2HoMf7l83vfd3GzEKGVQ/mK/Gk0Hu++beGJGgssIOR2iCPLGfEy/ X-Received: by 2002:a05:6a20:2203:b0:180:ebec:da1e with SMTP id u3-20020a056a20220300b00180ebecda1emr5963806pzb.21.1700574100177; Tue, 21 Nov 2023 05:41:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700574100; cv=none; d=google.com; s=arc-20160816; b=PrjHJE9Jws083deeH6A72HGJ8L6yW3NtjiNjCRU8HhLSxq/AYUOMgHMlfHEhETP9oA hQdjYfHv0j0L4u+meOFdPGeBl4ODODO7Y8/9yi4jJZidrKXxfspVwH5SDw6/NIj2qtTQ hfdE5AjFVff3la1mN4fCaWv4lJwl8xoru1vRsi29xexFTHwXUrdHJKJtGvAAm0PdXtlB w3TEoPHQ2NSXhAxWxCNdvkTZChHSOQcb0mjoZKD/cvoHGqakJ14OXMt+oslTLd8NGK/D Iae1cOs1+OpE53u2Owe0tAMIP1Scins/Vv+iemoj9taOmou8ZEv3dkydzU5nO10sn0oy gKHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=pcrYwFp88pWTL6yMI9KWImk/qrP0KNOz3TtNbxnSaOM=; fh=d6q2BRI6xHDyYkxQHH7yCcNkWmXc1Wk4oqYy12+KyIg=; b=0K8mOrd+bcIZL4/YWSW0O8U0OUGJ7EXsAJuHlGE/cDLEY7tifltxi0UdyLePBD4SrZ wPeaX7neIb6SJDHYAPxt8uxMiEBOx/8kvkTU/J5wxf779X81NkG4pSnhn+D9Yrqi2AZM aOhJIkf/NuCID1YWldOgN471r9l1+SBv2K4CCm/y1px4IC8yhCcPyOtqS+Oz6zYMUQFH huSX5bdrpi51TBgmVEC3AC0GL1P82U1lccE63LEXvFawj7LlfxwXpbEOYt0xqROhC0n/ RW1vC10ksYtBD6ImRhUZ30lmWEu2CY+NZbeP7OUtnV5oPIt1KJe3G57YanE4HfODLC2X FFAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fOZBM1wX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id e2-20020a654782000000b00565f0e91894si9734636pgs.394.2023.11.21.05.41.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 05:41:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fOZBM1wX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id E646A8077825; Tue, 21 Nov 2023 05:41:36 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234048AbjKUNl3 (ORCPT + 99 others); Tue, 21 Nov 2023 08:41:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233844AbjKUNl1 (ORCPT ); Tue, 21 Nov 2023 08:41:27 -0500 Received: from mail-yw1-x1132.google.com (mail-yw1-x1132.google.com [IPv6:2607:f8b0:4864:20::1132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B705D52; Tue, 21 Nov 2023 05:41:24 -0800 (PST) Received: by mail-yw1-x1132.google.com with SMTP id 00721157ae682-5c08c47c055so59629027b3.1; Tue, 21 Nov 2023 05:41:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700574083; x=1701178883; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=pcrYwFp88pWTL6yMI9KWImk/qrP0KNOz3TtNbxnSaOM=; b=fOZBM1wXb/g3/+EMdX9iCcndKGIWiISBUPuYuQ8EEYPVDamQFfFgeFI+iVL9FkvVeu t9rRuRsxD3KldxrPZcy3TDcMMcJrF1mgCtEo6RX+txtmnQgw5ZqwdAaM5VlHCgmWGt1Q sl1PPIDAH04hj+LKXgEi5caDL2ggREufFzFMSTJA+zeZFSLHzOQoVBFWIvfLZq3y5LUg Wmpf1iIVSCQYF7Fon/hUn9i/olHSacdxc4lec4y/a/hIehKOjYv0qh6xyxlWVefptyJJ pxHwH01Dp/XLzjWOQL8fIXu5bQUMIx6qLYbNZFmxwRYdWAeHh3BJSiRaeGjPnWPpwHLI LCfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700574083; x=1701178883; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=pcrYwFp88pWTL6yMI9KWImk/qrP0KNOz3TtNbxnSaOM=; b=taPcXC2DDWagd/CHbNPxBD32mohcZFvI6ExJJjteGRWBW0vAmyAGRmZ/EHsa57+6Xh aAVyGRVZrUbH8Lv0Qk/5ncEe+dLy1gsg1x1gufRZRHdwLP9leJGESrOAozegLu/54hFn RDo8cyUUX0FHTyAVlVL+cMkv8+PKbXH/2GC4UYt4jqLRGnQuejP0hZICIK/Z5Dv4XTBp 3CQTcTJQfC9ITcmMFRyHlC9lMJWWQX2beB5TlcqJWoh7Ao0ONRKtmKQPn2n9XEz9Ut0L kVL9BfxAsZtfxGZGxe+sfZDakHi0gzq13LDjtSsUVbu4k1kGviyH0XIoNqGHbCaWQRZm 8L7w== X-Gm-Message-State: AOJu0YwY3S7D348WYgdx3P2hEdR7aBnEM/63mU2bkhOi7YwnCeafRO4g yZ+buewtjXK/CbsWgmoHENE= X-Received: by 2002:a0d:d087:0:b0:5a7:ba53:6544 with SMTP id s129-20020a0dd087000000b005a7ba536544mr10495811ywd.12.1700574083485; Tue, 21 Nov 2023 05:41:23 -0800 (PST) Received: from localhost ([2601:344:8301:57f0:e005:b808:45e:1b60]) by smtp.gmail.com with ESMTPSA id q188-20020a0dcec5000000b00583f8f41cb8sm3010757ywd.63.2023.11.21.05.41.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 05:41:23 -0800 (PST) Date: Tue, 21 Nov 2023 05:41:22 -0800 From: Yury Norov To: Alexandra Winter Cc: linux-kernel@vger.kernel.org, Karsten Graul , Wenjia Zhang , Jan Karcher , "D. Wythe" , Tony Lu , Wen Gu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-s390@vger.kernel.org, netdev@vger.kernel.org, Jan Kara , Mirsad Todorovac , Matthew Wilcox , Rasmus Villemoes , Andy Shevchenko , Maxim Kuvyrkov , Alexey Klimov Subject: Re: [PATCH 29/34] net: smc: fix opencoded find_and_set_bit() in smc_wr_tx_get_free_slot_index() Message-ID: References: <20231118155105.25678-1-yury.norov@gmail.com> <20231118155105.25678-30-yury.norov@gmail.com> <04ff08d1-5892-44e8-bf74-802a225eeeda@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <04ff08d1-5892-44e8-bf74-802a225eeeda@linux.ibm.com> X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,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 fry.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 (fry.vger.email [0.0.0.0]); Tue, 21 Nov 2023 05:41:37 -0800 (PST) On Mon, Nov 20, 2023 at 09:43:54AM +0100, Alexandra Winter wrote: > > > On 18.11.23 16:51, Yury Norov wrote: > > The function opencodes find_and_set_bit() with a for_each() loop. Fix > > it, and make the whole function a simple almost one-liner. > > > > Signed-off-by: Yury Norov > > --- > > 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; > > } > > > > /** > > > My understanding is that you can omit the lines with > > - *idx = link->wr_tx_cnt; > because they only apply to the error paths and you checked that the calling function > does not use the idx variable in the error cases. Do I understand this correct? > > If so the removal of these 2 lines is not related to your change of using find_and_set_bit(), > do I understand that correctly? > > If so, it may be worth mentioning that in the commit message. I'll add: If find_and_set_bit() doesn't acquire a bit, it returns ->wr_tx_cnt, and so explicit initialization of *idx with the same value is unneeded. Makes sense?