RLIMIT_CPU charges a VM-clone child's CPU time to its parent

Open
#478 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
c, linux

Research direction

Start by reading src/runtime/forkipc.c around sys_clone_vm and src/syscall/sys.c around rlimit_cpu_main to see how VM-clone children are tracked and how CLOCK_PROCESS_CPUTIME_ID is sampled. Inspect test-rlimit-cpu for the existing limit tests, then add the described parent/child case so each guest process accounts for its own vCPU threads and the parent avoids SIGXCPU.

Written by the indexing model from the issue text.

Description

bug

A clone(CLONE_VM) child without CLONE_THREAD or CLONE_VFORK runs inside its parent's host process (sys_clone_vm in src/runtime/forkipc.c). The RLIMIT_CPU sampler from #475 (rlimit_cpu_main in src/syscall/sys.c) reads CLOCK_PROCESS_CPUTIME_ID, which counts the whole host process, so the parent and every VM-clone child share one CPU clock and one limit.

On Linux these are separate processes, each with its own CPU time and its own RLIMIT_CPU. Under elfuse, a parent whose VM-clone child spins gets SIGXCPU or SIGKILL for CPU time the child spent. signal_queue_info also puts the signal in the shared pending set, where the child's vCPU can dequeue it.

Follow-ups

  • Account CPU time per guest process, summing the vCPU threads of each one, and give each VM-clone child its own RLIMIT_CPU check.
  • Add a case to test-rlimit-cpu: a parent under a soft limit of 1 s sleeps while a CLONE_VM child spins for 2 s, and the parent gets no SIGXCPU.
Dominant language
C
Stars
287
Forks
33
Avg merge
2d 17h
Merged PRs (30d)
18

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from sysprog21/elfuse

All issues in sysprog21/elfuse

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.