Christophe JAILLET
2021-Nov-14 19:02 UTC
[Bridge] [PATCH] net: bridge: Slightly optimize 'find_portno()'
The 'inuse' bitmap is local to this function. So we can use the non-atomic '__set_bit()' to save a few cycles. While at it, also remove some useless {}. Signed-off-by: Christophe JAILLET <christophe.jaillet at wanadoo.fr> --- net/bridge/br_if.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c index c1183fef1f21..64b2d4fb50f5 100644 --- a/net/bridge/br_if.c +++ b/net/bridge/br_if.c @@ -397,10 +397,10 @@ static int find_portno(struct net_bridge *br) if (!inuse) return -ENOMEM; - set_bit(0, inuse); /* zero is reserved */ - list_for_each_entry(p, &br->port_list, list) { - set_bit(p->port_no, inuse); - } + __set_bit(0, inuse); /* zero is reserved */ + list_for_each_entry(p, &br->port_list, list) + __set_bit(p->port_no, inuse); + index = find_first_zero_bit(inuse, BR_MAX_PORTS); bitmap_free(inuse); -- 2.30.2
Dan Carpenter
2021-Nov-15 12:35 UTC
[Bridge] [PATCH] net: bridge: Slightly optimize 'find_portno()'
On Sun, Nov 14, 2021 at 08:02:35PM +0100, Christophe JAILLET wrote:> The 'inuse' bitmap is local to this function. So we can use the > non-atomic '__set_bit()' to save a few cycles. > > While at it, also remove some useless {}.I like the {} and tend to add it in new code. There isn't a rule about this one way or the other. regards, dan carpenter
Nikolay Aleksandrov
2021-Nov-15 12:57 UTC
[Bridge] [PATCH] net: bridge: Slightly optimize 'find_portno()'
On 14/11/2021 21:02, Christophe JAILLET wrote:> The 'inuse' bitmap is local to this function. So we can use the > non-atomic '__set_bit()' to save a few cycles. > > While at it, also remove some useless {}. > > Signed-off-by: Christophe JAILLET <christophe.jaillet at wanadoo.fr> > --- > net/bridge/br_if.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c > index c1183fef1f21..64b2d4fb50f5 100644 > --- a/net/bridge/br_if.c > +++ b/net/bridge/br_if.c > @@ -397,10 +397,10 @@ static int find_portno(struct net_bridge *br) > if (!inuse) > return -ENOMEM; > > - set_bit(0, inuse); /* zero is reserved */ > - list_for_each_entry(p, &br->port_list, list) { > - set_bit(p->port_no, inuse); > - } > + __set_bit(0, inuse); /* zero is reserved */ > + list_for_each_entry(p, &br->port_list, list) > + __set_bit(p->port_no, inuse); > + > index = find_first_zero_bit(inuse, BR_MAX_PORTS); > bitmap_free(inuse); > >This should be targeted at net-next. The patch itself looks ok, TBH it's a slow path so speed doesn't really matter but it's a straight-forward change. Acked-by: Nikolay Aleksandrov <nikolay at nvidia.com>
patchwork-bot+netdevbpf at kernel.org
2021-Nov-15 14:10 UTC
[Bridge] [PATCH] net: bridge: Slightly optimize 'find_portno()'
Hello: This patch was applied to netdev/net-next.git (master) by David S. Miller <davem at davemloft.net>: On Sun, 14 Nov 2021 20:02:35 +0100 you wrote:> The 'inuse' bitmap is local to this function. So we can use the > non-atomic '__set_bit()' to save a few cycles. > > While at it, also remove some useless {}. > > Signed-off-by: Christophe JAILLET <christophe.jaillet at wanadoo.fr> > > [...]Here is the summary with links: - net: bridge: Slightly optimize 'find_portno()' https://git.kernel.org/netdev/net-next/c/cc0be1ad686f You are awesome, thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html