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 Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E4B48C433EF for ; Tue, 19 Apr 2022 10:57:04 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KjLNH2vtgz3bcR for ; Tue, 19 Apr 2022 20:57:03 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=P1T979Cb; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2a00:1450:4864:20::42f; helo=mail-wr1-x42f.google.com; envelope-from=habetsm.xilinx@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=P1T979Cb; dkim-atps=neutral Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4KjG7C0hDMz2xrb for ; Tue, 19 Apr 2022 17:45:25 +1000 (AEST) Received: by mail-wr1-x42f.google.com with SMTP id c10so21256279wrb.1 for ; Tue, 19 Apr 2022 00:45:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=LIDXo/Uity2xr0NOefpQVn0crCBfVXuQDDJyi/aflIk=; b=P1T979CbMsI2SUmYhQenmVVAIhGym62LpiPwyhu9mqZxFcDQfYblpBVJSI318EvEkU 8qraQoEDiW07OJeqNLpO1y4LicWptHus+FDeTQ+ri0fKDi0Gd3qjTzchzJWw1eV3J2P/ ur+/YV9SpThD14a+M4Xmx2nBHefr2HCF9i0g9r/v0YFck8Sp1dDQHrhoCRX/D8LLD+nv hSbMh/wtA7UytVfbYUIxc8Vd3UCJhC0dZWi5dnl6xtPjbpaBDhqNaROJjuoWcG/xdpM/ cfT1g6fLQGRIHJeLkDOGbTqf4WV/fdLr/5gECYLOYf83BQnlZ2tdaiA8le5fVPy13rCW ro6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=LIDXo/Uity2xr0NOefpQVn0crCBfVXuQDDJyi/aflIk=; b=udOGfO8uMF58PaAhQ/ZgfRcqGdRcuqnPB0dnl/V+5iMwrA6bEj8CLuDHDMsTYxvcjl BnH5w5UpSraT2kvf2BrahDYsAeyPJhTK8fqYXOuZxnqqpHoLPDiiCs89hpD5p481MEh/ PMcqGRgeoHOEGcBtKIHmDAPw6Kq1KwYFM9xEpmff9oWmSrDEOeC1za3uWypCvY/apCsX skTr9PAKN5iCfWO4sJCgwsDIB5VqA1iJ7tkGLX+Lvy3iGqDcTObciCqYPzvfYcAuZCtM drs4iJVihTd+vS3XzuUSnRaM8ZXwGlWmo02k6cICil6lMiNjV49zO/l0EdmZgdfNM0Ir xXjQ== X-Gm-Message-State: AOAM530KzFpbVOVNxBm7hEL9hwXir9TxBAeIU3tThnvFeL1KSa1LOAeD 6pfJPTNM4mwx8VKwt5Og1TU= X-Google-Smtp-Source: ABdhPJzezuCr1A2N5D3o9C3Ys+bbuuIe1wYYoQKgg7RlsTX7w5PNcndV/T40ockclreuq/ypyy6ZLw== X-Received: by 2002:adf:e2cc:0:b0:203:e8ba:c709 with SMTP id d12-20020adfe2cc000000b00203e8bac709mr10556484wrj.713.1650354316985; Tue, 19 Apr 2022 00:45:16 -0700 (PDT) Received: from gmail.com ([81.168.73.77]) by smtp.gmail.com with ESMTPSA id h10-20020a05600c414a00b0038ebb6884d8sm22941157wmm.0.2022.04.19.00.45.15 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Apr 2022 00:45:16 -0700 (PDT) Date: Tue, 19 Apr 2022 08:45:13 +0100 From: Martin Habets To: Jakob Koschel Subject: Re: [PATCH net-next v4 14/18] sfc: Remove usage of list iterator for list_add() after the loop body Message-ID: <20220419074513.bgqmi3c5ydogpytj@gmail.com> Mail-Followup-To: Jakob Koschel , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , Lars Povlsen , Steen Hegelund , UNGLinuxDriver@microchip.com, Ariel Elior , Manish Chopra , Edward Cree , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Jiri Pirko , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Casper Andersson , Bjarni Jonasson , Christophe JAILLET , Arnd Bergmann , Colin Ian King , Eric Dumazet , Xu Wang , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, bpf@vger.kernel.org, Mike Rapoport , Brian Johannesmeyer , Cristiano Giuffrida , "Bos, H.J." References: <20220415122947.2754662-1-jakobkoschel@gmail.com> <20220415122947.2754662-15-jakobkoschel@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220415122947.2754662-15-jakobkoschel@gmail.com> User-Agent: NeoMutt/20170113 (1.7.2) X-Mailman-Approved-At: Tue, 19 Apr 2022 20:56:27 +1000 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Lunn , Song Liu , Alexei Starovoitov , Eric Dumazet , Paul Mackerras , Ariel Elior , Florian Fainelli , Daniel Borkmann , "David S. Miller" , Steen Hegelund , John Fastabend , Andrii Nakryiko , "Bos, H.J." , linux-arm-kernel@lists.infradead.org, Jakub Kicinski , Paolo Abeni , Vivien Didelot , Bjarni Jonasson , Jiri Pirko , Arnd Bergmann , KP Singh , Christophe JAILLET , Yonghong Song , Brian Johannesmeyer , Lars Povlsen , Colin Ian King , Manish Chopra , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, UNGLinuxDriver@microchip.com, Edward Cree , Casper Andersson , Xu Wang , Cristiano Giuffrida , bpf@vger.kernel.org, Vladimir Oltean , linuxppc-dev@lists.ozlabs.org, Martin KaFai Lau , Mike Rapoport Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Fri, Apr 15, 2022 at 02:29:43PM +0200, Jakob Koschel wrote: > In preparation to limit the scope of a list iterator to the list > traversal loop, use a dedicated pointer pointing to the location > where the element should be inserted [1]. > > Before, the code implicitly used the head when no element was found > when using &new->list. The new 'pos' variable is set to the list head > by default and overwritten if the list exits early, marking the > insertion point for list_add(). > > Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/ [1] > Signed-off-by: Jakob Koschel > --- > drivers/net/ethernet/sfc/rx_common.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/ethernet/sfc/rx_common.c b/drivers/net/ethernet/sfc/rx_common.c > index 1b22c7be0088..716847ba7038 100644 > --- a/drivers/net/ethernet/sfc/rx_common.c > +++ b/drivers/net/ethernet/sfc/rx_common.c > @@ -556,6 +556,7 @@ efx_rx_packet_gro(struct efx_channel *channel, struct efx_rx_buffer *rx_buf, > struct efx_rss_context *efx_alloc_rss_context_entry(struct efx_nic *efx) > { > struct list_head *head = &efx->rss_context.list; > + struct list_head *pos = head; This violates the reverse Xmas list policy. This definition should be 1 line further down. Martin > struct efx_rss_context *ctx, *new; > u32 id = 1; /* Don't use zero, that refers to the master RSS context */ > > @@ -563,8 +564,10 @@ struct efx_rss_context *efx_alloc_rss_context_entry(struct efx_nic *efx) > > /* Search for first gap in the numbering */ > list_for_each_entry(ctx, head, list) { > - if (ctx->user_id != id) > + if (ctx->user_id != id) { > + pos = &ctx->list; > break; > + } > id++; > /* Check for wrap. If this happens, we have nearly 2^32 > * allocated RSS contexts, which seems unlikely. > @@ -582,7 +585,7 @@ struct efx_rss_context *efx_alloc_rss_context_entry(struct efx_nic *efx) > > /* Insert the new entry into the gap */ > new->user_id = id; > - list_add_tail(&new->list, &ctx->list); > + list_add_tail(&new->list, pos); > return new; > } > > -- > 2.25.1