mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Cosmin Ratiu <cratiu@nvidia.com>
To: Tariq Toukan <tariqt@nvidia.com>, "kuba@kernel.org" <kuba@kernel.org>
Cc: "andrew+netdev@lunn.ch" <andrew+netdev@lunn.ch>,
	"linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
	"davem@davemloft.net" <davem@davemloft.net>,
	Gal Pressman <gal@nvidia.com>, Moshe Shemesh <moshe@nvidia.com>,
	Mark Bloch <mbloch@nvidia.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"pabeni@redhat.com" <pabeni@redhat.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"edumazet@google.com" <edumazet@google.com>,
	Saeed Mahameed <saeedm@nvidia.com>,
	"horms@kernel.org" <horms@kernel.org>,
	"leon@kernel.org" <leon@kernel.org>
Subject: Re: [PATCH net V2 2/4] net/mlx5: Fix deadlock between devlink lock and esw->wq
Date: Thu, 29 Jan 2026 10:33:40 +0000	[thread overview]
Message-ID: <d52714243592921c08175aa742f32ae56e4f6651.camel@nvidia.com> (raw)
In-Reply-To: <20260128205622.12e1f026@kernel.org>

On Wed, 2026-01-28 at 20:56 -0800, Jakub Kicinski wrote:
> On Tue, 27 Jan 2026 10:52:39 +0200 Tariq Toukan wrote:
> > esw_functions_changed_event_handler ->
> > esw_vfs_changed_event_handler is
> > called from the esw->work_queue and acquires the devlink lock.
> > 
> > Changing the esw mode is done via .eswitch_mode_set (acquires
> > devlink
> > lock in the devlink_nl_pre_doit call) ->
> > mlx5_devlink_eswitch_mode_set
> > -> mlx5_eswitch_disable_locked ->
> > mlx5_eswitch_event_handler_unregister
> > -> flush_workqueue.  
> 
> This is quite an ugly hack, is there no way to avoid the flush and
> let 
> the work discover that what it was supposed to do is no longer
> needed?

Not possible, unfortunately. I stared at it for quite a while. The wq
is flushed because the esw is being unconfigured, which removes data
structs the work handler uses. Flushing the work is required, otherwise
we'll run into worse issues.

> 
> >  	devlink = priv_to_devlink(esw->dev);
> > -	devl_lock(devlink);
> > +	/* Repeatedly try to grab the lock with a delay while this
> > work is
> > +	 * still relevant.
> > +	 * This allows a concurrent
> > mlx5_eswitch_event_handler_unregister
> > +	 * (holding the devlink lock) to flush the wq without
> > deadlocking.
> > +	 */
> > +	while (!devl_trylock(devlink)) {
> > +		if (!esw->esw_funcs.notifier_enabled)
> 
> Technically READ_ONCE/WRITE_ONCE is required on this.

Will fix.


> > +			return;
> > +		schedule_timeout_interruptible(msecs_to_jiffies(10
> > ));
> 
> Why _interruptible(), you're not handling the return value.
> If somehow this thread gets a signal pending we'll turn this
> loop into a busy poll which doesn't seem ideal?


Didn't pay attention to this possibility. Sorry, will fix.

Cosmin.

  reply	other threads:[~2026-01-29 10:33 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-27  8:52 [PATCH net V2 0/4] mlx5 misc fixes 2026-01-27 Tariq Toukan
2026-01-27  8:52 ` [PATCH net V2 1/4] net/mlx5: fs, Fix inverted cap check in tx flow table root disconnect Tariq Toukan
2026-01-27  8:52 ` [PATCH net V2 2/4] net/mlx5: Fix deadlock between devlink lock and esw->wq Tariq Toukan
2026-01-29  4:56   ` Jakub Kicinski
2026-01-29 10:33     ` Cosmin Ratiu [this message]
2026-01-29 23:40       ` Jakub Kicinski
2026-02-02 14:48         ` Cosmin Ratiu
2026-02-03  0:29           ` Jakub Kicinski
2026-01-27  8:52 ` [PATCH net V2 3/4] net/mlx5: Fix vhca_id access call trace use before alloc Tariq Toukan
2026-01-27  8:52 ` [PATCH net V2 4/4] net/mlx5e: Skip ESN replay window setup for IPsec crypto offload Tariq Toukan
2026-01-29  5:00 ` [PATCH net V2 0/4] mlx5 misc fixes 2026-01-27 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=d52714243592921c08175aa742f32ae56e4f6651.camel@nvidia.com \
    --to=cratiu@nvidia.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gal@nvidia.com \
    --cc=horms@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=moshe@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=saeedm@nvidia.com \
    --cc=tariqt@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

all inboxes | Powered by JetHome®