1. Verify that cpu and cpuset are in this file

    # cat /sys/fs/cgroup/cgroup.controllers

  2. Enable cpu-related controllers
    # echo "+cpu" >> /sys/fs/cgroup/cgroup.subtree_control
    # echo "+cpuset" >> /sys/fs/cgroup/cgroup.subtree_control
    
  3. Create the cgroup for our segmented experiment cores

    # mkdir /sys/fs/cgroup/experiment/

  4. Set the cpus for the experiment cgroup

    # echo "3-6" > /sys/fs/cgroup/experiment/cpuset.cpus

  5. Set the memory node for the experiment cgroup

    # echo 0 > /sys/fs/cgroup/experiment/cpuset.mems

  6. Set the cpuset for the experiment cgroup to cpu_exclusive mode

    # echo "3-6" > /sys/fs/cgroup/experiment/cpuset.cpus.exclusive

  7. Create the cgroup for everything else

    # mkdir /sys/fs/cgroup/notexperiment/

  8. Set the cpus for the notexperiment cgroup

    # echo "1-2,7-15" > /sys/fs/cgroup/notexperiment/cpuset.cpus

  9. Set the memory node for the notexperiment cgroup

    # echo 0 > /sys/fs/cgroup/notexperiment/cpuset.mems

  10. Set the cpuset for the notexperiment cgroup to cpu_exclusive mode

    # echo "1-2,7-15" > /sys/fs/cgroup/notexperiment/cpuset.cpus.exclusive

  11. Move all the existing tasks to the notexperiment cgroup

    # ps -eLo lwp | while read thread; do echo $thread > /sys/fs/cgroup/notexperiment/cgroup.procs; done

  12. Move the shell into the experiment cgroup and then use it to start the experiment program.

    # echo $$ > /sys/fs/cgroup/experiment/cgroup.procs

  13. Set the two cgroups to be root cgroups, so they can have true exclusive access to the resources we've allocated to them.

    # echo "root" > /sys/fs/cgroup/notexperiment/cpuset.cpus.partition
    # echo "root" > /sys/fs/cgroup/experiment/cpuset.cpus.partition

  14. Verify that the only processes running on the isolated cpus are kernel threads

    # ps -e -o pid,psr,cmd | awk '$2 >= 3 && $2 <= 6' | sort -k2,2n

Edit

Pub: 11 Dec 2024 22:13 UTC

Edit: 12 Dec 2024 01:46 UTC

Views: 22