netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: Heng Qi <hengqi@linux.alibaba.com>
Cc: netdev@vger.kernel.org,
	virtualization@lists.linux-foundation.org,  mst@redhat.com,
	pabeni@redhat.com, kuba@kernel.org, yinjun.zhang@corigine.com,
	 edumazet@google.com, davem@davemloft.net, hawk@kernel.org,
	 john.fastabend@gmail.com, ast@kernel.org, horms@kernel.org,
	 xuanzhuo@linux.alibaba.com
Subject: Re: [PATCH net-next v6 4/5] virtio-net: add spin lock for ctrl cmd access
Date: Wed, 6 Dec 2023 17:11:02 +0800	[thread overview]
Message-ID: <CACGkMEsf=c_fodNUgX1idwRa9Jsd1_rsYgtZaYH3DuASJvfTog@mail.gmail.com> (raw)
In-Reply-To: <ad02f02a-b08f-4061-9aba-cadef02641c8@linux.alibaba.com>

On Tue, Dec 5, 2023 at 7:06 PM Heng Qi <hengqi@linux.alibaba.com> wrote:
>
>
>
> 在 2023/12/5 下午4:35, Jason Wang 写道:
> > On Tue, Dec 5, 2023 at 4:02 PM Heng Qi <hengqi@linux.alibaba.com> wrote:
> >> Currently access to ctrl cmd is globally protected via rtnl_lock and works
> >> fine. But if dim work's access to ctrl cmd also holds rtnl_lock, deadlock
> >> may occur due to cancel_work_sync for dim work.
> > Can you explain why?
>
> For example, during the bus unbind operation, the following call stack
> occurs:
> virtnet_remove -> unregister_netdev -> rtnl_lock[1] -> virtnet_close ->
> cancel_work_sync -> virtnet_rx_dim_work -> rtnl_lock[2] (deadlock occurs).

Can we use rtnl_trylock() and reschedule the work?

>
> >> Therefore, treating
> >> ctrl cmd as a separate protection object of the lock is the solution and
> >> the basis for the next patch.
> > Let's don't do that. Reasons are:
> >
> > 1) virtnet_send_command() may wait for cvq commands for an indefinite time
>
> Yes, I took that into consideration. But ndo_set_rx_mode's need for an
> atomic
> environment rules out the mutex lock.

It is a "bug" that we need to fix.

>
> > 2) hold locks may complicate the future hardening works around cvq
>
> Agree, but I don't seem to have thought of a better way besides passing
> the lock.
> Do you have any other better ideas or suggestions?

So far no, you can refer to the past discussions, it might require the
collaboration from the uAPI and stack.

Thanks

>
> Thanks!
>
> >
> > Thanks
>


  reply	other threads:[~2023-12-06  9:11 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-05  8:02 [PATCH net-next v6 0/5] virtio-net: support dynamic coalescing moderation Heng Qi
2023-12-05  8:02 ` [PATCH net-next v6 1/5] virtio-net: returns whether napi is complete Heng Qi
2023-12-05  8:02 ` [PATCH net-next v6 2/5] virtio-net: separate rx/tx coalescing moderation cmds Heng Qi
2023-12-05  8:02 ` [PATCH net-next v6 3/5] virtio-net: extract virtqueue coalescig cmd for reuse Heng Qi
2023-12-05  8:02 ` [PATCH net-next v6 4/5] virtio-net: add spin lock for ctrl cmd access Heng Qi
2023-12-05  8:35   ` Jason Wang
2023-12-05 11:05     ` Heng Qi
2023-12-06  9:11       ` Jason Wang [this message]
2023-12-06 12:27       ` Paolo Abeni
2023-12-06 13:03         ` Heng Qi
2023-12-07  4:19           ` Jason Wang
2023-12-07  4:47             ` Heng Qi
2023-12-07  5:31               ` Jason Wang
2023-12-05  8:02 ` [PATCH net-next v6 5/5] virtio-net: support rx netdim Heng Qi

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='CACGkMEsf=c_fodNUgX1idwRa9Jsd1_rsYgtZaYH3DuASJvfTog@mail.gmail.com' \
    --to=jasowang@redhat.com \
    --cc=ast@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hawk@kernel.org \
    --cc=hengqi@linux.alibaba.com \
    --cc=horms@kernel.org \
    --cc=john.fastabend@gmail.com \
    --cc=kuba@kernel.org \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=xuanzhuo@linux.alibaba.com \
    --cc=yinjun.zhang@corigine.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;
as well as URLs for NNTP newsgroup(s).