• Mike Christie's avatar
    vhost_task: Allow vhost layer to use copy_process · e297cd54
    Mike Christie authored
    Qemu will create vhost devices in the kernel which perform network, SCSI,
    etc IO and management operations from worker threads created by the
    kthread API. Because the kthread API does a copy_process on the kthreadd
    thread, the vhost layer has to use kthread_use_mm to access the Qemu
    thread's memory and cgroup_attach_task_all to add itself to the Qemu
    thread's cgroups, and it bypasses the RLIMIT_NPROC limit which can result
    in VMs creating more threads than the admin expected.
    
    This patch adds a new struct vhost_task which can be used instead of
    kthreads. They allow the vhost layer to use copy_process and inherit
    the userspace process's mm and cgroups, the task is accounted for
    under the userspace's nproc count and can be seen in its process tree,
    and other features like namespaces work and are inherited by default.
    Signed-off-by: default avatarMike Christie <michael.christie@oracle.com>
    Acked-by: default avatarMichael S. Tsirkin <mst@redhat.com>
    Signed-off-by: default avatarChristian Brauner (Microsoft) <brauner@kernel.org>
    Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
    e297cd54
vhost_task.c 2.77 KB