* [PATCH 04/22] ice: use bitmap_empty() in ice_vf_has_no_qs_ena()
[not found] <20220510154750.212913-1-yury.norov@gmail.com>
@ 2022-05-10 15:47 ` Yury Norov
2022-05-10 15:47 ` [PATCH 06/22] octeontx2: use bitmap_empty() instead of bitmap_weight() Yury Norov
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Yury Norov @ 2022-05-10 15:47 UTC (permalink / raw)
To: Andy Shevchenko, David Laight, Greg Kroah-Hartman, Joe Perches,
Julia Lawall, Michał Mirosław, Nicholas Piggin,
Nicolas Palix, Peter Zijlstra, Rasmus Villemoes, Matti Vaittinen,
linux-kernel
Cc: Yury Norov, David S . Miller, Eric Dumazet, Jakub Kicinski,
Jesse Brandeburg, Paolo Abeni, Tony Nguyen, intel-wired-lan,
netdev
bitmap_empty() is better than bitmap_weight() because it may return
earlier, and improves on readability.
CC: David S. Miller <davem@davemloft.net>
CC: Eric Dumazet <edumazet@google.com>
CC: Jakub Kicinski <kuba@kernel.org>
CC: Jesse Brandeburg <jesse.brandeburg@intel.com>
CC: Paolo Abeni <pabeni@redhat.com>
CC: Tony Nguyen <anthony.l.nguyen@intel.com>
CC: intel-wired-lan@lists.osuosl.org
CC: netdev@vger.kernel.org
CC: linux-kernel@vger.kernel.org
Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
drivers/net/ethernet/intel/ice/ice_vf_lib.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_vf_lib.c b/drivers/net/ethernet/intel/ice/ice_vf_lib.c
index 6578059d9479..de67ac4075f0 100644
--- a/drivers/net/ethernet/intel/ice/ice_vf_lib.c
+++ b/drivers/net/ethernet/intel/ice/ice_vf_lib.c
@@ -740,8 +740,8 @@ bool ice_is_vf_trusted(struct ice_vf *vf)
*/
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.32.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 06/22] octeontx2: use bitmap_empty() instead of bitmap_weight()
[not found] <20220510154750.212913-1-yury.norov@gmail.com>
2022-05-10 15:47 ` [PATCH 04/22] ice: use bitmap_empty() in ice_vf_has_no_qs_ena() Yury Norov
@ 2022-05-10 15:47 ` Yury Norov
2022-05-10 21:31 ` Jakub Kicinski
2022-05-10 15:47 ` [PATCH 09/22] qed: replace bitmap_weight() with MANY_BITS() Yury Norov
` (2 subsequent siblings)
4 siblings, 1 reply; 6+ messages in thread
From: Yury Norov @ 2022-05-10 15:47 UTC (permalink / raw)
To: Andy Shevchenko, David Laight, Greg Kroah-Hartman, Joe Perches,
Julia Lawall, Michał Mirosław, Nicholas Piggin,
Nicolas Palix, Peter Zijlstra, Rasmus Villemoes, Matti Vaittinen,
linux-kernel
Cc: Yury Norov, David S . Miller, Eric Dumazet, Geetha sowjanya,
Jakub Kicinski, Jerin Jacob, Linu Cherian, Paolo Abeni,
Subbaraya Sundeep, Sunil Goutham, hariprasad, netdev
bitmap_empty() is better than bitmap_weight() because it may return
earlier, and improves on readability.
CC: David S. Miller <davem@davemloft.net>
CC: Eric Dumazet <edumazet@google.com>
CC: Geetha sowjanya <gakula@marvell.com>
CC: Jakub Kicinski <kuba@kernel.org>
CC: Jerin Jacob <jerinj@marvell.com>
CC: Linu Cherian <lcherian@marvell.com>
CC: Paolo Abeni <pabeni@redhat.com>
CC: Subbaraya Sundeep <sbhatta@marvell.com>
CC: Sunil Goutham <sgoutham@marvell.com>
CC: hariprasad <hkelam@marvell.com>
CC: netdev@vger.kernel.org
CC: linux-kernel@vger.kernel.org
Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
drivers/net/ethernet/marvell/octeontx2/af/cgx.c | 6 +++---
drivers/net/ethernet/marvell/octeontx2/af/rpm.c | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c b/drivers/net/ethernet/marvell/octeontx2/af/cgx.c
index 25491edc35ce..921bf9cb707b 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/cgx.c
@@ -615,7 +615,7 @@ void cgx_lmac_enadis_rx_pause_fwding(void *cgxd, int lmac_id, bool enable)
return;
/* Pause frames are not enabled just return */
- if (!bitmap_weight(lmac->rx_fc_pfvf_bmap.bmap, lmac->rx_fc_pfvf_bmap.max))
+ if (bitmap_empty(lmac->rx_fc_pfvf_bmap.bmap, lmac->rx_fc_pfvf_bmap.max))
return;
cgx_lmac_get_pause_frm_status(cgx, lmac_id, &rx_pause, &tx_pause);
@@ -870,13 +870,13 @@ int verify_lmac_fc_cfg(void *cgxd, int lmac_id, u8 tx_pause, u8 rx_pause,
set_bit(pfvf_idx, lmac->tx_fc_pfvf_bmap.bmap);
/* check if other pfvfs are using flow control */
- if (!rx_pause && bitmap_weight(lmac->rx_fc_pfvf_bmap.bmap, lmac->rx_fc_pfvf_bmap.max)) {
+ if (!rx_pause && !bitmap_empty(lmac->rx_fc_pfvf_bmap.bmap, lmac->rx_fc_pfvf_bmap.max)) {
dev_warn(&cgx->pdev->dev,
"Receive Flow control disable not permitted as its used by other PFVFs\n");
return -EPERM;
}
- if (!tx_pause && bitmap_weight(lmac->tx_fc_pfvf_bmap.bmap, lmac->tx_fc_pfvf_bmap.max)) {
+ if (!tx_pause && !bitmap_empty(lmac->tx_fc_pfvf_bmap.bmap, lmac->tx_fc_pfvf_bmap.max)) {
dev_warn(&cgx->pdev->dev,
"Transmit Flow control disable not permitted as its used by other PFVFs\n");
return -EPERM;
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rpm.c b/drivers/net/ethernet/marvell/octeontx2/af/rpm.c
index 47e83d7a5804..f2c866825c81 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rpm.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rpm.c
@@ -109,7 +109,7 @@ void rpm_lmac_enadis_rx_pause_fwding(void *rpmd, int lmac_id, bool enable)
return;
/* Pause frames are not enabled just return */
- if (!bitmap_weight(lmac->rx_fc_pfvf_bmap.bmap, lmac->rx_fc_pfvf_bmap.max))
+ if (bitmap_empty(lmac->rx_fc_pfvf_bmap.bmap, lmac->rx_fc_pfvf_bmap.max))
return;
if (enable) {
--
2.32.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 09/22] qed: replace bitmap_weight() with MANY_BITS()
[not found] <20220510154750.212913-1-yury.norov@gmail.com>
2022-05-10 15:47 ` [PATCH 04/22] ice: use bitmap_empty() in ice_vf_has_no_qs_ena() Yury Norov
2022-05-10 15:47 ` [PATCH 06/22] octeontx2: use bitmap_empty() instead of bitmap_weight() Yury Norov
@ 2022-05-10 15:47 ` Yury Norov
2022-05-10 15:47 ` [PATCH 10/22] net/mlx5e: simplify mlx5e_set_fecparam() Yury Norov
2022-05-10 15:47 ` [PATCH 15/22] net/mlx5: use cpumask_weight_gt() in irq_pool_request_irq() Yury Norov
4 siblings, 0 replies; 6+ messages in thread
From: Yury Norov @ 2022-05-10 15:47 UTC (permalink / raw)
To: Andy Shevchenko, David Laight, Greg Kroah-Hartman, Joe Perches,
Julia Lawall, Michał Mirosław, Nicholas Piggin,
Nicolas Palix, Peter Zijlstra, Rasmus Villemoes, Matti Vaittinen,
linux-kernel
Cc: Yury Norov, Ariel Elior, David S . Miller, Eric Dumazet,
Jakub Kicinski, Manish Chopra, Paolo Abeni, netdev
qed_init_qm_get_idx_from_flags() uses bitmap_weight() to check if
number of bits in pq_flags is greater than 1.
It's a bad practice to use bitmap API for things like flags, because flags
are not bitmaps (and it's bloating and potentially not safe - for example
if flags are not declared as unsigned long).
In this case, MANY_BITS() fits better than bitmap_weight(), and
switching to MANY_BITS() silences scripts/coccinelle/api/bitmap.cocci.
CC: Ariel Elior <aelior@marvell.com>
CC: David S. Miller <davem@davemloft.net>
CC: Eric Dumazet <edumazet@google.com>
CC: Jakub Kicinski <kuba@kernel.org>
CC: Manish Chopra <manishc@marvell.com>
CC: Paolo Abeni <pabeni@redhat.com>
CC: netdev@vger.kernel.org
CC: linux-kernel@vger.kernel.org
Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
drivers/net/ethernet/qlogic/qed/qed_dev.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/qlogic/qed/qed_dev.c b/drivers/net/ethernet/qlogic/qed/qed_dev.c
index 672480c9d195..fbe69e538f53 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_dev.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_dev.c
@@ -1702,8 +1702,7 @@ static u16 *qed_init_qm_get_idx_from_flags(struct qed_hwfn *p_hwfn,
struct qed_qm_info *qm_info = &p_hwfn->qm_info;
/* Can't have multiple flags set here */
- if (bitmap_weight(&pq_flags,
- sizeof(pq_flags) * BITS_PER_BYTE) > 1) {
+ if (MANY_BITS(pq_flags)) {
DP_ERR(p_hwfn, "requested multiple pq flags 0x%lx\n", pq_flags);
goto err;
}
--
2.32.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 10/22] net/mlx5e: simplify mlx5e_set_fecparam()
[not found] <20220510154750.212913-1-yury.norov@gmail.com>
` (2 preceding siblings ...)
2022-05-10 15:47 ` [PATCH 09/22] qed: replace bitmap_weight() with MANY_BITS() Yury Norov
@ 2022-05-10 15:47 ` Yury Norov
2022-05-10 15:47 ` [PATCH 15/22] net/mlx5: use cpumask_weight_gt() in irq_pool_request_irq() Yury Norov
4 siblings, 0 replies; 6+ messages in thread
From: Yury Norov @ 2022-05-10 15:47 UTC (permalink / raw)
To: Andy Shevchenko, David Laight, Greg Kroah-Hartman, Joe Perches,
Julia Lawall, Michał Mirosław, Nicholas Piggin,
Nicolas Palix, Peter Zijlstra, Rasmus Villemoes, Matti Vaittinen,
linux-kernel
Cc: Yury Norov, David S . Miller, Eric Dumazet, Jakub Kicinski,
Leon Romanovsky, Paolo Abeni, Saeed Mahameed, netdev, linux-rdma
mlx5e_set_fecparam() used bitmap API to handle fecparam->fec. This is a
bad practice because ->fec is not a bitmap - it's an u32 mask.
The code wants to prevent user from passing ->fec with many modes
enables. For this purpose it's better to use MANY_BITS() macro, which
allows to avoid converting u32 to bitmap.
CC: David S. Miller <davem@davemloft.net>
CC: Eric Dumazet <edumazet@google.com>
CC: Jakub Kicinski <kuba@kernel.org>
CC: Leon Romanovsky <leon@kernel.org>
CC: Paolo Abeni <pabeni@redhat.com>
CC: Saeed Mahameed <saeedm@nvidia.com>
CC: netdev@vger.kernel.org
CC: linux-rdma@vger.kernel.org
CC: linux-kernel@vger.kernel.org
Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
index 6e80585d731f..316cb72c4cc8 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
@@ -1664,13 +1664,11 @@ static int mlx5e_set_fecparam(struct net_device *netdev,
{
struct mlx5e_priv *priv = netdev_priv(netdev);
struct mlx5_core_dev *mdev = priv->mdev;
- unsigned long fec_bitmap;
u16 fec_policy = 0;
int mode;
int err;
- bitmap_from_arr32(&fec_bitmap, &fecparam->fec, sizeof(fecparam->fec) * BITS_PER_BYTE);
- if (bitmap_weight(&fec_bitmap, ETHTOOL_FEC_LLRS_BIT + 1) > 1)
+ if (MANY_BITS(fecparam->fec))
return -EOPNOTSUPP;
for (mode = 0; mode < ARRAY_SIZE(pplm_fec_2_ethtool); mode++) {
--
2.32.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 15/22] net/mlx5: use cpumask_weight_gt() in irq_pool_request_irq()
[not found] <20220510154750.212913-1-yury.norov@gmail.com>
` (3 preceding siblings ...)
2022-05-10 15:47 ` [PATCH 10/22] net/mlx5e: simplify mlx5e_set_fecparam() Yury Norov
@ 2022-05-10 15:47 ` Yury Norov
4 siblings, 0 replies; 6+ messages in thread
From: Yury Norov @ 2022-05-10 15:47 UTC (permalink / raw)
To: Andy Shevchenko, David Laight, Greg Kroah-Hartman, Joe Perches,
Julia Lawall, Michał Mirosław, Nicholas Piggin,
Nicolas Palix, Peter Zijlstra, Rasmus Villemoes, Matti Vaittinen,
linux-kernel
Cc: Yury Norov, David S . Miller, Eric Dumazet, Jakub Kicinski,
Leon Romanovsky, Paolo Abeni, Saeed Mahameed, netdev, linux-rdma
cpumask_weight_gt() is more efficient because it may stop traversing
cpumask depending on condition.
CC: David S. Miller <davem@davemloft.net>
CC: Eric Dumazet <edumazet@google.com>
CC: Jakub Kicinski <kuba@kernel.org>
CC: Leon Romanovsky <leon@kernel.org>
CC: Paolo Abeni <pabeni@redhat.com>
CC: Saeed Mahameed <saeedm@nvidia.com>
CC: netdev@vger.kernel.org
CC: linux-rdma@vger.kernel.org
CC: linux-kernel@vger.kernel.org
Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
drivers/net/ethernet/mellanox/mlx5/core/irq_affinity.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/irq_affinity.c b/drivers/net/ethernet/mellanox/mlx5/core/irq_affinity.c
index 380a208ab137..d57f804ee934 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/irq_affinity.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/irq_affinity.c
@@ -58,7 +58,7 @@ irq_pool_request_irq(struct mlx5_irq_pool *pool, const struct cpumask *req_mask)
if (err)
return ERR_PTR(err);
if (pool->irqs_per_cpu) {
- if (cpumask_weight(req_mask) > 1)
+ if (cpumask_weight_gt(req_mask, 1))
/* if req_mask contain more then one CPU, set the least loadad CPU
* of req_mask
*/
--
2.32.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 06/22] octeontx2: use bitmap_empty() instead of bitmap_weight()
2022-05-10 15:47 ` [PATCH 06/22] octeontx2: use bitmap_empty() instead of bitmap_weight() Yury Norov
@ 2022-05-10 21:31 ` Jakub Kicinski
0 siblings, 0 replies; 6+ messages in thread
From: Jakub Kicinski @ 2022-05-10 21:31 UTC (permalink / raw)
To: Yury Norov
Cc: Andy Shevchenko, David Laight, Greg Kroah-Hartman, Joe Perches,
Julia Lawall, Michał Mirosław, Nicholas Piggin,
Nicolas Palix, Peter Zijlstra, Rasmus Villemoes, Matti Vaittinen,
linux-kernel, David S . Miller, Eric Dumazet, Geetha sowjanya,
Jerin Jacob, Linu Cherian, Paolo Abeni, Subbaraya Sundeep,
Sunil Goutham, hariprasad, netdev
On Tue, 10 May 2022 08:47:34 -0700 Yury Norov wrote:
> bitmap_empty() is better than bitmap_weight() because it may return
> earlier, and improves on readability.
resend patches 6 and 9 separately please. if you CC the ML only on
a portion of the patches our build bot will ignore it.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-05-10 21:31 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20220510154750.212913-1-yury.norov@gmail.com>
2022-05-10 15:47 ` [PATCH 04/22] ice: use bitmap_empty() in ice_vf_has_no_qs_ena() Yury Norov
2022-05-10 15:47 ` [PATCH 06/22] octeontx2: use bitmap_empty() instead of bitmap_weight() Yury Norov
2022-05-10 21:31 ` Jakub Kicinski
2022-05-10 15:47 ` [PATCH 09/22] qed: replace bitmap_weight() with MANY_BITS() Yury Norov
2022-05-10 15:47 ` [PATCH 10/22] net/mlx5e: simplify mlx5e_set_fecparam() Yury Norov
2022-05-10 15:47 ` [PATCH 15/22] net/mlx5: use cpumask_weight_gt() in irq_pool_request_irq() 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).