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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 26D34C433EF for ; Thu, 7 Apr 2022 10:37:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=mUPUk/qn1pbB+feWi36Vv8RLyFIZ+AtvvrGWlaiTjyA=; b=pYX4cte9TkP2Dq Q574+EgfGwWZgwcGrIRGLe5aGhYUXWlzq61lO/aANpIYtxK3JXIBHeJdzgk9JEO9Hc1liJSHb/99v McrF0CYBivaGHCtekKqRF+QTWxg9ipb/bPx45t7nSjv0Crz1GFXUcQlR1x1GMvDoyj1Yotr7QTxcO K/jOAoGlGkLJYyo539HQl1X6Hrl7vgwboxSkIvv9OjWz0ZHVKRu5KeGYSx7dsSMIPZDV4BFUj6CUl Y1weX24+kcwUraXZFgZLp4rURV5HlWkbeWnIh2OMUUTo07g3fsQ732nlQoNK9sDTOjgqdJ9L5ONmg w9JhTQO7dHuoWSa18LjQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ncPV4-00BH4b-5u; Thu, 07 Apr 2022 10:36:26 +0000 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ncPQ6-00BEGX-ND for linux-arm-kernel@lists.infradead.org; Thu, 07 Apr 2022 10:31:20 +0000 Received: by mail-ej1-x632.google.com with SMTP id i27so9864254ejd.9 for ; Thu, 07 Apr 2022 03:31:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=k+AveRuUfZMS7nrLE2qCYNI1T96Mx5+XYDPrjV8syDQ=; b=NcLD8mHaR4qaNPR6BVkLI8cR0N9faisH5bqM+PPDilSapF2TaoYIOm6cL6AzD7IbWj CBshM5QiBxeaw54xMXgap91pls2Kb5DPu5mg9Xg/5UAIUU4gW1w0pOZS0KeKNWr/kVJ3 BrDl1iS2myhrhLtoREcwcpaaioyTRJl8NPRjZxfUF6qzcfXh3RzU4tevnL07WCFfBVV3 PcqElTxD9nGyEUKAvM6/iFJitBW2/ljIDlNeUUcU2bf2uYx9XQVu+BmitEAqntOci0IY KMSBsY+JaFePOA6R2px14qoCJFT2c6j5LEg2gkuS+B04U9JJfAQVgVh381Rebhkj3RMz Z+gQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=k+AveRuUfZMS7nrLE2qCYNI1T96Mx5+XYDPrjV8syDQ=; b=ULS47E7kNntzCXt8/J89fUBUAbO5m7xYTfk10Cog1JbYTeD5M+RkmIR4iOMXLt5t9I z/ELfhfRHKW8v+4UK1kp6/YSljJhs8wW67HP4P7bXyvCnqBKxCkDFm0Hk05VJFie1cvW lsK4yPjBpenOGII26jc0QDay0xmflUqEj4qB8q0bqFOGLHwm29iy5GXyyTmZHRlBfAsi nxPubKFDCw8cZDLlim7JoFG2dLRA0/ZgKRc91oScCZfON+z3Rh4V2IzHW2oa/rmU7itr 3oR2vR9uwOlPM71rfizP4kVjfWjNe75IteHeUxUE7m1cqwUsO9Y7SmiTfltIXkC2eAD4 lJqQ== X-Gm-Message-State: AOAM531MdJZExMxyeFPCf1P914U5PkSTZ23f1m+YKQruxIDQzXT0jAza nq0FUf/Zk7FY6DNFQg8BsDM= X-Google-Smtp-Source: ABdhPJyUMk7P7yhyEFZWum6NOrzRuYQhvq6Vl8oB+OA51dwydUryDEsWaJ7QTxbXBBuOO2+NpgZo8A== X-Received: by 2002:a17:906:5d14:b0:6e8:3897:9ec2 with SMTP id g20-20020a1709065d1400b006e838979ec2mr2114089ejt.708.1649327474884; Thu, 07 Apr 2022 03:31:14 -0700 (PDT) Received: from localhost.localdomain (i130160.upc-i.chello.nl. [62.195.130.160]) by smtp.googlemail.com with ESMTPSA id c5-20020a170906d18500b006ce371f09d4sm7413573ejz.57.2022.04.07.03.31.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 03:31:14 -0700 (PDT) From: Jakob Koschel To: "David S. Miller" Cc: 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 , Martin Habets , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Jiri Pirko , Casper Andersson , Bjarni Jonasson , Jakob Koschel , Colin Ian King , Michael Walle , Christophe JAILLET , Arnd Bergmann , Eric Dumazet , Di Zhu , Xu Wang , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, Mike Rapoport , "Brian Johannesmeyer" , Cristiano Giuffrida , "Bos, H.J." Subject: [PATCH net-next 11/15] sfc: Remove usage of list iterator for list_add() after the loop body Date: Thu, 7 Apr 2022 12:28:56 +0200 Message-Id: <20220407102900.3086255-12-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220407102900.3086255-1-jakobkoschel@gmail.com> References: <20220407102900.3086255-1-jakobkoschel@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220407_033118_824020_A4BDD574 X-CRM114-Status: GOOD ( 16.71 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In preparation to limit the scope of a list iterator to the list traversal loop, use a dedicated pointer to point to the found element [1]. Before, the code implicitly used the head when no element was found when using &pos->list. Since the new variable is only set if an element was found, the list_add() is performed within the loop and only done after the loop if it is done on the list head directly. 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 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/sfc/rx_common.c b/drivers/net/ethernet/sfc/rx_common.c index 1b22c7be0088..a8822152ff83 100644 --- a/drivers/net/ethernet/sfc/rx_common.c +++ b/drivers/net/ethernet/sfc/rx_common.c @@ -563,8 +563,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) { + head = &ctx->list; break; + } id++; /* Check for wrap. If this happens, we have nearly 2^32 * allocated RSS contexts, which seems unlikely. @@ -582,7 +584,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, head); return new; } -- 2.25.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel