From: Simon Horman <horms@kernel.org>
To: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Cc: intel-wired-lan@lists.osuosl.org, anthony.l.nguyen@intel.com,
netdev@vger.kernel.org
Subject: Re: [PATCH iwl-net v2 5/6] ixgbe: fix ITR value overflow in adaptive interrupt throttling
Date: Mon, 13 Apr 2026 14:39:38 +0100 [thread overview]
Message-ID: <20260413133938.GO469338@kernel.org> (raw)
In-Reply-To: <20260408131154.2661818-6-aleksandr.loktionov@intel.com>
On Wed, Apr 08, 2026 at 03:11:53PM +0200, Aleksandr Loktionov wrote:
> ixgbe_update_itr() packs a mode flag (IXGBE_ITR_ADAPTIVE_LATENCY,
> bit 7) and a usecs delay (bits [6:0]) into an unsigned int, then
> stores the combined value in ring_container->itr which is declared as
> u8. Values above 0xFF wrap on truncation, corrupting both the delay
> and the mode flag on the next readback.
>
> Separate the mode bits from the usecs sub-field; clamp only the usecs
> portion to [0, IXGBE_ITR_ADAPTIVE_LATENCY - 1] (= 0x7F) using min_t()
> so overflow cannot bleed into bit 7.
>
> Fixes: b4ded8327fea ("ixgbe: Update adaptive ITR algorithm")
> Cc: stable@vger.kernel.org
> Signed-off-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
> ---
> v1 -> v2:
> - Add proper [N/M] numbering so patchwork tracks it as part of the set;
> no code change.
>
> drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
> index 210c7b9..9f3ae21 100644
> --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
> +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
> @@ -2889,8 +2889,9 @@ static void ixgbe_update_itr(struct ixgbe_q_vector *q_vector,
> }
>
> clear_counts:
> - /* write back value */
> - ring_container->itr = itr;
> + ring_container->itr = (itr & IXGBE_ITR_ADAPTIVE_LATENCY) |
> + min_t(unsigned int, itr & ~IXGBE_ITR_ADAPTIVE_LATENCY,
> + IXGBE_ITR_ADAPTIVE_LATENCY - 1);
* It is not clear to me that the mode flag bit (IXGBE_ITR_ADAPTIVE_LATENCY)
is always set in itr when reaching this code. But with this patch that
bit will always be set in ring_container->itr.
* Perhaps no such case exists, but it's not clear to me how this handles a
case where the usec delay has overflowed into the mode flag bit.
As a hypothetical example, consider the case where the delay overflows to
exactly 0x80. The resulting delay is 0 (both with and without this
patch).
I would suggest an approach of keeping the delay and mode bits separate
during calculation - in separate local variables - and only combining
them when ring_container->itr is set.
This may turn out to be more verbose. But I expect it is easier to reason
with.
* Looking over the code, it looks like the maximum allowed udelay is
IXGBE_ITR_ADAPTIVE_MAX_USECS (126) rather than
IXGBE_ITR_ADAPTIVE_LATENCY - 1 (127).
* The calculation does not guard against delay values less
than IXGBE_ITR_ADAPTIVE_MIN_USECS. Which looking over the code seems
to be something that matters. (And which occurred in the hypothetical
example above).
* As itr is an unsigned int, and IXGBE_ITR_ADAPTIVE_LATENCY - 1 is a
compile time constant, I expect that min() is sufficient.
IOW, I don't think min_t is needed here.
* It looks like using FIELD_PREP is appropriate to construct
ring_container->itr. But that may be overkill if you end up with
something like:
ring_container->itr = mode | clamp(delay, IXGBE_ITR_ADAPTIVE_MAX_USECS,
IXGBE_ITR_ADAPTIVE_MIN_USECS);
>
> /* next update should occur within next jiffy */
> ring_container->next_update = next_update + 1;
> --
> 2.52.0
next prev parent reply other threads:[~2026-04-13 13:39 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-08 13:11 [PATCH iwl-net v2 0/6] ixgbe: six bug fixes Aleksandr Loktionov
2026-04-08 13:11 ` [PATCH iwl-net v2 1/6] ixgbe: fix SWFW semaphore timeout for X550 family Aleksandr Loktionov
2026-04-13 10:52 ` Simon Horman
2026-04-14 0:56 ` [Intel-wired-lan] " Jacob Keller
2026-04-08 13:11 ` [PATCH iwl-net v2 2/6] ixgbe: add bounds check for debugfs register access Aleksandr Loktionov
2026-04-13 10:30 ` Simon Horman
2026-04-14 1:00 ` [Intel-wired-lan] " Jacob Keller
2026-04-14 17:16 ` Simon Horman
2026-04-08 13:11 ` [PATCH iwl-net v2 3/6] ixgbe: call ixgbe_setup_fc() before fc_enable() after NVM update Aleksandr Loktionov
2026-04-13 10:51 ` Simon Horman
2026-04-08 13:11 ` [PATCH iwl-net v2 4/6] ixgbe: fix cls_u32 nexthdr path returning success when no entry installed Aleksandr Loktionov
2026-04-13 10:54 ` Simon Horman
2026-04-08 13:11 ` [PATCH iwl-net v2 5/6] ixgbe: fix ITR value overflow in adaptive interrupt throttling Aleksandr Loktionov
2026-04-13 13:39 ` Simon Horman [this message]
2026-04-08 13:11 ` [PATCH iwl-net v2 6/6] ixgbe: fix integer overflow and wrong bit position in ixgbe_validate_rtr() Aleksandr Loktionov
2026-04-13 13:43 ` Simon Horman
2026-04-13 14:02 ` Simon Horman
2026-04-13 14:03 ` Simon Horman
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=20260413133938.GO469338@kernel.org \
--to=horms@kernel.org \
--cc=aleksandr.loktionov@intel.com \
--cc=anthony.l.nguyen@intel.com \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=netdev@vger.kernel.org \
/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