Pádraig Brady wrote:
> cgroup constraints are a popular mechanism on linux.
> I was thinking of augmenting the nproc routines
> to incorporate cgroup cpu constraints for NPROC_CURRENT_OVERRIDABLE
> so that we'd return MIN(cgroup constraint, current value);

Sounds reasonable.

So, if I understand it correctly, the inequality chain

         sysconf (_SC_NPROCESSORS_CONF)
            >= sysconf (_SC_NPROCESSORS_ONLN)
               >= num_processors_via_affinity_mask ()
     The first number is the number of CPUs configured in the system.
     The second number is the number of CPUs available to the scheduler.
     The third number is the number of CPUs available to the current process.

would be replaced with

         sysconf (_SC_NPROCESSORS_CONF)
            >= sysconf (_SC_NPROCESSORS_ONLN)
               >= num_processors_available_to_cgroup ()
                  >= num_processors_via_affinity_mask ()
     The first number is the number of CPUs configured in the system.
     The second number is the number of CPUs available to the scheduler.
     The third number is the number of CPUs available to the current cgroup.
     The fourth number is the number of CPUs available to the current process.

Right?

> The cgroup constraint would be inferred from:
>    cat $(findmnt -n -t cgroup2 -o target)/$(cut -d: -f3- < 
> /proc/self/cgroup)/cpu.max

On my system, that file does not exist:

  $ findmnt -n -t cgroup2 -o target
  /sys/fs/cgroup
  $ cut -d: -f3- < /proc/self/cgroup
  
/user.slice/user-1000.slice/[email protected]/app.slice/app-org.kde.konsole-350a5358a38a477daa683d22092467dd.scope
  $ ls -l 
/sys/fs/cgroup/user.slice/user-1000.slice/[email protected]/app.slice/app-org.kde.konsole-350a5358a38a477daa683d22092467dd.scope
  total 0
  -r--r--r-- 1 bruno bruno 0  2. Jul 20:47 cgroup.controllers
  -r--r--r-- 1 bruno bruno 0  2. Jul 20:47 cgroup.events
  -rw-r--r-- 1 bruno bruno 0  2. Jul 20:47 cgroup.freeze
  --w------- 1 bruno bruno 0  2. Jul 20:47 cgroup.kill
  -rw-r--r-- 1 bruno bruno 0  2. Jul 20:47 cgroup.max.depth
  -rw-r--r-- 1 bruno bruno 0  2. Jul 20:47 cgroup.max.descendants
  -rw-r--r-- 1 bruno bruno 0  2. Jul 20:47 cgroup.pressure
  -rw-r--r-- 1 bruno bruno 0  2. Jul 20:47 cgroup.procs
  -r--r--r-- 1 bruno bruno 0  2. Jul 20:47 cgroup.stat
  -rw-r--r-- 1 bruno bruno 0  2. Jul 20:47 cgroup.subtree_control
  -rw-r--r-- 1 bruno bruno 0  2. Jul 20:47 cgroup.threads
  -rw-r--r-- 1 bruno bruno 0  2. Jul 20:47 cgroup.type
  -rw-r--r-- 1 bruno bruno 0  2. Jul 20:47 cpu.pressure
  -r--r--r-- 1 bruno bruno 0  2. Jul 20:47 cpu.stat
  -r--r--r-- 1 bruno bruno 0  2. Jul 20:47 cpu.stat.local
  -rw-r--r-- 1 bruno bruno 0  2. Jul 20:47 io.pressure
  -r--r--r-- 1 bruno bruno 0  2. Jul 20:47 memory.current
  -r--r--r-- 1 bruno bruno 0  2. Jul 20:47 memory.events
  -r--r--r-- 1 bruno bruno 0  2. Jul 20:47 memory.events.local
  -rw-r--r-- 1 bruno bruno 0  2. Jul 20:47 memory.high
  -rw-r--r-- 1 bruno bruno 0  2. Jul 20:47 memory.low
  -rw-r--r-- 1 bruno bruno 0  2. Jul 20:47 memory.max
  -rw-r--r-- 1 bruno bruno 0  2. Jul 20:47 memory.min
  -r--r--r-- 1 bruno bruno 0  2. Jul 20:47 memory.numa_stat
  -rw-r--r-- 1 bruno bruno 0  2. Jul 20:47 memory.oom.group
  -r--r--r-- 1 bruno bruno 0  2. Jul 20:47 memory.peak
  -rw-r--r-- 1 bruno bruno 0  2. Jul 20:47 memory.pressure
  --w------- 1 bruno bruno 0  2. Jul 20:47 memory.reclaim
  -r--r--r-- 1 bruno bruno 0  2. Jul 20:47 memory.stat
  -r--r--r-- 1 bruno bruno 0  2. Jul 20:47 memory.swap.current
  -r--r--r-- 1 bruno bruno 0  2. Jul 20:47 memory.swap.events
  -rw-r--r-- 1 bruno bruno 0  2. Jul 20:47 memory.swap.high
  -rw-r--r-- 1 bruno bruno 0  2. Jul 20:47 memory.swap.max
  -r--r--r-- 1 bruno bruno 0  2. Jul 20:47 memory.swap.peak
  -r--r--r-- 1 bruno bruno 0  2. Jul 20:47 memory.zswap.current
  -rw-r--r-- 1 bruno bruno 0  2. Jul 20:47 memory.zswap.max
  -rw-r--r-- 1 bruno bruno 0  2. Jul 20:47 memory.zswap.writeback
  -r--r--r-- 1 bruno bruno 0  2. Jul 20:47 pids.current
  -r--r--r-- 1 bruno bruno 0  2. Jul 20:47 pids.events
  -rw-r--r-- 1 bruno bruno 0  2. Jul 20:47 pids.max
  -r--r--r-- 1 bruno bruno 0  2. Jul 20:47 pids.peak

Just FYI.

Bruno




Reply via email to