From: Jacob Keller <jacob.e.keller@intel.com>
To: <intel-wired-lan@osuosl.org>
Subject: Re: [Intel-wired-lan] [PATCH net v3 2/4] iavf: Don't lock rtnl_lock twice in reset
Date: Wed, 19 Apr 2023 11:40:35 -0700 [thread overview]
Message-ID: <02fc024e-40ad-d5e7-2824-3cdd742ad9bf@intel.com> (raw)
In-Reply-To: <20230419115006.200409-3-kamil.maziarz@intel.com>
On 4/19/2023 4:50 AM, Kamil Maziarz wrote:
> From: Marcin Szycik <marcin.szycik@linux.intel.com>
>
> Some ndo/ethtool callbacks are called under rtnl_lock. If such callback
> then triggers a reset, the reset task might try to take the rtnl_lock
> again, causing a deadlock.
>
> Callbacks that are sensitive to rtnl_lock are scheduled when the drivers
> are unable to obtain the rtnl_lock in the reset flow. This ensures that
> the reset task does not attempt to double lock rtnl_lock and avoids
> the deadlock.
>
> Before this patch, a deadlock could be caused by e.g.:
>
> echo 1 > /sys/class/net/$PF1/device/sriov_numvfs
> while :; do
> ip l s $VF1 up
> ethtool --set-channels $VF1 combined 8
> ip l s $VF1 down
> ip l s $VF1 up
> ethtool --set-channels $VF1 combined 16
> ip l s $VF1 down
> done
>
> Fixes: aa626da947e9 ("iavf: Detach device during reset task")
> Signed-off-by: Marcin Szycik <marcin.szycik@linux.intel.com>
> Co-developed-by: Dawid Wesierski <dawidx.wesierski@intel.com>
> Signed-off-by: Dawid Wesierski <dawidx.wesierski@intel.com>
> Signed-off-by: Kamil Maziarz <kamil.maziarz@intel.com>
> ---
> v2: no changes
> ---
> v3: Instead of the flag, we are using the rtnl_trylock in the rtnl_lock sensitive functions in the iavf_reset to avoid deadlock.
> Adding the scheduling functionality so we can update the netdev later in that case.
> out:
> - netif_set_real_num_rx_queues(adapter->netdev, pairs);
> - netif_set_real_num_tx_queues(adapter->netdev, pairs);
> + if (rtnl_trylock()) {
> + netif_set_real_num_rx_queues(adapter->netdev, pairs);
> + netif_set_real_num_tx_queues(adapter->netdev, pairs);
> + rtnl_unlock();
> + } else {
> + queue_work(adapter->wq, &adapter->set_interrupt_capability);
> + }
> +
I guess there's some merit to doing it inline when possible, but I'd
argue for simplicity of just always scheduling the work item. The
trylock is at least safe. I'm ok with either approach.
> return err;
> }
>
> +/**
> + * iavf_delayed_set_interrupt_capability - schedule the update of the netdev
> + * @work: pointer to work_struct containing our data
> + **/
> +static void iavf_delayed_set_interrupt_capability(struct work_struct *work)
> +{
> + struct iavf_adapter *adapter = container_of(work, struct iavf_adapter,
> + set_interrupt_capability);
> + int pairs = adapter->num_active_queues;
> +
> + if(rtnl_trylock()) {
> + netif_set_real_num_rx_queues(adapter->netdev, pairs);
> + netif_set_real_num_tx_queues(adapter->netdev, pairs);
> + rtnl_unlock();
> + } else {
> + queue_work(adapter->wq, &adapter->set_interrupt_capability);
> + }
> +}
The delayed function is now in a thread where its safe to take RTNL
lock, (since no one is waiting on a different lock/lock bit/etc) so this
should just be "rtnl_lock() / *set_real_num* / rtnl_unlock(). I don't
see the benefit of re-queueing here. The update won't take long so I
don't think we're going to be starving the adapter work queue by locking
on it..
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
next prev parent reply other threads:[~2023-04-19 18:43 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-19 11:50 [Intel-wired-lan] [PATCH net v3 0/4] iavf: fix reset task deadlock Kamil Maziarz
2023-04-19 11:50 ` [Intel-wired-lan] [PATCH net v3 1/4] iavf: Wait for reset in callbacks which trigger it Kamil Maziarz
2023-04-19 18:36 ` Jacob Keller
2023-04-19 22:47 ` Tony Nguyen
2023-04-19 11:50 ` [Intel-wired-lan] [PATCH net v3 2/4] iavf: Don't lock rtnl_lock twice in reset Kamil Maziarz
2023-04-19 18:40 ` Jacob Keller [this message]
2023-04-19 22:48 ` Tony Nguyen
2023-04-19 11:50 ` [Intel-wired-lan] [PATCH net v3 3/4] Revert "iavf: Detach device during reset task" Kamil Maziarz
2023-04-19 18:41 ` Jacob Keller
2023-04-19 11:50 ` [Intel-wired-lan] [PATCH net v3 4/4] Revert "iavf: Do not restart Tx queues after reset task failure" Kamil Maziarz
2023-04-19 18:42 ` Jacob Keller
2023-05-18 21:28 ` Jacob Keller
2023-04-19 18:35 ` [Intel-wired-lan] [PATCH net v3 0/4] iavf: fix reset task deadlock Jacob Keller
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=02fc024e-40ad-d5e7-2824-3cdd742ad9bf@intel.com \
--to=jacob.e.keller@intel.com \
--cc=intel-wired-lan@osuosl.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