Re: [PATCH v2 6/7] vhost: Add kthread support in function vhost_worker_create
From: Mike Christie
Date: Mon Oct 14 2024 - 17:02:25 EST
On 10/3/24 8:58 PM, Cindy Lu wrote:
> +static struct vhost_worker *vhost_worker_create(struct vhost_dev *dev)
> +{
> + if (enforce_inherit_owner)
> + return vhost_worker_create_task(dev);
> + else
> + return vhost_worker_create_kthread(dev);
> +}
The reason we are in this whole mess is because for vhost-scsi
we wanted to create multiple worker threads as the single thread
became a bottleneck. We couldn't use kthreads because they were
not accounted for under thread that created it and we could
exceed the NPROC_LIMIT.
So with the above code, we could hit that problem again if userspace
did the VHOST_NEW_WORKER ioctl and enforce_inherit_owner=false.
You would want a check for enforce_inherit_owner in vhost_worker_ioctl.