Intel-Wired-Lan Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Jacob Keller' <jacob.e.keller@intel.com>,
	Simon Horman <horms@kernel.org>,
	Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Cc: "wojciech.drewek@intel.com" <wojciech.drewek@intel.com>,
	"marcin.szycik@intel.com" <marcin.szycik@intel.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"konrad.knitter@intel.com" <konrad.knitter@intel.com>,
	"pawel.chmielewski@intel.com" <pawel.chmielewski@intel.com>,
	"intel-wired-lan@lists.osuosl.org"
	<intel-wired-lan@lists.osuosl.org>,
	"nex.sw.ncis.nat.hpm.dev@intel.com"
	<nex.sw.ncis.nat.hpm.dev@intel.com>,
	"pio.raczynski@gmail.com" <pio.raczynski@gmail.com>,
	"sridhar.samudrala@intel.com" <sridhar.samudrala@intel.com>,
	"jiri@resnulli.us" <jiri@resnulli.us>,
	"przemyslaw.kitszel@intel.com" <przemyslaw.kitszel@intel.com>
Subject: Re: [Intel-wired-lan] [iwl-next v4 3/8] ice: get rid of num_lan_msix field
Date: Mon, 14 Oct 2024 19:04:34 +0000	[thread overview]
Message-ID: <3e015d17e53f4cdd813c88c93b966810@AcuMS.aculab.com> (raw)
In-Reply-To: <636e511e-055d-4b7d-8fdb-13e546ff5b90@intel.com>

From: Jacob Keller
> Sent: 14 October 2024 19:51
> 
> On 10/12/2024 8:13 AM, Simon Horman wrote:
> > + David Laight
> >
> > On Mon, Sep 30, 2024 at 02:03:57PM +0200, Michal Swiatkowski wrote:
> >> Remove the field to allow having more queues than MSI-X on VSI. As
> >> default the number will be the same, but if there won't be more MSI-X
> >> available VSI can run with at least one MSI-X.
> >>
> >> Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com>
> >> Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
> >> ---
> >>  drivers/net/ethernet/intel/ice/ice.h         |  1 -
> >>  drivers/net/ethernet/intel/ice/ice_base.c    | 10 +++-----
> >>  drivers/net/ethernet/intel/ice/ice_ethtool.c |  8 +++---
> >>  drivers/net/ethernet/intel/ice/ice_irq.c     | 11 +++------
> >>  drivers/net/ethernet/intel/ice/ice_lib.c     | 26 +++++++++++---------
> >>  5 files changed, 27 insertions(+), 29 deletions(-)
> >>
> >> diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h
> >> index cf824d041d5a..1e23aec2634f 100644
> >> --- a/drivers/net/ethernet/intel/ice/ice.h
> >> +++ b/drivers/net/ethernet/intel/ice/ice.h
> >> @@ -622,7 +622,6 @@ struct ice_pf {
> >>  	u16 max_pf_txqs;	/* Total Tx queues PF wide */
> >>  	u16 max_pf_rxqs;	/* Total Rx queues PF wide */
> >>  	struct ice_pf_msix msix;
> >> -	u16 num_lan_msix;	/* Total MSIX vectors for base driver */
> >>  	u16 num_lan_tx;		/* num LAN Tx queues setup */
> >>  	u16 num_lan_rx;		/* num LAN Rx queues setup */
> >>  	u16 next_vsi;		/* Next free slot in pf->vsi[] - 0-based! */
> >
> > ...
> >
> >> diff --git a/drivers/net/ethernet/intel/ice/ice_ethtool.c
> b/drivers/net/ethernet/intel/ice/ice_ethtool.c
> >> index 85a3b2326e7b..e5c56ec8bbda 100644
> >> --- a/drivers/net/ethernet/intel/ice/ice_ethtool.c
> >> +++ b/drivers/net/ethernet/intel/ice/ice_ethtool.c
> >> @@ -3811,8 +3811,8 @@ ice_get_ts_info(struct net_device *dev, struct kernel_ethtool_ts_info *info)
> >>   */
> >>  static int ice_get_max_txq(struct ice_pf *pf)
> >>  {
> >> -	return min3(pf->num_lan_msix, (u16)num_online_cpus(),
> >> -		    (u16)pf->hw.func_caps.common_cap.num_txq);
> >> +	return min_t(u16, num_online_cpus(),
> >> +		     pf->hw.func_caps.common_cap.num_txq);
> >
> > It is unclear why min_t() is used here or elsewhere in this patch
> > instead of min() as it seems that all the entities being compared
> > are unsigned. Are you concerned about overflowing u16? If so, perhaps
> > clamp, or some error handling, is a better approach.
> >
> > I am concerned that the casting that min_t() brings will hide
> > any problems that may exist.
> >
> Ya, I think min makes more sense. min_t was likely selected out of habit
> or looking at other examples in the driver.

My 'spot patches that use min_t()' failed to spot that one.

But it is just plain wrong - and always was.
You want a result that is 16bits, casting the inputs is wrong.
Consider a system with 64k cpus!

Pretty much all the min_t() that specify u8 or u16 are likely to
be actually broken.
Most of the rest specify u32 or u64 in order to compare (usually)
unsigned values of different sizes.
But I found some that might be using 'long' on 64bit values
on 32bit (and as disk sector numbers!).

In the current min() bleats, the code is almost certainly awry.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

  reply	other threads:[~2024-10-14 19:11 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-30 12:03 [Intel-wired-lan] [iwl-next v4 0/8] ice: managing MSI-X in driver Michal Swiatkowski
2024-09-30 12:03 ` [Intel-wired-lan] [iwl-next v4 1/8] ice: devlink PF MSI-X max and min parameter Michal Swiatkowski
2024-09-30 12:03 ` [Intel-wired-lan] [iwl-next v4 2/8] ice: remove splitting MSI-X between features Michal Swiatkowski
2024-09-30 12:03 ` [Intel-wired-lan] [iwl-next v4 3/8] ice: get rid of num_lan_msix field Michal Swiatkowski
2024-10-12 15:13   ` Simon Horman
2024-10-14 18:50     ` Jacob Keller
2024-10-14 19:04       ` David Laight [this message]
2024-10-14 22:23         ` Jacob Keller
2024-10-23  7:17           ` Michal Swiatkowski
2024-09-30 12:03 ` [Intel-wired-lan] [iwl-next v4 4/8] ice, irdma: move interrupts code to irdma Michal Swiatkowski
2024-09-30 12:03 ` [Intel-wired-lan] [iwl-next v4 5/8] ice: treat dyn_allowed only as suggestion Michal Swiatkowski
2024-09-30 12:04 ` [Intel-wired-lan] [iwl-next v4 6/8] ice: enable_rdma devlink param Michal Swiatkowski
2024-09-30 12:04 ` [Intel-wired-lan] [iwl-next v4 7/8] ice: simplify VF MSI-X managing Michal Swiatkowski
2024-09-30 12:04 ` [Intel-wired-lan] [iwl-next v4 8/8] ice: init flow director before RDMA Michal Swiatkowski

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=3e015d17e53f4cdd813c88c93b966810@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=horms@kernel.org \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=jacob.e.keller@intel.com \
    --cc=jiri@resnulli.us \
    --cc=konrad.knitter@intel.com \
    --cc=marcin.szycik@intel.com \
    --cc=michal.swiatkowski@linux.intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=nex.sw.ncis.nat.hpm.dev@intel.com \
    --cc=pawel.chmielewski@intel.com \
    --cc=pio.raczynski@gmail.com \
    --cc=przemyslaw.kitszel@intel.com \
    --cc=sridhar.samudrala@intel.com \
    --cc=wojciech.drewek@intel.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