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 <[email protected]>
> Acked-by: Jason Wang <[email protected]>
> Reviewed-by: Xie Yongji <[email protected]>
> Signed-off-by: Eugenio Pérez <[email protected]>
> ---
> 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


Reply via email to