From: Florian Fainelli <f.fainelli@gmail.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
Andrew Lunn <andrew@lunn.ch>, Vladimir Oltean <olteanv@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
netdev@vger.kernel.org
Subject: Re: [PATCH net-next] net: dsa: b53: Slightly optimize b53_arl_read()
Date: Thu, 20 Apr 2023 17:40:45 -0700 [thread overview]
Message-ID: <be0d976a-2219-d007-617d-6865c0344335@gmail.com> (raw)
In-Reply-To: <c94fb1b4dcd9a04eff08cf9ba2444c348477e554.1682023416.git.christophe.jaillet@wanadoo.fr>
On 4/20/2023 1:44 PM, Christophe JAILLET wrote:
> 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);
That one I am not a big fan, as the number of ARL bins is a function of
the switch model, and this illustrates it well.
>
> /* 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);
I would be keen on taking that hunk but keep the other as-is. Does that
work for you?
--
Florian
next prev parent reply other threads:[~2023-04-21 0:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-20 20:44 Christophe JAILLET
2023-04-21 0:40 ` Florian Fainelli [this message]
2023-04-21 5:40 ` Christophe JAILLET
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=be0d976a-2219-d007-617d-6865c0344335@gmail.com \
--to=f.fainelli@gmail.com \
--cc=andrew@lunn.ch \
--cc=christophe.jaillet@wanadoo.fr \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®