nproc: cgroup v2 quota ignored when the cgroup path contains ':' or the quota is on a parent cgroup

Abierto
#16,753 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@Srizdebnath ya está trabajando en esto.

Desde el 21/11/2026.

  • #16754 de @Srizdebnath — abierto

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
32/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
linux, rust

Línea de trabajo

Start from cgroups2_quota, which takes split(':').nth(2) of /proc/self/cgroup — a path containing a colon is truncated there, so cpu.max is never found. Fix the path extraction (split on the first two fields only), then walk from the leaf cgroup up through its ancestors reading each cpu.max and keep the smallest quota, as GNU does. Verify with the two systemd-run/systemctl --user set-property repros in the issue: the colon case must print 2 and the nested-quota case 1 on a 4-CPU box. Note a linked PR #16754 is already open, so coordinate before starting.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

U - nproc

nproc misses cgroup v2 CPU quotas in two cases where GNU honors them.

1. The cgroup path contains a :

cgroups2_quota takes split(':').nth(2) of /proc/self/cgroup, so a path such as 0::/user.slice/.../app-dbus\x2d:1.3\x2dorg.gnome.Console.slice/vte-spawn-....scope (the default for a GNOME Console terminal) is cut at the colon, cpu.max is not found, and the quota is ignored.

$ systemd-run --user --scope -q --unit='nq:colon' -p CPUQuota=200% sh -c 'nproc; ./target/debug/nproc'
2      # GNU 9.11
4      # uutils

2. The quota is set on an ancestor cgroup

Only the process's own cpu.max is read. A quota on a parent slice also limits the process, and GNU uses the smallest quota along the path:

$ systemctl --user set-property --runtime nq.slice CPUQuota=150%
$ systemd-run --user --scope -q --slice=nq.slice sh -c 'nproc; ./target/debug/nproc'
2      # GNU
4      # uutils
$ systemctl --user set-property --runtime nq.slice CPUQuota=100%
$ systemd-run --user --scope -q --slice=nq.slice -p CPUQuota=300% sh -c 'nproc; ./target/debug/nproc'
1      # GNU
3      # uutils

(4 CPUs, cgroup v2, GNU coreutils 9.11.)

Lenguaje dominante
Rust
Estrellas
24.4k
Forks
2.2k
Merge medio
2 d 23 h
PR fusionados (30 d)
402

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de uutils/coreutils

Todos los issues de uutils/coreutils

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.