From: "Michael S. Tsirkin" <mst@redhat.com>
To: Eugenio Perez Martin <eperezma@redhat.com>
Cc: Yongji Xie <xieyongji@bytedance.com>,
Stefano Garzarella <sgarzare@redhat.com>,
Xuan Zhuo <xuanzhuo@linux.alibaba.com>,
virtualization@lists.linux.dev, linux-kernel@vger.kernel.org,
jasowang@redhat.com, Maxime Coquelin <mcoqueli@redhat.com>,
Laurent Vivier <lvivier@redhat.com>, Cindy Lu <lulu@redhat.com>
Subject: Re: [PATCH v7 1/7] vduse: make domain_lock an rwlock
Date: Mon, 27 Oct 2025 12:57:11 -0400 [thread overview]
Message-ID: <20251027125520-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <CAJaqyWeeJVM6VeYp4HUEe0ZZAi26Jgqw8WaEg6POoGcUOkk6Qw@mail.gmail.com>
On Thu, Oct 23, 2025 at 10:59:01AM +0200, Eugenio Perez Martin wrote:
> On Fri, Oct 10, 2025 at 2:34 PM Michael S. Tsirkin <mst@redhat.com> wrote:
> >
>
> ...
>
> >
> >
> > > @@ -2045,11 +2046,11 @@ static int vdpa_dev_add(struct vdpa_mgmt_dev *mdev, const char *name,
> > > if (ret)
> > > return ret;
> > >
> > > - mutex_lock(&dev->domain_lock);
> > > + write_lock(&dev->domain_lock);
> > > if (!dev->domain)
> > > dev->domain = vduse_domain_create(VDUSE_IOVA_SIZE - 1,
> > > dev->bounce_size);
> > > - mutex_unlock(&dev->domain_lock);
> > > + write_unlock(&dev->domain_lock);
> > > if (!dev->domain) {
> > > put_device(&dev->vdev->vdpa.dev);
> > > return -ENOMEM;
> >
> >
> > Let's look at this example:
> >
> > So now you are invoking this under an rw lock:
> >
> >
> >
> >
> > struct vduse_iova_domain *
> > vduse_domain_create(unsigned long iova_limit, size_t bounce_size)
> > {
> > struct vduse_iova_domain *domain;
> > struct file *file;
> > struct vduse_bounce_map *map;
> > unsigned long pfn, bounce_pfns;
> > int ret;
> >
> > bounce_pfns = PAGE_ALIGN(bounce_size) >> BOUNCE_MAP_SHIFT;
> > if (iova_limit <= bounce_size)
> > return NULL;
> >
> > domain = kzalloc(sizeof(*domain), GFP_KERNEL);
> > if (!domain)
> > return NULL;
> >
> >
> > ...
> >
> >
> >
> > Which unless I am mistaken will produce a lockdep splat and deadlock.
> >
>
> Can you expand on this? All that code works with and without lockdep.
GFP_KERNEL can sleep and if that happens and another thread runs and
will try to take the lock, it will spin forever.
> >
> > So it looks like the previous version did not compile
> > and this one looks DOA. What's up?
> >
>
> In case it is useful, I forgot to enable some vendor vdpa drivers of
> HW I don't have, and that was the reason why it didn't compile. But I
> didn't send it without testing it of course.
>
> > At this stage please include information about configs you
> > tested, and how.
> >
> > And any locking changes should also be tested with lockdep enabled
> > please.
> >
>
> This is the text I'm planning to include in the next series, please
> let me know if you want me to expand:
>
> Tested by creating a VDUSE device OVS with and without MQ, and live
> migrating between two hosts back and forth while maintaining ping
> alive in all the stages. All tested with and without lockdep.
next prev parent reply other threads:[~2025-10-27 16:57 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-10 8:58 [PATCH v7 0/7] Add multiple address spaces support to VDUSE Eugenio Pérez
2025-10-10 8:58 ` [PATCH v7 1/7] vduse: make domain_lock an rwlock Eugenio Pérez
2025-10-10 12:34 ` Michael S. Tsirkin
2025-10-17 6:32 ` Eugenio Perez Martin
2025-10-23 8:59 ` Eugenio Perez Martin
2025-10-27 16:57 ` Michael S. Tsirkin [this message]
2025-10-10 8:58 ` [PATCH v7 2/7] vduse: add v1 API definition Eugenio Pérez
2025-10-11 5:21 ` Jason Wang
2025-10-10 8:58 ` [PATCH v7 3/7] vduse: add vq group support Eugenio Pérez
2025-10-11 5:22 ` Jason Wang
2025-10-10 8:58 ` [PATCH v7 4/7] vduse: return internal vq group struct as map token Eugenio Pérez
2025-10-11 5:22 ` Jason Wang
2025-10-10 8:58 ` [PATCH v7 5/7] vduse: refactor vdpa_dev_add for goto err handling Eugenio Pérez
2025-10-11 5:23 ` Jason Wang
2025-10-10 8:58 ` [PATCH v7 6/7] vduse: add vq group asid support Eugenio Pérez
2025-10-11 5:23 ` Jason Wang
2025-10-10 8:58 ` [PATCH v7 7/7] vduse: bump version number Eugenio Pérez
2025-10-11 5:23 ` Jason Wang
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=20251027125520-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=eperezma@redhat.com \
--cc=jasowang@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lulu@redhat.com \
--cc=lvivier@redhat.com \
--cc=mcoqueli@redhat.com \
--cc=sgarzare@redhat.com \
--cc=virtualization@lists.linux.dev \
--cc=xieyongji@bytedance.com \
--cc=xuanzhuo@linux.alibaba.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®