From: "Michael S. Tsirkin" <mst@redhat.com>
To: "Eugenio Pérez" <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: Fri, 10 Oct 2025 08:34:43 -0400 [thread overview]
Message-ID: <20251010081923-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20251010085827.116958-2-eperezma@redhat.com>
On Fri, Oct 10, 2025 at 10:58:21AM +0200, Eugenio Pérez wrote:
> It will be used in a few more scenarios read-only so make it more
> scalable.
Well a mutex is sleepable and rwlock is a spinlock.
So this does much more than "make it more scalable".
"A few more scenarios" and "scalable" is also vague.
RW has its own issues such as fairness.
So tell us please, which operations do you want to speed up and why?
What kind of speedup was observed?
All this belongs in the commit log.
> Suggested-by: Xie Yongji <xieyongji@bytedance.com>
> Acked-by: Jason Wang <jasowang@redhat.com>
> Reviewed-by: Xie Yongji <xieyongji@bytedance.com>
> Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
> ---
> v6: Not including linux/rwlock.h directly.
>
> v2: New in v2.
> ---
...
> @@ -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.
So it looks like the previous version did not compile
and this one looks DOA. What's up?
At this stage please include information about configs you
tested, and how.
And any locking changes should also be tested with lockdep enabled
please.
--
MST
next prev parent reply other threads:[~2025-10-10 12:34 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 [this message]
2025-10-17 6:32 ` Eugenio Perez Martin
2025-10-23 8:59 ` Eugenio Perez Martin
2025-10-27 16:57 ` Michael S. Tsirkin
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=20251010081923-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;
as well as URLs for NNTP newsgroup(s).