DPDK patches and discussions
 help / color / mirror / Atom feed
From: Maxime Coquelin <mcoqueli@redhat.com>
To: Serhii Iliushyk <sil-plv@napatech.com>
Cc: dev@dpdk.org, mko-plv@napatech.com, ckm@napatech.com,
	 maxime.coquelin@redhat.com, Chenbo Xia <chenbox@nvidia.com>
Subject: Re: [PATCH v2] vhost: always lock all QPs if handlers request it
Date: Tue, 14 Oct 2025 15:00:28 +0200	[thread overview]
Message-ID: <CAO55csx-CUrS=eFtHhA+Y9nJygPmV-8segingRU5MDBc5taGDw@mail.gmail.com> (raw)
In-Reply-To: <CAO55cszP6B5aUnRtydZ170WOGCRs1iFe-zgSX2PyJSU4i2HKxA@mail.gmail.com>

On Tue, Oct 14, 2025 at 2:54 PM Maxime Coquelin <mcoqueli@redhat.com> wrote:
>
> Hi Serghii,
>
> On Tue, Oct 7, 2025 at 5:06 PM Serhii Iliushyk <sil-plv@napatech.com> wrote:
> >
> > The check for the VIRTIO_DEV_VDPA_CONFIGURED flag is not needed
> > since each handler has its own lock_all_qps flag
> > to indicate whether it needs all queue pairs.
>
> Hmm, I think this is needed because lock_all_qps is only effective
> with the SW datapath.
> With vDPA, once the device is configured, we would end-up with
> virtqueues modifications
> without the HW being stopped or even notified.
>
> > Checking the VIRTIO_DEV_VDPA_CONFIGURED flag caused certain handlers
> > (for example, SET_MEM_TABLE for memory hot plug) to run without holding
> > the per-vq access_lock and trigger vq_assert_lock failures.
>
> In this specific memory hotplug case, we do the right thing in the handler:
>
>     if (dev->mem) {
>         if (dev->flags & VIRTIO_DEV_VDPA_CONFIGURED) {
>             struct rte_vdpa_device *vdpa_dev = dev->vdpa_dev;
>
>             if (vdpa_dev && vdpa_dev->ops->dev_close)
>                 vdpa_dev->ops->dev_close(dev->vid);
>             dev->flags &= ~VIRTIO_DEV_VDPA_CONFIGURED;
>         }
>
> Maybe we should also lock all the queue pairs once the vDPA is closed.
> The problem is to handle the unlock properly.

Maybe a generic solution would be in vhost_user_msg_handler() to close
the vDPA device,
clear CONFIGURED flag and lock all queue pairs as we do in
vhost_user_set_mem_table?

I have no hardware to test, could you have a try if you think it makes sense?

Thanks,
Maxime
> Maxime
>
> > Signed-off-by: Serhii Iliushyk <sil-plv@napatech.com>
> > ---
> > v2
> > * fix typo in commit message
> > ---
> >  lib/vhost/vhost_user.c | 6 ++----
> >  1 file changed, 2 insertions(+), 4 deletions(-)
> >
> > diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c
> > index 4bfb13fb98..9288da9322 100644
> > --- a/lib/vhost/vhost_user.c
> > +++ b/lib/vhost/vhost_user.c
> > @@ -3171,10 +3171,8 @@ vhost_user_msg_handler(int vid, int fd)
> >          * would cause a dead lock.
> >          */
> >         if (msg_handler != NULL && msg_handler->lock_all_qps) {
> > -               if (!(dev->flags & VIRTIO_DEV_VDPA_CONFIGURED)) {
> > -                       vhost_user_lock_all_queue_pairs(dev);
> > -                       unlock_required = 1;
> > -               }
> > +               vhost_user_lock_all_queue_pairs(dev);
> > +               unlock_required = 1;
> >         }
> >
> >         handled = false;
> > --
> > 2.47.3
> >


      reply	other threads:[~2025-10-14 13:00 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-29 12:32 [PATCH v1 0/1] Memory hotplug fix Danylo Vodopianov
2025-05-29 12:32 ` [PATCH v1 1/1] vhost: handle virtqueue locking for memory hotplug Danylo Vodopianov
2025-06-02  8:19   ` [PATCH v2 " Danylo Vodopianov
2025-06-02  8:40     ` [PATCH v3 0/1] Memory hotplug fix Danylo Vodopianov
2025-06-02  8:40       ` [PATCH v3 1/1] vhost: handle virtqueue locking for memory hotplug Danylo Vodopianov
2025-06-02  8:50         ` [PATCH v4 0/1] Memory hotplug fix Danylo Vodopianov
2025-06-02  8:50           ` [PATCH v4 1/1] vhost: handle virtqueue locking for memory hotplug Danylo Vodopianov
2025-06-03 12:30             ` Maxime Coquelin
2025-06-04  8:32               ` Danylo Vodopianov
2025-06-12 11:38                 ` Maxime Coquelin
2025-06-19 13:01                   ` Danylo Vodopianov
2025-06-30  8:50                     ` Maxime Coquelin
2025-10-07 14:56                       ` [PATCH v1] vhost: always lock all qp if handlers request it Serhii Iliushyk
2025-10-07 15:06                         ` [PATCH v2] vhost: always lock all QPs " Serhii Iliushyk
2025-10-14 12:54                           ` Maxime Coquelin
2025-10-14 13:00                             ` Maxime Coquelin [this message]

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='CAO55csx-CUrS=eFtHhA+Y9nJygPmV-8segingRU5MDBc5taGDw@mail.gmail.com' \
    --to=mcoqueli@redhat.com \
    --cc=chenbox@nvidia.com \
    --cc=ckm@napatech.com \
    --cc=dev@dpdk.org \
    --cc=maxime.coquelin@redhat.com \
    --cc=mko-plv@napatech.com \
    --cc=sil-plv@napatech.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).