Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sched_deadline, docs: add affinity setting with cgroup2 cpuset controller

Setting the cpu affinity mask of a SCHED_DEADLINE process using the cgroup v1
cpuset controller is already detailed. Add similar information for cgroup v2's
cpuset controller.

Signed-off-by: Shashank Balaji <shashank.mahadasyam@sony.com>
Reviewed-by: Juri Lelli <juri.lelli@redhat.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/20250527-sched-deadline-cpu-affinity-v2-2-b8b40a4feefa@sony.com

authored by

Shashank Balaji and committed by
Jonathan Corbet
01167650 ab8531cd

+23 -6
+23 -6
Documentation/scheduler/sched-deadline.rst
··· 20 20 4.3 Default behavior 21 21 4.4 Behavior of sched_yield() 22 22 5. Tasks CPU affinity 23 - 5.1 SCHED_DEADLINE and cpusets HOWTO 23 + 5.1 Using cgroup v1 cpuset controller 24 + 5.2 Using cgroup v2 cpuset controller 24 25 6. Future plans 25 26 A. Test suite 26 27 B. Minimal main() ··· 672 671 5. Tasks CPU affinity 673 672 ===================== 674 673 675 - -deadline tasks cannot have an affinity mask smaller that the entire 676 - root_domain they are created on. However, affinities can be specified 677 - through the cpuset facility (Documentation/admin-guide/cgroup-v1/cpusets.rst). 674 + Deadline tasks cannot have a cpu affinity mask smaller than the root domain they 675 + are created on. So, using ``sched_setaffinity(2)`` won't work. Instead, the 676 + the deadline task should be created in a restricted root domain. This can be 677 + done using the cpuset controller of either cgroup v1 (deprecated) or cgroup v2. 678 + See :ref:`Documentation/admin-guide/cgroup-v1/cpusets.rst <cpusets>` and 679 + :ref:`Documentation/admin-guide/cgroup-v2.rst <cgroup-v2>` for more information. 678 680 679 - 5.1 SCHED_DEADLINE and cpusets HOWTO 680 - ------------------------------------ 681 + 5.1 Using cgroup v1 cpuset controller 682 + ------------------------------------- 681 683 682 684 An example of a simple configuration (pin a -deadline task to CPU0) follows:: 683 685 ··· 695 691 echo 1 > cpu0/cpuset.cpu_exclusive 696 692 echo 1 > cpu0/cpuset.mem_exclusive 697 693 echo $$ > cpu0/tasks 694 + chrt --sched-runtime 100000 --sched-period 200000 --deadline 0 yes > /dev/null 695 + 696 + 5.2 Using cgroup v2 cpuset controller 697 + ------------------------------------- 698 + 699 + Assuming the cgroup v2 root is mounted at ``/sys/fs/cgroup``. 700 + 701 + cd /sys/fs/cgroup 702 + echo '+cpuset' > cgroup.subtree_control 703 + mkdir deadline_group 704 + echo 0 > deadline_group/cpuset.cpus 705 + echo 'root' > deadline_group/cpuset.cpus.partition 706 + echo $$ > deadline_group/cgroup.procs 698 707 chrt --sched-runtime 100000 --sched-period 200000 --deadline 0 yes > /dev/null 699 708 700 709 6. Future plans