From patchwork Thu Apr 20 20:44:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 86039 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp612233vqo; Thu, 20 Apr 2023 14:00:56 -0700 (PDT) X-Google-Smtp-Source: AKy350b3PyNVcWNQipkIC6BUXZo44BQHa8EKwawFw3Mh/fX7ahkhmYitUYtnD8pqPCRsS3aQfxpa X-Received: by 2002:a05:6a20:548c:b0:ef:88c8:90ec with SMTP id i12-20020a056a20548c00b000ef88c890ecmr4370845pzk.10.1682024455815; Thu, 20 Apr 2023 14:00:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682024455; cv=none; d=google.com; s=arc-20160816; b=WwNU2GRf2Zwv5Rf0Qv1FyJrS7U3CM/rGzGLbeic47ltMbVOCiP+nXSxL7QSOatX6mg PIylNXGA+J5D9//7eIBcTvzibsdlR1aq0FxezBB+nWNr37vERWu1T6tXQXaC26O5/1M+ z4+eeHhEFT0pBtzXIUgAQbpqOXbH4yoArxK1ftXpwgoqnlaTG3j7LLDVR85TDG9nqrEn kMz3CsM6otTYUgWEK/YizQ1Z4YrM//wbLBibB8Uqv6By1qgcMV10qi+beZXNwVOK63fH FhEX3vt8aDw1QzbKTXr2hwMibVwKXKxcREe8u3Elr0cKqrZhINd2uZbVFFeUChNcQghS GGTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=a/xPA7tF/CGArRsFpwm1r+BaXbXOHoj1SyeyiFZc7Ow=; b=piFJ0E9qyRPNJPaw0b4F3Ynnhmttix2ZL9wxhoWRGqXhTA0CsfTRcjKrghvu78UOBZ EAvSvZi0Uw2ZTA4sQqQCE92Ag0URZov8WWncNr9RMVTz4RUhw8jVujxx6ZqedXUXfA3Q 2PLrSnscivywPCLYU/+dLu1x1AIIpoTUhkjok+LNQB+/SLP770pZ6apgc+RCCTZtLrlW SdAsl0TTEGioXsHBA2HrFn5AZcypGVk6vAz+JF4jpDyOa1JvnrXmttyRRPrlIRFK8B77 a3cCKAvdEB9fLvkDRt+A1CBeuFR55qtcXF+gUu71TABSp2q2H6Q36iokigQ+ZHiJF0dx GEqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=OaSdxjWr; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j13-20020a65430d000000b0051f265b549dsi2451881pgq.346.2023.04.20.14.00.42; Thu, 20 Apr 2023 14:00:55 -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; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=OaSdxjWr; 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 S232410AbjDTUo2 (ORCPT + 99 others); Thu, 20 Apr 2023 16:44:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232422AbjDTUoT (ORCPT ); Thu, 20 Apr 2023 16:44:19 -0400 Received: from smtp.smtpout.orange.fr (smtp-22.smtpout.orange.fr [80.12.242.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13C7035AA for ; Thu, 20 Apr 2023 13:44:16 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id pb8WpIj6fkuIhpb8WpSgq7; Thu, 20 Apr 2023 22:44:15 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1682023455; bh=a/xPA7tF/CGArRsFpwm1r+BaXbXOHoj1SyeyiFZc7Ow=; h=From:To:Cc:Subject:Date; b=OaSdxjWr68FBxCGG8hbo0vS4DKWX0NNIIIEp/bdFq016Hd/w9DvX0ITh2xvM6xYmn gQ2YqFCBgq+RkCNDXDw5QAzjNhtvsqz85OGRYL4bxraJQYQPUI8BQAx5gbVk0rPbu+ wpQNSRjfbb2fjFnRt+rieHruLqwCM68p3WVnbGAmoG/a3ltWiUydNj0ZvvcE7b2URg 0Y6/zAlrTmgabtK2VMYp6wonj3EJAkQRHowrg81Q3aU+ZGmXmZ7EbDrNGJUCX8wriV j0zCaVEy/fEPz5JVyLK2ru0tQWG2umnvVUEUuLEm5YAzRcxyzMxoaHuHlnmMjjN3oP FoDhnmwNLH7fA== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Thu, 20 Apr 2023 22:44:15 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Florian Fainelli , Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , netdev@vger.kernel.org Subject: [PATCH net-next] net: dsa: b53: Slightly optimize b53_arl_read() Date: Thu, 20 Apr 2023 22:44:10 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763730476137349880?= X-GMAIL-MSGID: =?utf-8?q?1763730476137349880?= When the 'free_bins' bitmap is cleared, it is better to use its full maximum size instead of only the needed size. This lets the compiler optimize it because the size is now known at compile time. B53_ARLTBL_MAX_BIN_ENTRIES is small (i.e. currently 4), so a call to memset() is saved. Also, as 'free_bins' is local to the function, the non-atomic __set_bit() can also safely be used here. Signed-off-by: Christophe JAILLET --- drivers/net/dsa/b53/b53_common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c index 3464ce5e7470..8c55fe0e0747 100644 --- a/drivers/net/dsa/b53/b53_common.c +++ b/drivers/net/dsa/b53/b53_common.c @@ -1627,7 +1627,7 @@ static int b53_arl_read(struct b53_device *dev, u64 mac, if (ret) return ret; - bitmap_zero(free_bins, dev->num_arl_bins); + bitmap_zero(free_bins, B53_ARLTBL_MAX_BIN_ENTRIES); /* Read the bins */ for (i = 0; i < dev->num_arl_bins; i++) { @@ -1641,7 +1641,7 @@ static int b53_arl_read(struct b53_device *dev, u64 mac, b53_arl_to_entry(ent, mac_vid, fwd_entry); if (!(fwd_entry & ARLTBL_VALID)) { - set_bit(i, free_bins); + __set_bit(i, free_bins); continue; } if ((mac_vid & ARLTBL_MAC_MASK) != mac)