Re: [PATCH v11 8/8] vhost: use vhost_tasks for worker threads

From: Nicolas Dichtel
Date: Fri May 05 2023 - 09:40:28 EST


Le 03/02/2023 à 00:25, Mike Christie a écrit :
> 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@xxxxxxxxxx>
> Acked-by: Michael S. Tsirkin <mst@xxxxxxxxxx>

I have a question about (a side effect of?) this patch. The output of the 'ps'
command has changed. Here is an example:

Before:
$ ps
PID TTY TIME CMD
598 ttyS0 00:00:00 login
640 ttyS0 00:00:00 bash
8880 ttyS0 00:00:06 example:2
9389 ttyS0 00:00:00 ps
$ ps a
PID TTY STAT TIME COMMAND
598 ttyS0 Ss 0:00 /bin/login -p --
602 tty1 Ss+ 0:00 /sbin/agetty -o -p -- \u --noclear tty1 linux
640 ttyS0 S 0:00 /bin/bash -li
8880 ttyS0 SLl 0:10 /usr/bin/example
9396 ttyS0 R+ 0:00 ps a
$ pgrep -f example
8880

After:
$ ps
PID TTY TIME CMD
538 ttyS0 00:00:00 login
574 ttyS0 00:00:00 bash
8275 ttyS0 00:03:28 example:2
8285 ttyS0 00:00:00 vhost-8275
8295 ttyS0 00:00:00 vhost-8275
8299 ttyS0 00:00:00 vhost-8275
9054 ttyS0 00:00:00 ps
$ ps a
PID TTY STAT TIME COMMAND
538 ttyS0 Ss 0:00 /bin/login -p --
540 tty1 Ss+ 0:00 /sbin/agetty -o -p -- \u --noclear tty1 linux
574 ttyS0 S 0:00 /bin/bash -li
8275 ttyS0 SLl 3:28 /usr/bin/example
8285 ttyS0 SL 0:00 /usr/bin/example
8295 ttyS0 SL 0:00 /usr/bin/example
8299 ttyS0 SL 0:00 /usr/bin/example
9055 ttyS0 R+ 0:00 ps a
$ pgrep -f example
8275
8285
8295
8299

Is this an intended behavior?
This breaks some of our scripts.


Regards,
Nicolas