* [Intel-wired-lan] [PATCH v2] i40e: drop useless bitmap_weight() call in i40e_set_rxfh_fields()
@ 2025-12-18 1:57 Yury Norov (NVIDIA)
2026-01-05 15:41 ` Simon Horman
2026-01-27 6:22 ` Rinitha, SX
0 siblings, 2 replies; 3+ messages in thread
From: Yury Norov (NVIDIA) @ 2025-12-18 1:57 UTC (permalink / raw)
To: Tony Nguyen, Przemek Kitszel, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, intel-wired-lan,
netdev, linux-kernel
Cc: Yury Norov (NVIDIA), Loktionov, Aleksandr
bitmap_weight() is O(N) and useless here, because the following
for_each_set_bit() returns immediately in case of empty flow_pctypes.
Signed-off-by: Yury Norov (NVIDIA) <yury.norov@gmail.com>
---
v1: https://lore.kernel.org/all/20251216002852.334561-1-yury.norov@gmail.com/
v2: don't drop flow_id (Aleksandr).
.../net/ethernet/intel/i40e/i40e_ethtool.c | 21 +++++++------------
1 file changed, 8 insertions(+), 13 deletions(-)
diff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
index f2c2646ea298..e64880b6b047 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
@@ -3637,6 +3637,7 @@ static int i40e_set_rxfh_fields(struct net_device *netdev,
((u64)i40e_read_rx_ctl(hw, I40E_PFQF_HENA(1)) << 32);
DECLARE_BITMAP(flow_pctypes, FLOW_PCTYPES_SIZE);
u64 i_set, i_setc;
+ u8 flow_id;
bitmap_zero(flow_pctypes, FLOW_PCTYPES_SIZE);
@@ -3720,20 +3721,14 @@ static int i40e_set_rxfh_fields(struct net_device *netdev,
return -EINVAL;
}
- if (bitmap_weight(flow_pctypes, FLOW_PCTYPES_SIZE)) {
- u8 flow_id;
+ for_each_set_bit(flow_id, flow_pctypes, FLOW_PCTYPES_SIZE) {
+ i_setc = (u64)i40e_read_rx_ctl(hw, I40E_GLQF_HASH_INSET(0, flow_id)) |
+ ((u64)i40e_read_rx_ctl(hw, I40E_GLQF_HASH_INSET(1, flow_id)) << 32);
+ i_set = i40e_get_rss_hash_bits(&pf->hw, nfc, i_setc);
- for_each_set_bit(flow_id, flow_pctypes, FLOW_PCTYPES_SIZE) {
- i_setc = (u64)i40e_read_rx_ctl(hw, I40E_GLQF_HASH_INSET(0, flow_id)) |
- ((u64)i40e_read_rx_ctl(hw, I40E_GLQF_HASH_INSET(1, flow_id)) << 32);
- i_set = i40e_get_rss_hash_bits(&pf->hw, nfc, i_setc);
-
- i40e_write_rx_ctl(hw, I40E_GLQF_HASH_INSET(0, flow_id),
- (u32)i_set);
- i40e_write_rx_ctl(hw, I40E_GLQF_HASH_INSET(1, flow_id),
- (u32)(i_set >> 32));
- hena |= BIT_ULL(flow_id);
- }
+ i40e_write_rx_ctl(hw, I40E_GLQF_HASH_INSET(0, flow_id), (u32)i_set);
+ i40e_write_rx_ctl(hw, I40E_GLQF_HASH_INSET(1, flow_id), (u32)(i_set >> 32));
+ hena |= BIT_ULL(flow_id);
}
i40e_write_rx_ctl(hw, I40E_PFQF_HENA(0), (u32)hena);
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Intel-wired-lan] [PATCH v2] i40e: drop useless bitmap_weight() call in i40e_set_rxfh_fields()
2025-12-18 1:57 [Intel-wired-lan] [PATCH v2] i40e: drop useless bitmap_weight() call in i40e_set_rxfh_fields() Yury Norov (NVIDIA)
@ 2026-01-05 15:41 ` Simon Horman
2026-01-27 6:22 ` Rinitha, SX
1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2026-01-05 15:41 UTC (permalink / raw)
To: Yury Norov (NVIDIA)
Cc: Tony Nguyen, Przemek Kitszel, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, intel-wired-lan,
netdev, linux-kernel, Loktionov, Aleksandr
On Wed, Dec 17, 2025 at 08:57:57PM -0500, Yury Norov (NVIDIA) wrote:
> bitmap_weight() is O(N) and useless here, because the following
> for_each_set_bit() returns immediately in case of empty flow_pctypes.
>
> Signed-off-by: Yury Norov (NVIDIA) <yury.norov@gmail.com>
> ---
> v1: https://lore.kernel.org/all/20251216002852.334561-1-yury.norov@gmail.com/
> v2: don't drop flow_id (Aleksandr).
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Intel-wired-lan] [PATCH v2] i40e: drop useless bitmap_weight() call in i40e_set_rxfh_fields()
2025-12-18 1:57 [Intel-wired-lan] [PATCH v2] i40e: drop useless bitmap_weight() call in i40e_set_rxfh_fields() Yury Norov (NVIDIA)
2026-01-05 15:41 ` Simon Horman
@ 2026-01-27 6:22 ` Rinitha, SX
1 sibling, 0 replies; 3+ messages in thread
From: Rinitha, SX @ 2026-01-27 6:22 UTC (permalink / raw)
To: Yury Norov (NVIDIA), Nguyen, Anthony L, Kitszel, Przemyslaw,
Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, intel-wired-lan@lists.osuosl.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Loktionov, Aleksandr
> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of Yury Norov (NVIDIA)
> Sent: 18 December 2025 07:28
> To: Nguyen, Anthony L <anthony.l.nguyen@intel.com>; Kitszel, Przemyslaw <przemyslaw.kitszel@intel.com>; Andrew Lunn <andrew+netdev@lunn.ch>; David S. Miller <davem@davemloft.net>; Eric Dumazet <edumazet@google.com>; Jakub Kicinski <kuba@kernel.org>; Paolo Abeni <pabeni@redhat.com>; intel-wired-lan@lists.osuosl.org; netdev@vger.kernel.org; linux-kernel@vger.kernel.org
> Cc: Yury Norov (NVIDIA) <yury.norov@gmail.com>; Loktionov, Aleksandr <aleksandr.loktionov@intel.com>
> Subject: [Intel-wired-lan] [PATCH v2] i40e: drop useless bitmap_weight() call in i40e_set_rxfh_fields()
>
> bitmap_weight() is O(N) and useless here, because the following
> for_each_set_bit() returns immediately in case of empty flow_pctypes.
>
> Signed-off-by: Yury Norov (NVIDIA) <yury.norov@gmail.com>
> ---
> v1: https://lore.kernel.org/all/20251216002852.334561-1-yury.norov@gmail.com/
> v2: don't drop flow_id (Aleksandr).
>
> .../net/ethernet/intel/i40e/i40e_ethtool.c | 21 +++++++------------
> 1 file changed, 8 insertions(+), 13 deletions(-)
>
Tested-by: Rinitha S <sx.rinitha@intel.com> (A Contingent worker at Intel)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-01-27 6:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-18 1:57 [Intel-wired-lan] [PATCH v2] i40e: drop useless bitmap_weight() call in i40e_set_rxfh_fields() Yury Norov (NVIDIA)
2026-01-05 15:41 ` Simon Horman
2026-01-27 6:22 ` Rinitha, SX
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox