vhost: use vhost_tasks for worker threads
authorMike Christie <michael.christie@oracle.com>
Fri, 10 Mar 2023 22:03:32 +0000 (16:03 -0600)
committerChristian Brauner <brauner@kernel.org>
Thu, 23 Mar 2023 11:45:37 +0000 (12:45 +0100)
commit6e890c5d5021ca7e69bbe203fde42447874d9a82
tree1c244655a6ce71005156847d8e8403d4034af4ea
parent1a5f8090c6de99306f4212dc7adfc6189a616eb9
vhost: use vhost_tasks for worker threads

For vhost workers we use the kthread API which inherit's its values from
and checks against the kthreadd thread. This results in the wrong RLIMITs
being checked, so while tools like libvirt try to control the number of
threads based on the nproc rlimit setting we can end up creating more
threads than the user wanted.

This patch has us use the vhost_task helpers which will inherit its
values/checks from the thread that owns the device similar to if we did
a clone in userspace. The vhost threads will now be counted in the nproc
rlimits. And we get features like cgroups and mm sharing automatically,
so we can remove those calls.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>
drivers/vhost/vhost.c
drivers/vhost/vhost.h