From: Yury Norov <ynorov@nvidia.com>
To: David Laight <david.laight.linux@gmail.com>
Cc: "Yury Norov (NVIDIA)" <yury.norov@gmail.com>,
Tony Nguyen <anthony.l.nguyen@intel.com>,
Przemek Kitszel <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>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Andrew Morton <akpm@linux-foundation.org>,
intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] ice: use bitmap_weighted_xor() in ice_find_free_recp_res_idx()
Date: Sun, 22 Feb 2026 12:59:14 -0500 [thread overview]
Message-ID: <aZtD8klexMFal8GI@yury> (raw)
In-Reply-To: <20251223190846.76ff4dc0@pumpkin>
On Tue, Dec 23, 2025 at 07:08:46PM +0000, David Laight wrote:
> On Tue, 23 Dec 2025 11:23:01 -0500
> "Yury Norov (NVIDIA)" <yury.norov@gmail.com> wrote:
>
> > Use the right helper and save one bitmaps traverse.
>
> It makes no difference here.
No it makes.
> The bitmap has 48 entries and is just a single 'long' on 64bit.
> It is also already in a very slow path that has iterated all the
> 'set' bit of two bitmaps.
>
> The code is also pretty convoluted and confusing already.
> One of the other bitmaps has 64 entries, recoding using u64 would
> make it a bit more readable.
>
> Doing the 'weight' here is also just optimising for failure.
We've introduced bitmap_weighted_or() recently, and now we need to add
siblings to the new sub-class. Regardless of performance impact in this
case, having a dedicated helper for a typical operations saves a lot in
debugging. This is proven by decades of code development.
> Oh, and using u8 and u16 for function parameters, return values and
> maths requires extra instructions and is usually a bad idea.
Changing function signatures is not the patch purpose. Feel free to
submit a separate patch.
> Dvaid
>
> >
> > Signed-off-by: Yury Norov (NVIDIA) <yury.norov@gmail.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 84848f0123e7..903417477929 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);
> > }
> >
> > /**
next prev parent reply other threads:[~2026-02-22 17:59 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-23 16:22 [PATCH 0/3] ice: use better bitmap API Yury Norov (NVIDIA)
2025-12-23 16:23 ` [PATCH 1/3] bitmap: introduce bitmap_weighted_xor() Yury Norov (NVIDIA)
2025-12-23 16:23 ` [PATCH 2/3] ice: use bitmap_weighted_xor() in ice_find_free_recp_res_idx() Yury Norov (NVIDIA)
2025-12-23 19:08 ` David Laight
2026-02-22 17:59 ` Yury Norov [this message]
2026-02-24 22:50 ` Tony Nguyen
2025-12-23 16:23 ` [PATCH 3/3] ice: use bitmap_empty() in ice_vf_has_no_qs_ena Yury Norov (NVIDIA)
2026-02-22 18:00 ` [PATCH 0/3] ice: use better bitmap API Yury Norov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aZtD8klexMFal8GI@yury \
--to=ynorov@nvidia.com \
--cc=akpm@linux-foundation.org \
--cc=andrew+netdev@lunn.ch \
--cc=anthony.l.nguyen@intel.com \
--cc=davem@davemloft.net \
--cc=david.laight.linux@gmail.com \
--cc=edumazet@google.com \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=yury.norov@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox