Netdev List
 help / color / mirror / Atom feed
From: Yevgeny Kliteynik <kliteyn@nvidia.com>
To: Simon Horman <horms@kernel.org>, tariqt@nvidia.com
Cc: cpaasch@openai.com, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, andrew+netdev@lunn.ch, davem@davemloft.net,
	saeedm@nvidia.com, leon@kernel.org, mbloch@nvidia.com,
	vdogaru@nvidia.com, kees@kernel.org, valex@nvidia.com,
	erezsh@nvidia.com, netdev@vger.kernel.org,
	linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
	gal@nvidia.com, dtatulea@nvidia.com
Subject: Re: [PATCH net-next 1/3] net/mlx5: HWS, Check if device is down while polling for completion
Date: Mon, 11 May 2026 11:48:57 +0300	[thread overview]
Message-ID: <0a39da37-6e4d-434f-9416-f102d1d6a159@nvidia.com> (raw)
In-Reply-To: <20260510190351.1422486-1-horms@kernel.org>

On 10-May-26 22:03, Simon Horman wrote:
> From: 'Simon Horman' <horms@kernel.org>
> 
> This is an AI-generated review of your patch. The human sending this
> email has considered the AI review valid, or at least plausible.
> Full review at: https://sashiko.dev
> ---
> net/mlx5: HWS, Check if device is down while polling for completion
> 
> This commit adds a check to abort polling for hardware completions if the
> device state indicates an internal error. This returns -ETIMEDOUT early to
> avoid long timeouts when the hardware stops generating completions.
> 
>> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/bwc.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/bwc.c
>> index 6dcd9c2a78aa8..eae02bc742218 100644
>> --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/bwc.c
>> +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/bwc.c
>> @@ -422,6 +422,18 @@ int mlx5hws_bwc_queue_poll(struct mlx5hws_context *ctx,
>>   	if (!got_comp && !drain)
>>   		return 0;
>>   
>> +	if (unlikely(ctx->mdev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR)) {
>> +		/* If the device is down for any reason (e.g. FLR), the HW will
>> +		 * no longer generate completions.
>> +		 * Note that ETIMEDOUT is returned here because the BWC layer
>> +		 * already has a special handling for timeouts - it breaks the
>> +		 * rehash / resize / shrink loops to avoid chain of timeouts.
>> +		 */
>> +		mlx5_core_warn_once(ctx->mdev,
>> +				    "BWC poll: device is down, polling for completion aborted\n");
>> +		return -ETIMEDOUT;
>> +	}
>> +
>>   	queue_full = mlx5hws_send_engine_full(&ctx->send_queue[queue_id]);
>>   	while (queue_full || ((got_comp || drain) && *pending_rules)) {
> 
> Could this lead to a CPU stall if the device goes down during the polling loop?

That is correct.
There is the possibility that the device goes down while we're already inside
the polling loop, in which case the looping will continue till it reaches the
timeout.
But what we're trying to optimize is the "normal" flow. We prefer not to
add additional 'if' into the polling loop, which should be as efficient
as possible - it affects rules insertion/deletion rate.
So this patch aims to prevent chain of timeouts when device is in error
state, which is happening during deletion of all the flows, and during
shrinking of the matchers, while it still leaves some probability to see
a single initial timeout.


> The hardware state check is placed outside the while loop. The loop has a
> 60-second timeout (MLX5HWS_BWC_POLLING_TIMEOUT) and lacks cond_resched(),
> meaning it can peg the CPU while spinning.
> 
> If the hardware fails and stops generating completions while we are already
> inside the loop, the driver's health thread on another CPU might detect the
> failure and set ctx->mdev->state to MLX5_DEVICE_STATE_INTERNAL_ERROR.
> 
> Since the check is outside the loop, we would fail to detect the state change
> and continue to spin uselessly for the remainder of the 60 seconds, which
> could trigger a soft lockup panic.
> 
> Should the state check be moved inside the polling loop, perhaps using
> READ_ONCE() on ctx->mdev->state to ensure the compiler does not hoist the
> lockless read?
> 
>>   		ret = mlx5hws_send_queue_poll(ctx, queue_id, comp, burst_th);


  reply	other threads:[~2026-05-11  8:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-07 17:34 [PATCH net-next 0/3] net/mlx5: Steering misc enhancements Tariq Toukan
2026-05-07 17:34 ` [PATCH net-next 1/3] net/mlx5: HWS, Check if device is down while polling for completion Tariq Toukan
2026-05-10 19:03   ` Simon Horman
2026-05-11  8:48     ` Yevgeny Kliteynik [this message]
2026-05-07 17:34 ` [PATCH net-next 2/3] net/mlx5: HWS, Handle destroying table that has a miss table Tariq Toukan
2026-05-10 19:04   ` Simon Horman
2026-05-07 17:34 ` [PATCH net-next 3/3] net/mlx5: DR, Remove unused field of struct mlx5dr_matcher_rx_tx Tariq Toukan
2026-05-10 19:04   ` Simon Horman
2026-05-10 18:52 ` [PATCH net-next 0/3] net/mlx5: Steering misc enhancements patchwork-bot+netdevbpf

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=0a39da37-6e4d-434f-9416-f102d1d6a159@nvidia.com \
    --to=kliteyn@nvidia.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=cpaasch@openai.com \
    --cc=davem@davemloft.net \
    --cc=dtatulea@nvidia.com \
    --cc=edumazet@google.com \
    --cc=erezsh@nvidia.com \
    --cc=gal@nvidia.com \
    --cc=horms@kernel.org \
    --cc=kees@kernel.org \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=mbloch@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=saeedm@nvidia.com \
    --cc=tariqt@nvidia.com \
    --cc=valex@nvidia.com \
    --cc=vdogaru@nvidia.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