On Sat, May 31, 2025 at 05:57:26PM +0800, Cindy Lu wrote:
> The vhost now uses vhost_task and workers as a child of the owner thread.
> While this aligns with containerization principles, it confuses some
> legacy userspace applications, therefore, we are reintroducing kthread
> API support.
> 
> Add a new module parameter to allow userspace to select behavior
> between using kthread and task.
> 
> By default, this parameter is set to true (task mode). This means the
> default behavior remains unchanged by this patch.
> 
> Signed-off-by: Cindy Lu <l...@redhat.com>

So modparam is here but does nothing.
This should be the last patch in the series, or squashed with 3/3.

why is this inherit_owner but ioctl is fork_owner? is there
a difference? If not
can't the name be consistent with the ioctl?  vhost_fork_owner?


> ---
>  drivers/vhost/vhost.c |  5 +++++
>  drivers/vhost/vhost.h | 10 ++++++++++
>  2 files changed, 15 insertions(+)
> 
> diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
> index 3a5ebb973dba..240ba78b1e3f 100644
> --- a/drivers/vhost/vhost.c
> +++ b/drivers/vhost/vhost.c
> @@ -41,6 +41,10 @@ static int max_iotlb_entries = 2048;
>  module_param(max_iotlb_entries, int, 0444);
>  MODULE_PARM_DESC(max_iotlb_entries,
>       "Maximum number of iotlb entries. (default: 2048)");
> +bool inherit_owner_default = true;
> +module_param(inherit_owner_default, bool, 0444);
> +MODULE_PARM_DESC(inherit_owner_default,
> +              "Set task mode as the default(default: Y)");
>  
>  enum {
>       VHOST_MEMORY_F_LOG = 0x1,
> @@ -552,6 +556,7 @@ void vhost_dev_init(struct vhost_dev *dev,
>       dev->byte_weight = byte_weight;
>       dev->use_worker = use_worker;
>       dev->msg_handler = msg_handler;
> +     dev->inherit_owner = inherit_owner_default;
>       init_waitqueue_head(&dev->wait);
>       INIT_LIST_HEAD(&dev->read_list);
>       INIT_LIST_HEAD(&dev->pending_list);
> diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h
> index bb75a292d50c..c1ff4a92b925 100644
> --- a/drivers/vhost/vhost.h
> +++ b/drivers/vhost/vhost.h
> @@ -176,6 +176,16 @@ struct vhost_dev {
>       int byte_weight;
>       struct xarray worker_xa;
>       bool use_worker;
> +     /*
> +      * If inherit_owner is true we use vhost_tasks to create
> +      * the worker so all settings/limits like cgroups, NPROC,
> +      * scheduler, etc are inherited from the owner. If false,
> +      * we use kthreads and only attach to the same cgroups
> +      * as the owner for compat with older kernels.
> +      * here we use true as default value.
> +      * The default value is set by modparam inherit_owner_default
> +      */
> +     bool inherit_owner;
>       int (*msg_handler)(struct vhost_dev *dev, u32 asid,
>                          struct vhost_iotlb_msg *msg);
>  };
> -- 
> 2.45.0


Reply via email to