offbynull
offbynull

Reputation: 390

Mixing cpuset.cpus and cpuset.mems cgroups with cpu.shares with memory.limit_in_bytes

I have some confusion over how cgroups work. Here's my understanding of these cgroup limits...

So what happens when you bind a process to a specific cpuset, cpu, and memory? Some examples...

  1. If the NUMA nodes I bind to total 8GB but I set my memory limit to 12GB, what happens?
  2. If I bind to cores 0 and 1 but set the cpu shares to 2 out of 1024, what happens?

Also, how do I know the details/specs of the cores/NUMA nodes that I'm referencing in cpuset?

Upvotes: 1

Views: 1518

Answers (1)

chestack
chestack

Reputation: 116

have the same confusion. But based on my test, if cpuset.cpu_exclusive=0(cores are shared), both cpu.shares and cpuset.cpus work. Test is as following.

  1. create two cgroups: cputest1 and cputest2(same hierarchy under root)

  2. for both cputest1 and cputest2, do:

    echo 0,2 > cpuset.cpus echo 0 > cpuset.mems

  3. new terminal a

    cd /sys/fs/cgroup/cpuset/cputest1 echo $$ >> cgroup.proc while :; do echo test > /dev/null; done

new terminal b

cd /sys/fs/cgroup/cpuset/cputest1
echo $$ >> cgroup.proc
while :; do echo test > /dev/null; done

new terminal c

cd /sys/fs/cgroup/cpuset/cputest2
echo $$ >> cgroup.proc
while :; do echo test > /dev/null; done

run top, there are three bash tasks, and cpu usage of each task is almost same about(60%-70%), total is 200%

4. terminal a

echo $$ >> /sys/fs/cgroup/cpu/cputest1/cgroup.proc
while :; do echo test > /dev/null; done

terminal b

echo $$ >> /sys/fs/cgroup/cpu/cputest1/cgroup.proc
while :; do echo test > /dev/null; done

terminal c

echo $$ >> /sys/fs/cgroup/cpu/cputest2/cgroup.proc
while :; do echo test > /dev/null; done

echo 2/2048/1024 > /sys/fs/cgroup/cpu/cputest1/cpu.shares
echo 2048/2/1024 > /sys/fs/cgroup/cpu/cputest2/cpu.shares

run top to watch the cpu usage among three bash task

Upvotes: 1

Related Questions