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

The following patches made over Linus's tree, allow 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. 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.

V5:
- Handle kbuild errors by building patchset against current kernel that
  has all deps merged. Also add patch to remove create_io_thread code as
  it's not used anymore.
- Rebase patchset against current kernel and handle a new vm PF_IO_WORKER
  case added in 5.16-rc1.
- Add PF_USER_WORKER flag so we can check it later after the initial
  thread creation for the wake up, vm and singal cses.
- Added patch to auto reap the worker thread.
V4:
- Drop NO_SIG patch and replaced with Christian's SIG_IGN patch.
- Merged Christian's kernel_worker_flags_valid helpers into patch 5 that
  added the new kernel worker functions.
- Fixed extra "i" issue.
- Added PF_USER_WORKER flag and added check that kernel_worker_start users
  had that flag set. Also dropped patches that passed worker flags to
  copy_thread and replaced with PF_USER_WORKER check.
V3:
- Add parentheses in p->flag and work_flags check in copy_thread.
- Fix check in arm/arm64 which was doing the reverse of other archs
  where it did likely(!flags) instead of unlikely(flags).
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] 17+ messages in thread

end of thread, other threads:[~2021-11-23 14:23 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-21 17:49 [PATCH V5 00/10] Use copy_process/create_io_thread in vhost layer Mike Christie
2021-11-21 17:49 ` [PATCH V5 01/10] fork: Make IO worker options flag based Mike Christie
2021-11-21 17:49 ` [PATCH V5 02/10] fork/vm: Move common PF_IO_WORKER behavior to new flag Mike Christie
2021-11-22  8:08   ` Geert Uytterhoeven
2021-11-21 17:49 ` [PATCH V5 03/10] fork: add KERNEL_WORKER flag to not dup/clone files Mike Christie
2021-11-21 17:49 ` [PATCH V5 04/10] fork: Add KERNEL_WORKER flag to ignore signals Mike Christie
2021-11-21 17:49 ` [PATCH V5 05/10] signal: Perfom autoreap for PF_USER_WORKER Mike Christie
2021-11-21 17:49 ` [PATCH V5 06/10] fork: add helper to clone a process Mike Christie
2021-11-21 17:49 ` [PATCH V5 07/10] io_uring: switch to kernel_worker Mike Christie
2021-11-21 18:17   ` Jens Axboe
2021-11-22 10:02     ` Christian Brauner
2021-11-22 14:20       ` Jens Axboe
2021-11-22 16:47         ` michael.christie
2021-11-23 14:23           ` Christian Brauner
2021-11-21 17:49 ` [PATCH V5 08/10] fork: remove create_io_thread Mike Christie
2021-11-21 17:49 ` [PATCH V5 09/10] vhost: move worker thread fields to new struct Mike Christie
2021-11-21 17:49 ` [PATCH V5 10/10] vhost: use kernel_worker to check RLIMITs Mike Christie

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).