linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2 0/9] Use copy_process/create_io_thread in vhost layer
@ 2021-09-21 21:52 Mike Christie
  2021-09-21 21:52 ` [PATCH V2 1/9] fork: Make IO worker options flag based Mike Christie
                   ` (8 more replies)
  0 siblings, 9 replies; 22+ messages in thread
From: Mike Christie @ 2021-09-21 21:52 UTC (permalink / raw)
  To: hdanton, hch, stefanha, jasowang, mst, sgarzare, virtualization,
	christian.brauner, axboe, linux-kernel

The following patches were made over Linus's tree but also apply over
Jens's 5.16 io_uring branch and Michaels' vhost/next branch.

This is version 2 of the patchset and should handle all the review
comments posted in V1 here:

https://lore.kernel.org/all/20210916212051.6918-1-michael.christie@oracle.com/

If I missed a comment, please let me know.

This patchset allows the vhost layer to do a copy_process on the thread
that does the VHOST_SET_OWNER ioctl like how io_uring does a copy_process
against its userspace app (Jens, the patches make create_io_thread more
generic so that's why you are cc'd). This allows the vhost layer's worker
threads to inherit cgroups, namespaces, address space, etc and this worker
thread will also be accounted for against that owner/parent process's
RLIMIT_NPROC limit.

If you are not familiar with qemu and vhost here is more detailed
problem description:

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.

The problem with this approach is that we then have to add new functions/
args/functionality for every thing we want to inherit. I started doing
that here:

https://lkml.org/lkml/2021/6/23/1233

for the RLIMIT_NPROC check, but it seems it might be easier to just
inherit everything from the beginning, becuase I'd need to do something
like that patch several times. For example, the current approach does not
support cgroups v2 so commands like virsh emulatorpin do not work. The
qemu process can go over its RLIMIT_NPROC. And for future vhost interfaces
where we export the vhost thread pid we will want the namespace info.

V2:
- Rename kernel_copy_process to kernel_worker.
- Instead of exporting functions, make kernel_worker() a proper
  function/API that does common work for the caller.
- Instead of adding new fields to kernel_clone_args for each option
  make it flag based similar to CLONE_*.
- Drop unused completion struct in vhost.
- Fix compile warnings by merging vhost cgroup cleanup patch and
  vhost conversion patch.
 



^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2021-10-04 13:15 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-21 21:52 [PATCH V2 0/9] Use copy_process/create_io_thread in vhost layer Mike Christie
2021-09-21 21:52 ` [PATCH V2 1/9] fork: Make IO worker options flag based Mike Christie
2021-09-22 12:44   ` Christian Brauner
2021-09-21 21:52 ` [PATCH V2 2/9] fork: pass worker_flags to copy_thread Mike Christie
2021-09-22 12:42   ` Christian Brauner
2021-09-22 14:18   ` Geert Uytterhoeven
2021-09-21 21:52 ` [PATCH V2 3/9] fork: move PF_IO_WORKER's kernel frame setup to new flag Mike Christie
2021-09-22 12:32   ` Geert Uytterhoeven
2021-09-22 12:39     ` Christian Brauner
2021-09-22 12:45     ` Christian Brauner
2021-09-21 21:52 ` [PATCH V2 4/9] fork: add option to not clone or dup files Mike Christie
2021-09-22 12:46   ` Christian Brauner
2021-09-21 21:52 ` [PATCH V2 5/9] fork: add helper to clone a process Mike Christie
2021-09-22 12:50   ` Christian Brauner
2021-09-21 21:52 ` [PATCH V2 6/9] io_uring: switch to kernel_worker Mike Christie
2021-09-22 12:53   ` Christian Brauner
2021-09-21 21:52 ` [PATCH V2 7/9] fork: Add worker flag to ignore signals Mike Christie
2021-09-22 12:52   ` Christian Brauner
2021-09-21 21:52 ` [PATCH V2 8/9] vhost: move worker thread fields to new struct Mike Christie
2021-10-04 13:12   ` Michael S. Tsirkin
2021-09-21 21:52 ` [PATCH V2 9/9] vhost: use kernel_worker to check RLIMITs and inherit v2 cgroups Mike Christie
2021-10-04 13:12   ` Michael S. Tsirkin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).