Netdev List
 help / color / mirror / Atom feed
* [PATCH] net: hsr: simplify fill_last_seq_nrs()
@ 2026-06-09 17:15 Yury Norov
  2026-06-11  8:45 ` Felix Maurer
  2026-06-12 23:30 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Yury Norov @ 2026-06-09 17:15 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman, Felix Maurer, Sebastian Andrzej Siewior, Kexin Sun,
	Yury Norov, Quan Sun, Luka Gejak, netdev, linux-kernel

The function checks the HSR_PT_SLAVE_A and HSR_PT_SLAVE_B bitmaps
for emptiness right before calling find_last_bit().

This pass may be avoided, because if the bitmap is empty, the
find_last_bit() returns >= HSR_SEQ_BLOCK_SIZE

Signed-off-by: Yury Norov <ynorov@nvidia.com>
---
 net/hsr/hsr_framereg.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/net/hsr/hsr_framereg.c b/net/hsr/hsr_framereg.c
index 124619920d38..bf143b86999b 100644
--- a/net/hsr/hsr_framereg.c
+++ b/net/hsr/hsr_framereg.c
@@ -827,18 +827,14 @@ static void fill_last_seq_nrs(struct hsr_node *node, u16 *if1_seq, u16 *if2_seq)
 	block_sz = hsr_seq_block_size(node);
 	block = node->block_buf + block_off * block_sz;
 
-	if (!bitmap_empty(block->seq_nrs[HSR_PT_SLAVE_B - 1],
-			  HSR_SEQ_BLOCK_SIZE)) {
-		seq_bit = find_last_bit(block->seq_nrs[HSR_PT_SLAVE_B - 1],
-					HSR_SEQ_BLOCK_SIZE);
+	seq_bit = find_last_bit(block->seq_nrs[HSR_PT_SLAVE_B - 1], HSR_SEQ_BLOCK_SIZE);
+	if (seq_bit < HSR_SEQ_BLOCK_SIZE)
 		*if1_seq = (block->block_idx << HSR_SEQ_BLOCK_SHIFT) | seq_bit;
-	}
-	if (!bitmap_empty(block->seq_nrs[HSR_PT_SLAVE_A - 1],
-			  HSR_SEQ_BLOCK_SIZE)) {
-		seq_bit = find_last_bit(block->seq_nrs[HSR_PT_SLAVE_A - 1],
-					HSR_SEQ_BLOCK_SIZE);
+
+	seq_bit = find_last_bit(block->seq_nrs[HSR_PT_SLAVE_A - 1], HSR_SEQ_BLOCK_SIZE);
+	if (seq_bit < HSR_SEQ_BLOCK_SIZE)
 		*if2_seq = (block->block_idx << HSR_SEQ_BLOCK_SHIFT) | seq_bit;
-	}
+
 	spin_unlock_bh(&node->seq_out_lock);
 }
 
-- 
2.53.0


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

* Re: [PATCH] net: hsr: simplify fill_last_seq_nrs()
  2026-06-09 17:15 [PATCH] net: hsr: simplify fill_last_seq_nrs() Yury Norov
@ 2026-06-11  8:45 ` Felix Maurer
  2026-06-12 23:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Felix Maurer @ 2026-06-11  8:45 UTC (permalink / raw)
  To: Yury Norov
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman, Sebastian Andrzej Siewior, Kexin Sun, Yury Norov,
	Quan Sun, Luka Gejak, netdev, linux-kernel

On Tue, Jun 09, 2026 at 01:15:44PM -0400, Yury Norov wrote:
> The function checks the HSR_PT_SLAVE_A and HSR_PT_SLAVE_B bitmaps
> for emptiness right before calling find_last_bit().
>
> This pass may be avoided, because if the bitmap is empty, the
> find_last_bit() returns >= HSR_SEQ_BLOCK_SIZE
>
> Signed-off-by: Yury Norov <ynorov@nvidia.com>

Reviewed-by: Felix Maurer <fmaurer@redhat.com>

Looks good to me, thank you!


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

* Re: [PATCH] net: hsr: simplify fill_last_seq_nrs()
  2026-06-09 17:15 [PATCH] net: hsr: simplify fill_last_seq_nrs() Yury Norov
  2026-06-11  8:45 ` Felix Maurer
@ 2026-06-12 23:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-06-12 23:30 UTC (permalink / raw)
  To: Yury Norov
  Cc: davem, edumazet, kuba, pabeni, horms, fmaurer, bigeasy, kexinsun,
	ynorov, 2022090917019, luka.gejak, netdev, linux-kernel

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Tue,  9 Jun 2026 13:15:44 -0400 you wrote:
> The function checks the HSR_PT_SLAVE_A and HSR_PT_SLAVE_B bitmaps
> for emptiness right before calling find_last_bit().
> 
> This pass may be avoided, because if the bitmap is empty, the
> find_last_bit() returns >= HSR_SEQ_BLOCK_SIZE
> 
> Signed-off-by: Yury Norov <ynorov@nvidia.com>
> 
> [...]

Here is the summary with links:
  - net: hsr: simplify fill_last_seq_nrs()
    https://git.kernel.org/netdev/net-next/c/8058d9755ecf

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2026-06-12 23:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-09 17:15 [PATCH] net: hsr: simplify fill_last_seq_nrs() Yury Norov
2026-06-11  8:45 ` Felix Maurer
2026-06-12 23:30 ` patchwork-bot+netdevbpf

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