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

未关闭
#478 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
55/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
c, linux

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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.
主要语言
C
星标
278
派生
31
平均合并
2 天 18 小时
30 天内合并 PR
16

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

sysprog21/elfuse 的其他 Issue

查看 sysprog21/elfuse 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。