mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net-next] net: dsa: b53: Slightly optimize b53_arl_read()
@ 2023-04-20 20:44 Christophe JAILLET
  2023-04-21  0:40 ` Florian Fainelli
  0 siblings, 1 reply; 3+ messages in thread
From: Christophe JAILLET @ 2023-04-20 20:44 UTC (permalink / raw)
  To: Florian Fainelli, Andrew Lunn, Vladimir Oltean, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, netdev

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 <christophe.jaillet@wanadoo.fr>
---
 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)
-- 
2.34.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-04-21  5:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-20 20:44 [PATCH net-next] net: dsa: b53: Slightly optimize b53_arl_read() Christophe JAILLET
2023-04-21  0:40 ` Florian Fainelli
2023-04-21  5:40   ` Christophe JAILLET

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®