* [PATCH 01/54] net/dsa: don't use bitmap_weight() in b53_arl_read()
[not found] <20220123183925.1052919-1-yury.norov@gmail.com>
@ 2022-01-23 18:38 ` Yury Norov
2022-01-24 3:11 ` Florian Fainelli
2022-01-23 18:38 ` [PATCH 02/54] net/ethernet: don't use bitmap_weight() in bcm_sysport_rule_set() Yury Norov
` (7 subsequent siblings)
8 siblings, 1 reply; 18+ messages in thread
From: Yury Norov @ 2022-01-23 18:38 UTC (permalink / raw)
To: Yury Norov, Andy Shevchenko, Rasmus Villemoes, Andrew Morton,
Michał Mirosław, Greg Kroah-Hartman, Peter Zijlstra,
David Laight, Joe Perches, Dennis Zhou, Emil Renner Berthing,
Nicholas Piggin, Matti Vaittinen, Alexey Klimov, linux-kernel,
Florian Fainelli, Andrew Lunn, Vivien Didelot, Vladimir Oltean,
David S. Miller, Jakub Kicinski, netdev
Don't call bitmap_weight() if the following code can get by
without it.
Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
drivers/net/dsa/b53/b53_common.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index 3867f3d4545f..9a10d80125d9 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -1620,12 +1620,8 @@ static int b53_arl_read(struct b53_device *dev, u64 mac,
return 0;
}
- if (bitmap_weight(free_bins, dev->num_arl_bins) == 0)
- return -ENOSPC;
-
*idx = find_first_bit(free_bins, dev->num_arl_bins);
-
- return -ENOENT;
+ return *idx >= dev->num_arl_bins ? -ENOSPC : -ENOENT;
}
static int b53_arl_op(struct b53_device *dev, int op, int port,
--
2.30.2
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 02/54] net/ethernet: don't use bitmap_weight() in bcm_sysport_rule_set()
[not found] <20220123183925.1052919-1-yury.norov@gmail.com>
2022-01-23 18:38 ` [PATCH 01/54] net/dsa: don't use bitmap_weight() in b53_arl_read() Yury Norov
@ 2022-01-23 18:38 ` Yury Norov
2022-01-24 3:11 ` Florian Fainelli
2022-01-23 18:38 ` [PATCH 04/54] net: mellanox: fix open-coded for_each_set_bit() Yury Norov
` (6 subsequent siblings)
8 siblings, 1 reply; 18+ messages in thread
From: Yury Norov @ 2022-01-23 18:38 UTC (permalink / raw)
To: Yury Norov, Andy Shevchenko, Rasmus Villemoes, Andrew Morton,
Michał Mirosław, Greg Kroah-Hartman, Peter Zijlstra,
David Laight, Joe Perches, Dennis Zhou, Emil Renner Berthing,
Nicholas Piggin, Matti Vaittinen, Alexey Klimov, linux-kernel,
Florian Fainelli, David S . Miller ,
Jakub Kicinski, bcm-kernel-feedback-list, netdev
Don't call bitmap_weight() if the following code can get by
without it.
Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
drivers/net/ethernet/broadcom/bcmsysport.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index 60dde29974bf..5284a5c961db 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -2180,13 +2180,9 @@ static int bcm_sysport_rule_set(struct bcm_sysport_priv *priv,
if (nfc->fs.ring_cookie != RX_CLS_FLOW_WAKE)
return -EOPNOTSUPP;
- /* All filters are already in use, we cannot match more rules */
- if (bitmap_weight(priv->filters, RXCHK_BRCM_TAG_MAX) ==
- RXCHK_BRCM_TAG_MAX)
- return -ENOSPC;
-
index = find_first_zero_bit(priv->filters, RXCHK_BRCM_TAG_MAX);
if (index >= RXCHK_BRCM_TAG_MAX)
+ /* All filters are already in use, we cannot match more rules */
return -ENOSPC;
/* Location is the classification ID, and index is the position
--
2.30.2
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 04/54] net: mellanox: fix open-coded for_each_set_bit()
[not found] <20220123183925.1052919-1-yury.norov@gmail.com>
2022-01-23 18:38 ` [PATCH 01/54] net/dsa: don't use bitmap_weight() in b53_arl_read() Yury Norov
2022-01-23 18:38 ` [PATCH 02/54] net/ethernet: don't use bitmap_weight() in bcm_sysport_rule_set() Yury Norov
@ 2022-01-23 18:38 ` Yury Norov
2022-01-26 9:01 ` Tariq Toukan
2022-01-23 18:38 ` [PATCH 08/54] net: ethernet: replace bitmap_weight with bitmap_empty for intel Yury Norov
` (5 subsequent siblings)
8 siblings, 1 reply; 18+ messages in thread
From: Yury Norov @ 2022-01-23 18:38 UTC (permalink / raw)
To: Yury Norov, Andy Shevchenko, Rasmus Villemoes, Andrew Morton,
Michał Mirosław, Greg Kroah-Hartman, Peter Zijlstra,
David Laight, Joe Perches, Dennis Zhou, Emil Renner Berthing,
Nicholas Piggin, Matti Vaittinen, Alexey Klimov, linux-kernel,
Tariq Toukan, David S. Miller, Jakub Kicinski, netdev,
linux-rdma
Mellanox driver has an open-coded for_each_set_bit(). Fix it.
Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
drivers/net/ethernet/mellanox/mlx4/cmd.c | 23 ++++++-----------------
1 file changed, 6 insertions(+), 17 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c b/drivers/net/ethernet/mellanox/mlx4/cmd.c
index e10b7b04b894..c56d2194cbfc 100644
--- a/drivers/net/ethernet/mellanox/mlx4/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c
@@ -1994,21 +1994,16 @@ static void mlx4_allocate_port_vpps(struct mlx4_dev *dev, int port)
static int mlx4_master_activate_admin_state(struct mlx4_priv *priv, int slave)
{
- int port, err;
+ int p, port, err;
struct mlx4_vport_state *vp_admin;
struct mlx4_vport_oper_state *vp_oper;
struct mlx4_slave_state *slave_state =
&priv->mfunc.master.slave_state[slave];
struct mlx4_active_ports actv_ports = mlx4_get_active_ports(
&priv->dev, slave);
- int min_port = find_first_bit(actv_ports.ports,
- priv->dev.caps.num_ports) + 1;
- int max_port = min_port - 1 +
- bitmap_weight(actv_ports.ports, priv->dev.caps.num_ports);
- for (port = min_port; port <= max_port; port++) {
- if (!test_bit(port - 1, actv_ports.ports))
- continue;
+ for_each_set_bit(p, actv_ports.ports, priv->dev.caps.num_ports) {
+ port = p + 1;
priv->mfunc.master.vf_oper[slave].smi_enabled[port] =
priv->mfunc.master.vf_admin[slave].enable_smi[port];
vp_oper = &priv->mfunc.master.vf_oper[slave].vport[port];
@@ -2063,19 +2058,13 @@ static int mlx4_master_activate_admin_state(struct mlx4_priv *priv, int slave)
static void mlx4_master_deactivate_admin_state(struct mlx4_priv *priv, int slave)
{
- int port;
+ int p, port;
struct mlx4_vport_oper_state *vp_oper;
struct mlx4_active_ports actv_ports = mlx4_get_active_ports(
&priv->dev, slave);
- int min_port = find_first_bit(actv_ports.ports,
- priv->dev.caps.num_ports) + 1;
- int max_port = min_port - 1 +
- bitmap_weight(actv_ports.ports, priv->dev.caps.num_ports);
-
- for (port = min_port; port <= max_port; port++) {
- if (!test_bit(port - 1, actv_ports.ports))
- continue;
+ for_each_set_bit(p, actv_ports.ports, priv->dev.caps.num_ports) {
+ port = p + 1;
priv->mfunc.master.vf_oper[slave].smi_enabled[port] =
MLX4_VF_SMI_DISABLED;
vp_oper = &priv->mfunc.master.vf_oper[slave].vport[port];
--
2.30.2
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 08/54] net: ethernet: replace bitmap_weight with bitmap_empty for intel
[not found] <20220123183925.1052919-1-yury.norov@gmail.com>
` (2 preceding siblings ...)
2022-01-23 18:38 ` [PATCH 04/54] net: mellanox: fix open-coded for_each_set_bit() Yury Norov
@ 2022-01-23 18:38 ` Yury Norov
2022-01-23 18:38 ` [PATCH 09/54] net: ethernet: replace bitmap_weight with bitmap_empty for Marvell Yury Norov
` (4 subsequent siblings)
8 siblings, 0 replies; 18+ messages in thread
From: Yury Norov @ 2022-01-23 18:38 UTC (permalink / raw)
To: Yury Norov, Andy Shevchenko, Rasmus Villemoes, Andrew Morton,
Michał Mirosław, Greg Kroah-Hartman, Peter Zijlstra,
David Laight, Joe Perches, Dennis Zhou, Emil Renner Berthing,
Nicholas Piggin, Matti Vaittinen, Alexey Klimov, linux-kernel,
Jesse Brandeburg, Tony Nguyen, David S. Miller, Jakub Kicinski,
intel-wired-lan, netdev
The ice_vf_has_no_qs_ena() calls bitmap_weight() to check if any bit
of a given bitmap is set. It's better to use bitmap_empty() in that
case because bitmap_empty() stops traversing the bitmap as soon as it
finds first set bit, while bitmap_weight() counts all bits
unconditionally.
Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c
index 39b80124d282..9dd52aab68cc 100644
--- a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c
+++ b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c
@@ -267,8 +267,8 @@ ice_set_pfe_link(struct ice_vf *vf, struct virtchnl_pf_event *pfe,
*/
static bool ice_vf_has_no_qs_ena(struct ice_vf *vf)
{
- return (!bitmap_weight(vf->rxq_ena, ICE_MAX_RSS_QS_PER_VF) &&
- !bitmap_weight(vf->txq_ena, ICE_MAX_RSS_QS_PER_VF));
+ return (bitmap_empty(vf->rxq_ena, ICE_MAX_RSS_QS_PER_VF) &&
+ bitmap_empty(vf->txq_ena, ICE_MAX_RSS_QS_PER_VF));
}
/**
--
2.30.2
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 09/54] net: ethernet: replace bitmap_weight with bitmap_empty for Marvell
[not found] <20220123183925.1052919-1-yury.norov@gmail.com>
` (3 preceding siblings ...)
2022-01-23 18:38 ` [PATCH 08/54] net: ethernet: replace bitmap_weight with bitmap_empty for intel Yury Norov
@ 2022-01-23 18:38 ` Yury Norov
2022-01-23 18:38 ` [PATCH 10/54] net: ethernet: replace bitmap_weight with bitmap_empty for qlogic Yury Norov
` (3 subsequent siblings)
8 siblings, 0 replies; 18+ messages in thread
From: Yury Norov @ 2022-01-23 18:38 UTC (permalink / raw)
To: Yury Norov, Andy Shevchenko, Rasmus Villemoes, Andrew Morton,
Michał Mirosław, Greg Kroah-Hartman, Peter Zijlstra,
David Laight, Joe Perches, Dennis Zhou, Emil Renner Berthing,
Nicholas Piggin, Matti Vaittinen, Alexey Klimov, linux-kernel,
Sunil Goutham, Geetha sowjanya, Subbaraya Sundeep, hariprasad,
David S. Miller, Jakub Kicinski, netdev
In some places, octeontx2 code calls bitmap_weight() to check if any bit of
a given bitmap is set. It's better to use bitmap_empty() in that case
because bitmap_empty() stops traversing the bitmap as soon as it finds
first set bit, while bitmap_weight() counts all bits unconditionally.
Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c | 4 ++--
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c
index 77a13fb555fb..80b2d64b4136 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c
@@ -353,7 +353,7 @@ int otx2_add_macfilter(struct net_device *netdev, const u8 *mac)
{
struct otx2_nic *pf = netdev_priv(netdev);
- if (bitmap_weight(&pf->flow_cfg->dmacflt_bmap,
+ if (!bitmap_empty(&pf->flow_cfg->dmacflt_bmap,
pf->flow_cfg->dmacflt_max_flows))
netdev_warn(netdev,
"Add %pM to CGX/RPM DMAC filters list as well\n",
@@ -436,7 +436,7 @@ int otx2_get_maxflows(struct otx2_flow_config *flow_cfg)
return 0;
if (flow_cfg->nr_flows == flow_cfg->max_flows ||
- bitmap_weight(&flow_cfg->dmacflt_bmap,
+ !bitmap_empty(&flow_cfg->dmacflt_bmap,
flow_cfg->dmacflt_max_flows))
return flow_cfg->max_flows + flow_cfg->dmacflt_max_flows;
else
diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
index 6080ebd9bd94..3d369ccc7ab9 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
@@ -1115,7 +1115,7 @@ static int otx2_cgx_config_loopback(struct otx2_nic *pf, bool enable)
struct msg_req *msg;
int err;
- if (enable && bitmap_weight(&pf->flow_cfg->dmacflt_bmap,
+ if (enable && !bitmap_empty(&pf->flow_cfg->dmacflt_bmap,
pf->flow_cfg->dmacflt_max_flows))
netdev_warn(pf->netdev,
"CGX/RPM internal loopback might not work as DMAC filters are active\n");
--
2.30.2
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 10/54] net: ethernet: replace bitmap_weight with bitmap_empty for qlogic
[not found] <20220123183925.1052919-1-yury.norov@gmail.com>
` (4 preceding siblings ...)
2022-01-23 18:38 ` [PATCH 09/54] net: ethernet: replace bitmap_weight with bitmap_empty for Marvell Yury Norov
@ 2022-01-23 18:38 ` Yury Norov
2022-01-24 12:28 ` Andy Shevchenko
2022-01-23 18:39 ` [PATCH 31/54] net: ethernet: replace bitmap_weight with bitmap_weight_eq for intel Yury Norov
` (2 subsequent siblings)
8 siblings, 1 reply; 18+ messages in thread
From: Yury Norov @ 2022-01-23 18:38 UTC (permalink / raw)
To: Yury Norov, Andy Shevchenko, Rasmus Villemoes, Andrew Morton,
Michał Mirosław, Greg Kroah-Hartman, Peter Zijlstra,
David Laight, Joe Perches, Dennis Zhou, Emil Renner Berthing,
Nicholas Piggin, Matti Vaittinen, Alexey Klimov, linux-kernel,
Ariel Elior, Manish Chopra, David S. Miller, Jakub Kicinski,
netdev
qlogic/qed code calls bitmap_weight() to check if any bit of a given
bitmap is set. It's better to use bitmap_empty() in that case because
bitmap_empty() stops traversing the bitmap as soon as it finds first
set bit, while bitmap_weight() counts all bits unconditionally.
Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
drivers/net/ethernet/qlogic/qed/qed_rdma.c | 4 ++--
drivers/net/ethernet/qlogic/qed/qed_roce.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/qlogic/qed/qed_rdma.c b/drivers/net/ethernet/qlogic/qed/qed_rdma.c
index 23b668de4640..b6e2e17bac04 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_rdma.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_rdma.c
@@ -336,7 +336,7 @@ void qed_rdma_bmap_free(struct qed_hwfn *p_hwfn,
/* print aligned non-zero lines, if any */
for (item = 0, line = 0; line < last_line; line++, item += 8)
- if (bitmap_weight((unsigned long *)&pmap[item], 64 * 8))
+ if (!bitmap_empty((unsigned long *)&pmap[item], 64 * 8))
DP_NOTICE(p_hwfn,
"line 0x%04x: 0x%016llx 0x%016llx 0x%016llx 0x%016llx 0x%016llx 0x%016llx 0x%016llx 0x%016llx\n",
line,
@@ -350,7 +350,7 @@ void qed_rdma_bmap_free(struct qed_hwfn *p_hwfn,
/* print last unaligned non-zero line, if any */
if ((bmap->max_count % (64 * 8)) &&
- (bitmap_weight((unsigned long *)&pmap[item],
+ (!bitmap_empty((unsigned long *)&pmap[item],
bmap->max_count - item * 64))) {
offset = sprintf(str_last_line, "line 0x%04x: ", line);
for (; item < last_item; item++)
diff --git a/drivers/net/ethernet/qlogic/qed/qed_roce.c b/drivers/net/ethernet/qlogic/qed/qed_roce.c
index 071b4aeaddf2..134ecfca96a3 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_roce.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_roce.c
@@ -76,7 +76,7 @@ void qed_roce_stop(struct qed_hwfn *p_hwfn)
* We delay for a short while if an async destroy QP is still expected.
* Beyond the added delay we clear the bitmap anyway.
*/
- while (bitmap_weight(rcid_map->bitmap, rcid_map->max_count)) {
+ while (!bitmap_empty(rcid_map->bitmap, rcid_map->max_count)) {
/* If the HW device is during recovery, all resources are
* immediately reset without receiving a per-cid indication
* from HW. In this case we don't expect the cid bitmap to be
--
2.30.2
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 31/54] net: ethernet: replace bitmap_weight with bitmap_weight_eq for intel
[not found] <20220123183925.1052919-1-yury.norov@gmail.com>
` (5 preceding siblings ...)
2022-01-23 18:38 ` [PATCH 10/54] net: ethernet: replace bitmap_weight with bitmap_empty for qlogic Yury Norov
@ 2022-01-23 18:39 ` Yury Norov
2022-01-23 18:39 ` [PATCH 32/54] net: ethernet: replace bitmap_weight with bitmap_weight_{eq,gt} for OcteonTX2 Yury Norov
2022-01-23 18:39 ` [PATCH 33/54] net: ethernet: replace bitmap_weight with bitmap_weight_{eq,gt,ge,lt,le} for mellanox Yury Norov
8 siblings, 0 replies; 18+ messages in thread
From: Yury Norov @ 2022-01-23 18:39 UTC (permalink / raw)
To: Yury Norov, Andy Shevchenko, Rasmus Villemoes, Andrew Morton,
Michał Mirosław, Greg Kroah-Hartman, Peter Zijlstra,
David Laight, Joe Perches, Dennis Zhou, Emil Renner Berthing,
Nicholas Piggin, Matti Vaittinen, Alexey Klimov, linux-kernel,
Jesse Brandeburg, Tony Nguyen, David S. Miller, Jakub Kicinski,
intel-wired-lan, netdev
ixgbe_disable_sriov calls bitmap_weight() to compare the weight of bitmap
with a given number. We can do it more efficiently with bitmap_weight_eq
because conditional bitmap_weight may stop traversing the bitmap earlier,
as soon as condition is met.
Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
index 214a38de3f41..35297d8a488b 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
@@ -246,7 +246,7 @@ int ixgbe_disable_sriov(struct ixgbe_adapter *adapter)
#endif
/* Disable VMDq flag so device will be set in VM mode */
- if (bitmap_weight(adapter->fwd_bitmask, adapter->num_rx_pools) == 1) {
+ if (bitmap_weight_eq(adapter->fwd_bitmask, adapter->num_rx_pools, 1)) {
adapter->flags &= ~IXGBE_FLAG_VMDQ_ENABLED;
adapter->flags &= ~IXGBE_FLAG_SRIOV_ENABLED;
rss = min_t(int, ixgbe_max_rss_indices(adapter),
--
2.30.2
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 32/54] net: ethernet: replace bitmap_weight with bitmap_weight_{eq,gt} for OcteonTX2
[not found] <20220123183925.1052919-1-yury.norov@gmail.com>
` (6 preceding siblings ...)
2022-01-23 18:39 ` [PATCH 31/54] net: ethernet: replace bitmap_weight with bitmap_weight_eq for intel Yury Norov
@ 2022-01-23 18:39 ` Yury Norov
2022-01-23 18:39 ` [PATCH 33/54] net: ethernet: replace bitmap_weight with bitmap_weight_{eq,gt,ge,lt,le} for mellanox Yury Norov
8 siblings, 0 replies; 18+ messages in thread
From: Yury Norov @ 2022-01-23 18:39 UTC (permalink / raw)
To: Yury Norov, Andy Shevchenko, Rasmus Villemoes, Andrew Morton,
Michał Mirosław, Greg Kroah-Hartman, Peter Zijlstra,
David Laight, Joe Perches, Dennis Zhou, Emil Renner Berthing,
Nicholas Piggin, Matti Vaittinen, Alexey Klimov, linux-kernel,
Sunil Goutham, Geetha sowjanya, Subbaraya Sundeep, hariprasad,
David S. Miller, Jakub Kicinski, netdev
OcteonTX2 code calls bitmap_weight() to compare the weight of bitmap with
a given number. We can do it more efficiently with bitmap_weight_{eq,gt}
because conditional bitmap_weight may stop traversing the bitmap earlier,
as soon as condition is met.
Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c | 2 +-
drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
index d85db90632d6..a55fd1d0c653 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
@@ -287,7 +287,7 @@ static int otx2_set_channels(struct net_device *dev,
if (!channel->rx_count || !channel->tx_count)
return -EINVAL;
- if (bitmap_weight(&pfvf->rq_bmap, pfvf->hw.rx_queues) > 1) {
+ if (bitmap_weight_gt(&pfvf->rq_bmap, pfvf->hw.rx_queues, 1)) {
netdev_err(dev,
"Receive queues are in use by TC police action\n");
return -EINVAL;
diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c
index 80b2d64b4136..55c899a6fcdd 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c
@@ -1170,8 +1170,8 @@ int otx2_remove_flow(struct otx2_nic *pfvf, u32 location)
* interface mac address and configure CGX/RPM block in
* promiscuous mode
*/
- if (bitmap_weight(&flow_cfg->dmacflt_bmap,
- flow_cfg->dmacflt_max_flows) == 1)
+ if (bitmap_weight_eq(&flow_cfg->dmacflt_bmap,
+ flow_cfg->dmacflt_max_flows, 1))
otx2_update_rem_pfmac(pfvf, DMAC_ADDR_DEL);
} else {
err = otx2_remove_flow_msg(pfvf, flow->entry, false);
--
2.30.2
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 33/54] net: ethernet: replace bitmap_weight with bitmap_weight_{eq,gt,ge,lt,le} for mellanox
[not found] <20220123183925.1052919-1-yury.norov@gmail.com>
` (7 preceding siblings ...)
2022-01-23 18:39 ` [PATCH 32/54] net: ethernet: replace bitmap_weight with bitmap_weight_{eq,gt} for OcteonTX2 Yury Norov
@ 2022-01-23 18:39 ` Yury Norov
2022-01-24 12:48 ` Andy Shevchenko
8 siblings, 1 reply; 18+ messages in thread
From: Yury Norov @ 2022-01-23 18:39 UTC (permalink / raw)
To: Yury Norov, Andy Shevchenko, Rasmus Villemoes, Andrew Morton,
Michał Mirosław, Greg Kroah-Hartman, Peter Zijlstra,
David Laight, Joe Perches, Dennis Zhou, Emil Renner Berthing,
Nicholas Piggin, Matti Vaittinen, Alexey Klimov, linux-kernel,
Sunil Goutham, Geetha sowjanya, Subbaraya Sundeep, hariprasad,
David S. Miller, Jakub Kicinski, netdev
Mellanox code uses bitmap_weight() to compare the weight of bitmap with
a given number. We can do it more efficiently with bitmap_weight_{eq, ...}
because conditional bitmap_weight may stop traversing the bitmap earlier,
as soon as condition is met.
Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
drivers/net/ethernet/mellanox/mlx4/cmd.c | 10 +++-------
drivers/net/ethernet/mellanox/mlx4/eq.c | 4 ++--
drivers/net/ethernet/mellanox/mlx4/fw.c | 4 ++--
drivers/net/ethernet/mellanox/mlx4/main.c | 2 +-
4 files changed, 8 insertions(+), 12 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c b/drivers/net/ethernet/mellanox/mlx4/cmd.c
index c56d2194cbfc..5bca0c68f00a 100644
--- a/drivers/net/ethernet/mellanox/mlx4/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c
@@ -2792,9 +2792,8 @@ int mlx4_slave_convert_port(struct mlx4_dev *dev, int slave, int port)
{
unsigned n;
struct mlx4_active_ports actv_ports = mlx4_get_active_ports(dev, slave);
- unsigned m = bitmap_weight(actv_ports.ports, dev->caps.num_ports);
- if (port <= 0 || port > m)
+ if (port <= 0 || bitmap_weight_lt(actv_ports.ports, dev->caps.num_ports, port))
return -EINVAL;
n = find_first_bit(actv_ports.ports, dev->caps.num_ports);
@@ -3404,10 +3403,6 @@ int mlx4_vf_set_enable_smi_admin(struct mlx4_dev *dev, int slave, int port,
struct mlx4_priv *priv = mlx4_priv(dev);
struct mlx4_active_ports actv_ports = mlx4_get_active_ports(
&priv->dev, slave);
- int min_port = find_first_bit(actv_ports.ports,
- priv->dev.caps.num_ports) + 1;
- int max_port = min_port - 1 +
- bitmap_weight(actv_ports.ports, priv->dev.caps.num_ports);
if (slave == mlx4_master_func_num(dev))
return 0;
@@ -3417,7 +3412,8 @@ int mlx4_vf_set_enable_smi_admin(struct mlx4_dev *dev, int slave, int port,
enabled < 0 || enabled > 1)
return -EINVAL;
- if (min_port == max_port && dev->caps.num_ports > 1) {
+ if (dev->caps.num_ports > 1 &&
+ bitmap_weight_eq(actv_ports.ports, priv->dev.caps.num_ports, 1)) {
mlx4_info(dev, "SMI access disallowed for single ported VFs\n");
return -EPROTONOSUPPORT;
}
diff --git a/drivers/net/ethernet/mellanox/mlx4/eq.c b/drivers/net/ethernet/mellanox/mlx4/eq.c
index 414e390e6b48..0c09432ff389 100644
--- a/drivers/net/ethernet/mellanox/mlx4/eq.c
+++ b/drivers/net/ethernet/mellanox/mlx4/eq.c
@@ -1435,8 +1435,8 @@ int mlx4_is_eq_shared(struct mlx4_dev *dev, int vector)
if (vector <= 0 || (vector >= dev->caps.num_comp_vectors + 1))
return -EINVAL;
- return !!(bitmap_weight(priv->eq_table.eq[vector].actv_ports.ports,
- dev->caps.num_ports) > 1);
+ return bitmap_weight_gt(priv->eq_table.eq[vector].actv_ports.ports,
+ dev->caps.num_ports, 1);
}
EXPORT_SYMBOL(mlx4_is_eq_shared);
diff --git a/drivers/net/ethernet/mellanox/mlx4/fw.c b/drivers/net/ethernet/mellanox/mlx4/fw.c
index 42c96c9d7fb1..855aae326ccb 100644
--- a/drivers/net/ethernet/mellanox/mlx4/fw.c
+++ b/drivers/net/ethernet/mellanox/mlx4/fw.c
@@ -1300,8 +1300,8 @@ int mlx4_QUERY_DEV_CAP_wrapper(struct mlx4_dev *dev, int slave,
actv_ports = mlx4_get_active_ports(dev, slave);
first_port = find_first_bit(actv_ports.ports, dev->caps.num_ports);
for (slave_port = 0, real_port = first_port;
- real_port < first_port +
- bitmap_weight(actv_ports.ports, dev->caps.num_ports);
+ bitmap_weight_gt(actv_ports.ports, dev->caps.num_ports,
+ real_port - first_port);
++real_port, ++slave_port) {
if (flags & (MLX4_DEV_CAP_FLAG_WOL_PORT1 << real_port))
flags |= MLX4_DEV_CAP_FLAG_WOL_PORT1 << slave_port;
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index b187c210d4d6..cfbaa7ac712f 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -1383,7 +1383,7 @@ static int mlx4_mf_bond(struct mlx4_dev *dev)
dev->persist->num_vfs + 1);
/* only single port vfs are allowed */
- if (bitmap_weight(slaves_port_1_2, dev->persist->num_vfs + 1) > 1) {
+ if (bitmap_weight_gt(slaves_port_1_2, dev->persist->num_vfs + 1, 1)) {
mlx4_warn(dev, "HA mode unsupported for dual ported VFs\n");
return -EINVAL;
}
--
2.30.2
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH 01/54] net/dsa: don't use bitmap_weight() in b53_arl_read()
2022-01-23 18:38 ` [PATCH 01/54] net/dsa: don't use bitmap_weight() in b53_arl_read() Yury Norov
@ 2022-01-24 3:11 ` Florian Fainelli
0 siblings, 0 replies; 18+ messages in thread
From: Florian Fainelli @ 2022-01-24 3:11 UTC (permalink / raw)
To: Yury Norov, Andy Shevchenko, Rasmus Villemoes, Andrew Morton,
Michał Mirosław, Greg Kroah-Hartman, Peter Zijlstra,
David Laight, Joe Perches, Dennis Zhou, Emil Renner Berthing,
Nicholas Piggin, Matti Vaittinen, Alexey Klimov, linux-kernel,
Andrew Lunn, Vivien Didelot, Vladimir Oltean, David S. Miller,
Jakub Kicinski, netdev
On 1/23/2022 10:38 AM, Yury Norov wrote:
> Don't call bitmap_weight() if the following code can get by
> without it.
>
> Signed-off-by: Yury Norov <yury.norov@gmail.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
--
Florian
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 02/54] net/ethernet: don't use bitmap_weight() in bcm_sysport_rule_set()
2022-01-23 18:38 ` [PATCH 02/54] net/ethernet: don't use bitmap_weight() in bcm_sysport_rule_set() Yury Norov
@ 2022-01-24 3:11 ` Florian Fainelli
0 siblings, 0 replies; 18+ messages in thread
From: Florian Fainelli @ 2022-01-24 3:11 UTC (permalink / raw)
To: Yury Norov, Andy Shevchenko, Rasmus Villemoes, Andrew Morton,
Michał Mirosław, Greg Kroah-Hartman, Peter Zijlstra,
David Laight, Joe Perches, Dennis Zhou, Emil Renner Berthing,
Nicholas Piggin, Matti Vaittinen, Alexey Klimov, linux-kernel,
David S . Miller, Jakub Kicinski, bcm-kernel-feedback-list,
netdev
On 1/23/2022 10:38 AM, Yury Norov wrote:
> Don't call bitmap_weight() if the following code can get by
> without it.
>
> Signed-off-by: Yury Norov <yury.norov@gmail.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
--
Florian
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 10/54] net: ethernet: replace bitmap_weight with bitmap_empty for qlogic
2022-01-23 18:38 ` [PATCH 10/54] net: ethernet: replace bitmap_weight with bitmap_empty for qlogic Yury Norov
@ 2022-01-24 12:28 ` Andy Shevchenko
2022-01-25 21:09 ` Yury Norov
0 siblings, 1 reply; 18+ messages in thread
From: Andy Shevchenko @ 2022-01-24 12:28 UTC (permalink / raw)
To: Yury Norov
Cc: Rasmus Villemoes, Andrew Morton, Michał Mirosław,
Greg Kroah-Hartman, Peter Zijlstra, David Laight, Joe Perches,
Dennis Zhou, Emil Renner Berthing, Nicholas Piggin,
Matti Vaittinen, Alexey Klimov, linux-kernel, Ariel Elior,
Manish Chopra, David S. Miller, Jakub Kicinski, netdev
On Sun, Jan 23, 2022 at 10:38:41AM -0800, Yury Norov wrote:
> qlogic/qed code calls bitmap_weight() to check if any bit of a given
> bitmap is set. It's better to use bitmap_empty() in that case because
> bitmap_empty() stops traversing the bitmap as soon as it finds first
> set bit, while bitmap_weight() counts all bits unconditionally.
> - if (bitmap_weight((unsigned long *)&pmap[item], 64 * 8))
> + if (!bitmap_empty((unsigned long *)&pmap[item], 64 * 8))
> - (bitmap_weight((unsigned long *)&pmap[item],
> + (!bitmap_empty((unsigned long *)&pmap[item],
Side note, these castings reminds me previous discussion and I'm wondering
if you have this kind of potentially problematic places in your TODO as
subject to fix.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 33/54] net: ethernet: replace bitmap_weight with bitmap_weight_{eq,gt,ge,lt,le} for mellanox
2022-01-23 18:39 ` [PATCH 33/54] net: ethernet: replace bitmap_weight with bitmap_weight_{eq,gt,ge,lt,le} for mellanox Yury Norov
@ 2022-01-24 12:48 ` Andy Shevchenko
2022-02-09 6:46 ` Yury Norov
0 siblings, 1 reply; 18+ messages in thread
From: Andy Shevchenko @ 2022-01-24 12:48 UTC (permalink / raw)
To: Yury Norov
Cc: Rasmus Villemoes, Andrew Morton, Michał Mirosław,
Greg Kroah-Hartman, Peter Zijlstra, David Laight, Joe Perches,
Dennis Zhou, Emil Renner Berthing, Nicholas Piggin,
Matti Vaittinen, Alexey Klimov, linux-kernel, Sunil Goutham,
Geetha sowjanya, Subbaraya Sundeep, hariprasad, David S. Miller,
Jakub Kicinski, netdev
On Sun, Jan 23, 2022 at 10:39:04AM -0800, Yury Norov wrote:
> Mellanox code uses bitmap_weight() to compare the weight of bitmap with
> a given number. We can do it more efficiently with bitmap_weight_{eq, ...}
> because conditional bitmap_weight may stop traversing the bitmap earlier,
> as soon as condition is met.
> - if (port <= 0 || port > m)
> + if (port <= 0 || bitmap_weight_lt(actv_ports.ports, dev->caps.num_ports, port))
> return -EINVAL;
Can we eliminate now the port <= 0 check? Or at least make it port == 0?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 10/54] net: ethernet: replace bitmap_weight with bitmap_empty for qlogic
2022-01-24 12:28 ` Andy Shevchenko
@ 2022-01-25 21:09 ` Yury Norov
2022-01-25 22:14 ` David Laight
0 siblings, 1 reply; 18+ messages in thread
From: Yury Norov @ 2022-01-25 21:09 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Rasmus Villemoes, Andrew Morton, Michał Mirosław,
Greg Kroah-Hartman, Peter Zijlstra, David Laight, Joe Perches,
Dennis Zhou, Emil Renner Berthing, Nicholas Piggin,
Matti Vaittinen, Alexey Klimov, linux-kernel, Ariel Elior,
Manish Chopra, David S. Miller, Jakub Kicinski, netdev
On Mon, Jan 24, 2022 at 4:29 AM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> On Sun, Jan 23, 2022 at 10:38:41AM -0800, Yury Norov wrote:
> > qlogic/qed code calls bitmap_weight() to check if any bit of a given
> > bitmap is set. It's better to use bitmap_empty() in that case because
> > bitmap_empty() stops traversing the bitmap as soon as it finds first
> > set bit, while bitmap_weight() counts all bits unconditionally.
>
> > - if (bitmap_weight((unsigned long *)&pmap[item], 64 * 8))
> > + if (!bitmap_empty((unsigned long *)&pmap[item], 64 * 8))
>
> > - (bitmap_weight((unsigned long *)&pmap[item],
> > + (!bitmap_empty((unsigned long *)&pmap[item],
>
> Side note, these castings reminds me previous discussion and I'm wondering
> if you have this kind of potentially problematic places in your TODO as
> subject to fix.
In the discussion you mentioned above, the u32* was cast to u64*,
which is wrong. The code
here is safe because in the worst case, it casts u64* to u32*. This
would be OK wrt
-Werror=array-bounds.
The function itself looks like doing this unsigned long <-> u64
conversions just for printing
purpose. I'm not a qlogic expert, so let's wait what people say?
The printing part may be refactored although to use %pb" format,
similarly to the snippet below
(not tested).
Thanks,
Yury
diff --git a/drivers/net/ethernet/qlogic/qed/qed_rdma.c
b/drivers/net/ethernet/qlogic/qed/qed_rdma.c
index 23b668de4640..72505517ced1 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_rdma.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_rdma.c
@@ -336,17 +336,8 @@ void qed_rdma_bmap_free(struct qed_hwfn *p_hwfn,
/* print aligned non-zero lines, if any */
for (item = 0, line = 0; line < last_line; line++, item += 8)
- if (bitmap_weight((unsigned long *)&pmap[item], 64 * 8))
- DP_NOTICE(p_hwfn,
- "line 0x%04x: 0x%016llx 0x%016llx
0x%016llx 0x%016llx 0x%016llx 0x%016llx 0x%016llx 0x%016llx\n",
- line,
- pmap[item],
- pmap[item + 1],
- pmap[item + 2],
- pmap[item + 3],
- pmap[item + 4],
- pmap[item + 5],
- pmap[item + 6], pmap[item + 7]);
+ if (bitmap_weight(bmap->bitmap, 64 * 8))
+ DP_NOTICE(p_hwfn, "line 0x%04x: %512pb\n",
line, bmap->bitmap);
/* print last unaligned non-zero line, if any */
if ((bmap->max_count % (64 * 8)) &&
^ permalink raw reply related [flat|nested] 18+ messages in thread
* RE: [PATCH 10/54] net: ethernet: replace bitmap_weight with bitmap_empty for qlogic
2022-01-25 21:09 ` Yury Norov
@ 2022-01-25 22:14 ` David Laight
2022-01-25 23:10 ` Yury Norov
0 siblings, 1 reply; 18+ messages in thread
From: David Laight @ 2022-01-25 22:14 UTC (permalink / raw)
To: 'Yury Norov', Andy Shevchenko
Cc: Rasmus Villemoes, Andrew Morton, Michał Mirosław,
Greg Kroah-Hartman, Peter Zijlstra, Joe Perches, Dennis Zhou,
Emil Renner Berthing, Nicholas Piggin, Matti Vaittinen,
Alexey Klimov, linux-kernel, Ariel Elior, Manish Chopra,
David S. Miller, Jakub Kicinski, netdev
From: Yury Norov
> Sent: 25 January 2022 21:10
> On Mon, Jan 24, 2022 at 4:29 AM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> >
> > On Sun, Jan 23, 2022 at 10:38:41AM -0800, Yury Norov wrote:
> > > qlogic/qed code calls bitmap_weight() to check if any bit of a given
> > > bitmap is set. It's better to use bitmap_empty() in that case because
> > > bitmap_empty() stops traversing the bitmap as soon as it finds first
> > > set bit, while bitmap_weight() counts all bits unconditionally.
> >
> > > - if (bitmap_weight((unsigned long *)&pmap[item], 64 * 8))
> > > + if (!bitmap_empty((unsigned long *)&pmap[item], 64 * 8))
> >
> > > - (bitmap_weight((unsigned long *)&pmap[item],
> > > + (!bitmap_empty((unsigned long *)&pmap[item],
> >
> > Side note, these castings reminds me previous discussion and I'm wondering
> > if you have this kind of potentially problematic places in your TODO as
> > subject to fix.
>
> In the discussion you mentioned above, the u32* was cast to u64*,
> which is wrong. The code
> here is safe because in the worst case, it casts u64* to u32*. This
> would be OK wrt
> -Werror=array-bounds.
>
> The function itself looks like doing this unsigned long <-> u64
> conversions just for printing
> purpose. I'm not a qlogic expert, so let's wait what people say?
It'll be wrong on BE systems.
You just can't cast the argument it has to be long[].
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 10/54] net: ethernet: replace bitmap_weight with bitmap_empty for qlogic
2022-01-25 22:14 ` David Laight
@ 2022-01-25 23:10 ` Yury Norov
0 siblings, 0 replies; 18+ messages in thread
From: Yury Norov @ 2022-01-25 23:10 UTC (permalink / raw)
To: David Laight
Cc: Andy Shevchenko, Rasmus Villemoes, Andrew Morton,
Michał Mirosław, Greg Kroah-Hartman, Peter Zijlstra,
Joe Perches, Dennis Zhou, Emil Renner Berthing, Nicholas Piggin,
Matti Vaittinen, Alexey Klimov, linux-kernel, Ariel Elior,
Manish Chopra, David S. Miller, Jakub Kicinski, netdev
On Tue, Jan 25, 2022 at 2:15 PM David Laight <David.Laight@aculab.com> wrote:
>
> From: Yury Norov
> > Sent: 25 January 2022 21:10
> > On Mon, Jan 24, 2022 at 4:29 AM Andy Shevchenko
> > <andriy.shevchenko@linux.intel.com> wrote:
> > >
> > > On Sun, Jan 23, 2022 at 10:38:41AM -0800, Yury Norov wrote:
> > > > qlogic/qed code calls bitmap_weight() to check if any bit of a given
> > > > bitmap is set. It's better to use bitmap_empty() in that case because
> > > > bitmap_empty() stops traversing the bitmap as soon as it finds first
> > > > set bit, while bitmap_weight() counts all bits unconditionally.
> > >
> > > > - if (bitmap_weight((unsigned long *)&pmap[item], 64 * 8))
> > > > + if (!bitmap_empty((unsigned long *)&pmap[item], 64 * 8))
> > >
> > > > - (bitmap_weight((unsigned long *)&pmap[item],
> > > > + (!bitmap_empty((unsigned long *)&pmap[item],
> > >
> > > Side note, these castings reminds me previous discussion and I'm wondering
> > > if you have this kind of potentially problematic places in your TODO as
> > > subject to fix.
> >
> > In the discussion you mentioned above, the u32* was cast to u64*,
> > which is wrong. The code
> > here is safe because in the worst case, it casts u64* to u32*. This
> > would be OK wrt
> > -Werror=array-bounds.
> >
> > The function itself looks like doing this unsigned long <-> u64
> > conversions just for printing
> > purpose. I'm not a qlogic expert, so let's wait what people say?
>
> It'll be wrong on BE systems.
The bitmap_weigh() result will be correct. As you can see, the address
is 64-bit aligned anyways. The array boundary violation will never happen
as well.
DP_NOTICE() may be wrong, or may not. It depends on how important
the absolute position of the bit in the printed bitmap is. Nevertheless,
printk("%pb") is better and should be used.
This whole concern may be simply irrelevant if QED is not supported
on 32-bit BE machines. From what I can see, at least Infiniband requires
64BIT.
Thanks,
Yury
> You just can't cast the argument it has to be long[].
>
> David
>
> -
> Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
> Registration No: 1397386 (Wales)
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 04/54] net: mellanox: fix open-coded for_each_set_bit()
2022-01-23 18:38 ` [PATCH 04/54] net: mellanox: fix open-coded for_each_set_bit() Yury Norov
@ 2022-01-26 9:01 ` Tariq Toukan
0 siblings, 0 replies; 18+ messages in thread
From: Tariq Toukan @ 2022-01-26 9:01 UTC (permalink / raw)
To: Yury Norov, Andy Shevchenko, Rasmus Villemoes, Andrew Morton,
Michał Mirosław, Greg Kroah-Hartman, Peter Zijlstra,
David Laight, Joe Perches, Dennis Zhou, Emil Renner Berthing,
Nicholas Piggin, Matti Vaittinen, Alexey Klimov, linux-kernel,
Tariq Toukan, David S. Miller, Jakub Kicinski, netdev,
linux-rdma
On 1/23/2022 8:38 PM, Yury Norov wrote:
> Mellanox driver has an open-coded for_each_set_bit(). Fix it.
>
> Signed-off-by: Yury Norov <yury.norov@gmail.com>
> ---
> drivers/net/ethernet/mellanox/mlx4/cmd.c | 23 ++++++-----------------
> 1 file changed, 6 insertions(+), 17 deletions(-)
>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Thanks,
Tariq
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 33/54] net: ethernet: replace bitmap_weight with bitmap_weight_{eq,gt,ge,lt,le} for mellanox
2022-01-24 12:48 ` Andy Shevchenko
@ 2022-02-09 6:46 ` Yury Norov
0 siblings, 0 replies; 18+ messages in thread
From: Yury Norov @ 2022-02-09 6:46 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Rasmus Villemoes, Andrew Morton, Michał Mirosław,
Greg Kroah-Hartman, Peter Zijlstra, David Laight, Joe Perches,
Dennis Zhou, Emil Renner Berthing, Nicholas Piggin,
Matti Vaittinen, Alexey Klimov, linux-kernel, Sunil Goutham,
Geetha sowjanya, Subbaraya Sundeep, hariprasad, David S. Miller,
Jakub Kicinski, netdev
On Mon, Jan 24, 2022 at 02:48:12PM +0200, Andy Shevchenko wrote:
> On Sun, Jan 23, 2022 at 10:39:04AM -0800, Yury Norov wrote:
> > Mellanox code uses bitmap_weight() to compare the weight of bitmap with
> > a given number. We can do it more efficiently with bitmap_weight_{eq, ...}
> > because conditional bitmap_weight may stop traversing the bitmap earlier,
> > as soon as condition is met.
>
> > - if (port <= 0 || port > m)
> > + if (port <= 0 || bitmap_weight_lt(actv_ports.ports, dev->caps.num_ports, port))
> > return -EINVAL;
>
> Can we eliminate now the port <= 0 check? Or at least make it port == 0?
The port is a parameter of exported function. I'd rather not take this risk.
Even if it makes sense, it should be a separate patch anyways.
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2022-02-09 6:49 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20220123183925.1052919-1-yury.norov@gmail.com>
2022-01-23 18:38 ` [PATCH 01/54] net/dsa: don't use bitmap_weight() in b53_arl_read() Yury Norov
2022-01-24 3:11 ` Florian Fainelli
2022-01-23 18:38 ` [PATCH 02/54] net/ethernet: don't use bitmap_weight() in bcm_sysport_rule_set() Yury Norov
2022-01-24 3:11 ` Florian Fainelli
2022-01-23 18:38 ` [PATCH 04/54] net: mellanox: fix open-coded for_each_set_bit() Yury Norov
2022-01-26 9:01 ` Tariq Toukan
2022-01-23 18:38 ` [PATCH 08/54] net: ethernet: replace bitmap_weight with bitmap_empty for intel Yury Norov
2022-01-23 18:38 ` [PATCH 09/54] net: ethernet: replace bitmap_weight with bitmap_empty for Marvell Yury Norov
2022-01-23 18:38 ` [PATCH 10/54] net: ethernet: replace bitmap_weight with bitmap_empty for qlogic Yury Norov
2022-01-24 12:28 ` Andy Shevchenko
2022-01-25 21:09 ` Yury Norov
2022-01-25 22:14 ` David Laight
2022-01-25 23:10 ` Yury Norov
2022-01-23 18:39 ` [PATCH 31/54] net: ethernet: replace bitmap_weight with bitmap_weight_eq for intel Yury Norov
2022-01-23 18:39 ` [PATCH 32/54] net: ethernet: replace bitmap_weight with bitmap_weight_{eq,gt} for OcteonTX2 Yury Norov
2022-01-23 18:39 ` [PATCH 33/54] net: ethernet: replace bitmap_weight with bitmap_weight_{eq,gt,ge,lt,le} for mellanox Yury Norov
2022-01-24 12:48 ` Andy Shevchenko
2022-02-09 6:46 ` Yury Norov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).