criu/compel/include/uapi
Andrei Vagin 03d41eff5d
compel/infect: Use waitpid with specific PIDs in compel_stop_tasks_on_syscall
When CRIU traces a large number of tasks, calling wait4(-1, ...) can
be slow because the kernel has to iterate over many tasks to find one
that has changed state. This overhead becomes significant when
thousands of tasks are involved. The time complexity of the old approach
was O(n^2) because we called wait4(-1, ...) N times, and each call
took O(N) time in the kernel.

This patch introduces compel_stop_tasks_on_syscall which takes an
array of PIDs and waits for each one specifically. This avoids the
O(N) search in the kernel's do_wait implementation and significantly
improves performance during the restore phase when many tasks are
being resumed and stopped at the rt_sigreturn syscall.

Some parallelism still exists in this approach. The loop waits for each
process to stop on a syscall, verifies it, and then lets it continue
running. While we move to wait for the next process in the array, the
previously processed ones continue their execution in parallel.

The performance profile of the bottleneck showed:
   - 70.45% entry_SYSCALL_64
      - do_syscall_64
         - 68.29% __do_sys_wait4
            - kernel_wait4
               - 68.28% do_wait
                  - 68.26% __do_wait
                     - 65.69% wait_consider_task
                          8.71% _raw_spin_lock_irq
                          2.39% _raw_spin_unlock_irq

Signed-off-by: Andrei Vagin <avagin@google.com>
2026-07-21 13:40:18 +02:00
..
asm compel: make include/uapi/asm symlink permanent 2017-03-15 00:09:56 +03:00
common compel: uapi -- Add common symlink 2017-03-15 00:06:12 +03:00
compel compel: make include/uapi symlink permanent 2017-03-15 00:09:55 +03:00
cpu.h compel/criu: Add __must_check 2020-02-04 12:39:04 -08:00
handle-elf.h Run 'make indent' on header files 2021-09-03 10:31:00 -07:00
infect-rpc.h Run 'make indent' on header files 2021-09-03 10:31:00 -07:00
infect-util.h criu: use libuuid for criu_run_id generation 2025-03-21 12:40:31 -07:00
infect.h compel/infect: Use waitpid with specific PIDs in compel_stop_tasks_on_syscall 2026-07-21 13:40:18 +02:00
ksigset.h ksigset: fix a typo in ksigdelset 2021-09-03 10:31:00 -07:00
log.h compel/uapi: add prefix to log levels 2017-03-15 09:36:06 +03:00
loglevels.h clang-format: do automatic comment fixups 2022-04-28 17:53:52 -07:00
plugins compel: Include compel headers as system ones 2017-03-15 00:06:02 +03:00
plugins.h Run 'make indent' on header files 2021-09-03 10:31:00 -07:00
ptrace.h compel: fix build on Amazon Linux 2 due to missing PTRACE_ARCH_PRCTL 2024-09-11 16:02:11 -07:00
sigframe-common.h Run 'make indent' on header files 2021-09-03 10:31:00 -07:00
task-state.h Run 'make indent' on header files 2021-09-03 10:31:00 -07:00