* [PATCH RESEND 0/3] ice: use better bitmap API
@ 2026-02-25 0:00 Yury Norov
2026-02-25 0:00 ` [PATCH RESEND 1/3] bitmap: introduce bitmap_weighted_xor() Yury Norov
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Yury Norov @ 2026-02-25 0:00 UTC (permalink / raw)
To: Tony Nguyen, Przemek Kitszel, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Yury Norov,
Rasmus Villemoes, Andrew Morton, intel-wired-lan, netdev,
linux-kernel
Cc: Yury Norov, David Laight
Use better bitmap API where appropriate.
Original series:
https://lore.kernel.org/all/20251223162303.434659-1-yury.norov@gmail.com/
RESEND: rebase on top of v7.0-rc1
Yury Norov (3):
bitmap: introduce bitmap_weighted_xor()
ice: use bitmap_weighted_xor() in ice_find_free_recp_res_idx()
ice: use bitmap_empty() in ice_vf_has_no_qs_ena
drivers/net/ethernet/intel/ice/ice_switch.c | 4 +---
drivers/net/ethernet/intel/ice/ice_vf_lib.c | 4 ++--
include/linux/bitmap.h | 14 ++++++++++++++
lib/bitmap.c | 7 +++++++
4 files changed, 24 insertions(+), 5 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH RESEND 1/3] bitmap: introduce bitmap_weighted_xor()
2026-02-25 0:00 [PATCH RESEND 0/3] ice: use better bitmap API Yury Norov
@ 2026-02-25 0:00 ` Yury Norov
2026-03-01 15:19 ` [RESEND,1/3] " Simon Horman
2026-02-25 0:00 ` [PATCH RESEND 2/3] ice: use bitmap_weighted_xor() in ice_find_free_recp_res_idx() Yury Norov
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: Yury Norov @ 2026-02-25 0:00 UTC (permalink / raw)
To: Tony Nguyen, Przemek Kitszel, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Yury Norov,
Rasmus Villemoes, Andrew Morton, intel-wired-lan, netdev,
linux-kernel
Cc: Yury Norov, David Laight
The function helps to XOR bitmaps and calculate Hamming weight of
the result in one pass.
Signed-off-by: Yury Norov <ynorov@nvidia.com>
---
include/linux/bitmap.h | 14 ++++++++++++++
lib/bitmap.c | 7 +++++++
2 files changed, 21 insertions(+)
diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
index b0395e4ccf90..5485076bb2d0 100644
--- a/include/linux/bitmap.h
+++ b/include/linux/bitmap.h
@@ -168,6 +168,8 @@ void __bitmap_or(unsigned long *dst, const unsigned long *bitmap1,
const unsigned long *bitmap2, unsigned int nbits);
unsigned int __bitmap_weighted_or(unsigned long *dst, const unsigned long *bitmap1,
const unsigned long *bitmap2, unsigned int nbits);
+unsigned int __bitmap_weighted_xor(unsigned long *dst, const unsigned long *bitmap1,
+ const unsigned long *bitmap2, unsigned int nbits);
void __bitmap_xor(unsigned long *dst, const unsigned long *bitmap1,
const unsigned long *bitmap2, unsigned int nbits);
bool __bitmap_andnot(unsigned long *dst, const unsigned long *bitmap1,
@@ -352,6 +354,18 @@ unsigned int bitmap_weighted_or(unsigned long *dst, const unsigned long *src1,
}
}
+static __always_inline
+unsigned int bitmap_weighted_xor(unsigned long *dst, const unsigned long *src1,
+ const unsigned long *src2, unsigned int nbits)
+{
+ if (small_const_nbits(nbits)) {
+ *dst = *src1 ^ *src2;
+ return hweight_long(*dst & BITMAP_LAST_WORD_MASK(nbits));
+ } else {
+ return __bitmap_weighted_xor(dst, src1, src2, nbits);
+ }
+}
+
static __always_inline
void bitmap_xor(unsigned long *dst, const unsigned long *src1,
const unsigned long *src2, unsigned int nbits)
diff --git a/lib/bitmap.c b/lib/bitmap.c
index 9dc526507875..a2bcb5b1fe99 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -361,6 +361,13 @@ unsigned int __bitmap_weighted_or(unsigned long *dst, const unsigned long *bitma
return BITMAP_WEIGHT(({dst[idx] = bitmap1[idx] | bitmap2[idx]; dst[idx]; }), bits);
}
+unsigned int __bitmap_weighted_xor(unsigned long *dst, const unsigned long *bitmap1,
+ const unsigned long *bitmap2, unsigned int bits)
+{
+ return BITMAP_WEIGHT(({dst[idx] = bitmap1[idx] ^ bitmap2[idx]; dst[idx]; }), bits);
+}
+EXPORT_SYMBOL(__bitmap_weighted_xor);
+
void __bitmap_set(unsigned long *map, unsigned int start, int len)
{
unsigned long *p = map + BIT_WORD(start);
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH RESEND 2/3] ice: use bitmap_weighted_xor() in ice_find_free_recp_res_idx()
2026-02-25 0:00 [PATCH RESEND 0/3] ice: use better bitmap API Yury Norov
2026-02-25 0:00 ` [PATCH RESEND 1/3] bitmap: introduce bitmap_weighted_xor() Yury Norov
@ 2026-02-25 0:00 ` Yury Norov
2026-02-25 0:00 ` [PATCH RESEND 3/3] ice: use bitmap_empty() in ice_vf_has_no_qs_ena Yury Norov
2026-02-25 12:02 ` [PATCH RESEND 0/3] ice: use better bitmap API Przemek Kitszel
3 siblings, 0 replies; 7+ messages in thread
From: Yury Norov @ 2026-02-25 0:00 UTC (permalink / raw)
To: Tony Nguyen, Przemek Kitszel, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Yury Norov,
Rasmus Villemoes, Andrew Morton, intel-wired-lan, netdev,
linux-kernel
Cc: Yury Norov, David Laight
Use the right helper and save one bitmaps traverse.
Signed-off-by: Yury Norov <ynorov@nvidia.com>
---
drivers/net/ethernet/intel/ice/ice_switch.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_switch.c b/drivers/net/ethernet/intel/ice/ice_switch.c
index bb0f990fa2c6..6a5875bd9c6b 100644
--- a/drivers/net/ethernet/intel/ice/ice_switch.c
+++ b/drivers/net/ethernet/intel/ice/ice_switch.c
@@ -4984,10 +4984,8 @@ ice_find_free_recp_res_idx(struct ice_hw *hw, const unsigned long *profiles,
hw->switch_info->recp_list[bit].res_idxs,
ICE_MAX_FV_WORDS);
- bitmap_xor(free_idx, used_idx, possible_idx, ICE_MAX_FV_WORDS);
-
/* return number of free indexes */
- return (u16)bitmap_weight(free_idx, ICE_MAX_FV_WORDS);
+ return (u16)bitmap_weighted_xor(free_idx, used_idx, possible_idx, ICE_MAX_FV_WORDS);
}
/**
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH RESEND 3/3] ice: use bitmap_empty() in ice_vf_has_no_qs_ena
2026-02-25 0:00 [PATCH RESEND 0/3] ice: use better bitmap API Yury Norov
2026-02-25 0:00 ` [PATCH RESEND 1/3] bitmap: introduce bitmap_weighted_xor() Yury Norov
2026-02-25 0:00 ` [PATCH RESEND 2/3] ice: use bitmap_weighted_xor() in ice_find_free_recp_res_idx() Yury Norov
@ 2026-02-25 0:00 ` Yury Norov
2026-02-25 12:02 ` [PATCH RESEND 0/3] ice: use better bitmap API Przemek Kitszel
3 siblings, 0 replies; 7+ messages in thread
From: Yury Norov @ 2026-02-25 0:00 UTC (permalink / raw)
To: Tony Nguyen, Przemek Kitszel, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Yury Norov,
Rasmus Villemoes, Andrew Morton, intel-wired-lan, netdev,
linux-kernel
Cc: Yury Norov, David Laight
bitmap_empty() is more verbose and efficient, as it stops traversing
{r,t}xq_ena as soon as the 1st set bit found.
Signed-off-by: Yury Norov <ynorov@nvidia.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 c8bc952f05cd..772f6b07340d 100644
--- a/drivers/net/ethernet/intel/ice/ice_vf_lib.c
+++ b/drivers/net/ethernet/intel/ice/ice_vf_lib.c
@@ -1210,8 +1210,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.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH RESEND 0/3] ice: use better bitmap API
2026-02-25 0:00 [PATCH RESEND 0/3] ice: use better bitmap API Yury Norov
` (2 preceding siblings ...)
2026-02-25 0:00 ` [PATCH RESEND 3/3] ice: use bitmap_empty() in ice_vf_has_no_qs_ena Yury Norov
@ 2026-02-25 12:02 ` Przemek Kitszel
2026-02-25 15:41 ` Yury Norov
3 siblings, 1 reply; 7+ messages in thread
From: Przemek Kitszel @ 2026-02-25 12:02 UTC (permalink / raw)
To: Yury Norov, Tony Nguyen, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Yury Norov,
Rasmus Villemoes, Andrew Morton, intel-wired-lan, netdev,
linux-kernel
Cc: David Laight
On 2/25/26 01:00, Yury Norov wrote:
> Use better bitmap API where appropriate.
>
> Original series:
>
> https://lore.kernel.org/all/20251223162303.434659-1-yury.norov@gmail.com/
>
> RESEND: rebase on top of v7.0-rc1
>
> Yury Norov (3):
> bitmap: introduce bitmap_weighted_xor()
> ice: use bitmap_weighted_xor() in ice_find_free_recp_res_idx()
Thank you for working on better API.
Do you want this to go through intel, then netdev, tree?
Likely that would slow any future user, if you have already one in mind.
> ice: use bitmap_empty() in ice_vf_has_no_qs_ena
For unrelated reasons I have one series that will possibly conflict
with your patch. Would prefer to not wait/block each other, so will
be best if we (Tony) just take this one (in case you will proceed
with the first two patches via your tree)
>
> drivers/net/ethernet/intel/ice/ice_switch.c | 4 +---
> drivers/net/ethernet/intel/ice/ice_vf_lib.c | 4 ++--
> include/linux/bitmap.h | 14 ++++++++++++++
> lib/bitmap.c | 7 +++++++
> 4 files changed, 24 insertions(+), 5 deletions(-)
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH RESEND 0/3] ice: use better bitmap API
2026-02-25 12:02 ` [PATCH RESEND 0/3] ice: use better bitmap API Przemek Kitszel
@ 2026-02-25 15:41 ` Yury Norov
0 siblings, 0 replies; 7+ messages in thread
From: Yury Norov @ 2026-02-25 15:41 UTC (permalink / raw)
To: Przemek Kitszel
Cc: Tony Nguyen, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Yury Norov, Rasmus Villemoes,
Andrew Morton, intel-wired-lan, netdev, linux-kernel,
Matthew Brost, David Laight
On Wed, Feb 25, 2026 at 01:02:35PM +0100, Przemek Kitszel wrote:
> On 2/25/26 01:00, Yury Norov wrote:
> > Use better bitmap API where appropriate.
> >
> > Original series:
> >
> > https://lore.kernel.org/all/20251223162303.434659-1-yury.norov@gmail.com/
> >
> > RESEND: rebase on top of v7.0-rc1
> >
> > Yury Norov (3):
> > bitmap: introduce bitmap_weighted_xor()
> > ice: use bitmap_weighted_xor() in ice_find_free_recp_res_idx()
>
> Thank you for working on better API.
> Do you want this to go through intel, then netdev, tree?
> Likely that would slow any future user, if you have already one in mind.
>
> > ice: use bitmap_empty() in ice_vf_has_no_qs_ena
>
> For unrelated reasons I have one series that will possibly conflict
> with your patch. Would prefer to not wait/block each other, so will
> be best if we (Tony) just take this one (in case you will proceed
> with the first two patches via your tree)
Another trivial user (recently added) for bitmap_weighted_xx() is
xe_pagefault_queue_init() in drivers/gpu/drm/xe/xe_pagefault.c, but
it's again the Intel's driver, so it will go with your tree anyways.
I'm not aware of others, so I believe Tony's tree is the best route.
> > drivers/net/ethernet/intel/ice/ice_switch.c | 4 +---
> > drivers/net/ethernet/intel/ice/ice_vf_lib.c | 4 ++--
> > include/linux/bitmap.h | 14 ++++++++++++++
> > lib/bitmap.c | 7 +++++++
> > 4 files changed, 24 insertions(+), 5 deletions(-)
+ Matthew Brost
Attaching a patch for xe_pagefault_queue_init(). Feel free to append it
to this series, or let me know if it's better to send it separately.
Thanks,
Yury
From 21804f4ae1674aa166e3566fa898996806ebd3e3 Mon Sep 17 00:00:00 2001
From: Yury Norov <ynorov@nvidia.com>
Date: Wed, 25 Feb 2026 10:02:22 -0500
Subject: [PATCH] drm/xe: switch xe_pagefault_queue_init() to using
bitmap_weighted_or()
The function calls bitmap_or() immediately followed by bitmap_weight().
Switch to using the dedicated bitmap_weighted_or() and save one bitmap
traverse.
Signed-off-by: Yury Norov <ynorov@nvidia.com>
---
drivers/gpu/drm/xe/xe_pagefault.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_pagefault.c b/drivers/gpu/drm/xe/xe_pagefault.c
index 6bee53d6ffc3..c4ce3cfe2164 100644
--- a/drivers/gpu/drm/xe/xe_pagefault.c
+++ b/drivers/gpu/drm/xe/xe_pagefault.c
@@ -285,10 +285,9 @@ static int xe_pagefault_queue_init(struct xe_device *xe,
xe_dss_mask_t all_dss;
int num_dss, num_eus;
- bitmap_or(all_dss, gt->fuse_topo.g_dss_mask,
+ num_dss = bitmap_weighted_or(all_dss, gt->fuse_topo.g_dss_mask,
gt->fuse_topo.c_dss_mask, XE_MAX_DSS_FUSE_BITS);
- num_dss = bitmap_weight(all_dss, XE_MAX_DSS_FUSE_BITS);
num_eus = bitmap_weight(gt->fuse_topo.eu_mask_per_dss,
XE_MAX_EU_FUSE_BITS) * num_dss;
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [RESEND,1/3] bitmap: introduce bitmap_weighted_xor()
2026-02-25 0:00 ` [PATCH RESEND 1/3] bitmap: introduce bitmap_weighted_xor() Yury Norov
@ 2026-03-01 15:19 ` Simon Horman
0 siblings, 0 replies; 7+ messages in thread
From: Simon Horman @ 2026-03-01 15:19 UTC (permalink / raw)
To: ynorov
Cc: Simon Horman, intel-wired-lan, edumazet, pabeni, anthony.l.nguyen,
akpm, przemyslaw.kitszel, andrew+netdev, david.laight.linux,
yury.norov, linux, netdev, davem, linux-kernel, kuba
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
bitmap: introduce bitmap_weighted_xor()
The function helps to XOR bitmaps and calculate Hamming weight of
the result in one pass.
> diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
> index b0395e4ccf90..5485076bb2d0 100644
> --- a/include/linux/bitmap.h
> +++ b/include/linux/bitmap.h
[ ... ]
> @@ -352,6 +354,18 @@ unsigned int bitmap_weighted_or(unsigned long *dst, const unsigned long *src1,
> }
> }
>
> +static __always_inline
> +unsigned int bitmap_weighted_xor(unsigned long *dst, const unsigned long *src1,
> + const unsigned long *src2, unsigned int nbits)
> +{
> + if (small_const_nbits(nbits)) {
> + *dst = *src1 ^ *src2;
> + return hweight_long(*dst & BITMAP_LAST_WORD_MASK(nbits));
> + } else {
> + return __bitmap_weighted_xor(dst, src1, src2, nbits);
> + }
> +}
Should bitmap_weighted_xor() be added to the API documentation block near
the beginning of this header file? The documentation lists bitmap_weighted_or()
at line 48 and bitmap_xor() at line 49. For consistency with the existing
pattern, bitmap_weighted_xor() could be documented similarly to:
"bitmap_weighted_xor(dst, src1, src2, nbits) *dst = *src1 ^ *src2.
Returns Hamming Weight of dst".
[ ... ]
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-03-01 15:19 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-25 0:00 [PATCH RESEND 0/3] ice: use better bitmap API Yury Norov
2026-02-25 0:00 ` [PATCH RESEND 1/3] bitmap: introduce bitmap_weighted_xor() Yury Norov
2026-03-01 15:19 ` [RESEND,1/3] " Simon Horman
2026-02-25 0:00 ` [PATCH RESEND 2/3] ice: use bitmap_weighted_xor() in ice_find_free_recp_res_idx() Yury Norov
2026-02-25 0:00 ` [PATCH RESEND 3/3] ice: use bitmap_empty() in ice_vf_has_no_qs_ena Yury Norov
2026-02-25 12:02 ` [PATCH RESEND 0/3] ice: use better bitmap API Przemek Kitszel
2026-02-25 15:41 ` Yury Norov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox