From: Shashank Balaji Date: Tue, 27 May 2025 14:55:58 +0000 (+0900) Subject: sched_deadline, docs: add affinity setting with cgroup2 cpuset controller X-Git-Tag: io_uring-6.17-20250815~111^2~87 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=0116765035eb3de7a6e7656c6c5ae48e68cfdfe4;p=linux-block.git 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 Reviewed-by: Juri Lelli Signed-off-by: Jonathan Corbet Link: https://lore.kernel.org/r/20250527-sched-deadline-cpu-affinity-v2-2-b8b40a4feefa@sony.com --- diff --git a/Documentation/scheduler/sched-deadline.rst b/Documentation/scheduler/sched-deadline.rst index b7aa96b0a025..ec543a12f848 100644 --- a/Documentation/scheduler/sched-deadline.rst +++ b/Documentation/scheduler/sched-deadline.rst @@ -20,7 +20,8 @@ Deadline Task Scheduling 4.3 Default behavior 4.4 Behavior of sched_yield() 5. Tasks CPU affinity - 5.1 SCHED_DEADLINE and cpusets HOWTO + 5.1 Using cgroup v1 cpuset controller + 5.2 Using cgroup v2 cpuset controller 6. Future plans A. Test suite B. Minimal main() @@ -671,12 +672,15 @@ Deadline Task Scheduling 5. Tasks CPU affinity ===================== - -deadline tasks cannot have an affinity mask smaller that the entire - root_domain they are created on. However, affinities can be specified - through the cpuset facility (Documentation/admin-guide/cgroup-v1/cpusets.rst). + Deadline tasks cannot have a cpu affinity mask smaller than the root domain they + are created on. So, using ``sched_setaffinity(2)`` won't work. Instead, the + the deadline task should be created in a restricted root domain. This can be + done using the cpuset controller of either cgroup v1 (deprecated) or cgroup v2. + See :ref:`Documentation/admin-guide/cgroup-v1/cpusets.rst ` and + :ref:`Documentation/admin-guide/cgroup-v2.rst ` for more information. -5.1 SCHED_DEADLINE and cpusets HOWTO ------------------------------------- +5.1 Using cgroup v1 cpuset controller +------------------------------------- An example of a simple configuration (pin a -deadline task to CPU0) follows:: @@ -693,6 +697,19 @@ Deadline Task Scheduling echo $$ > cpu0/tasks chrt --sched-runtime 100000 --sched-period 200000 --deadline 0 yes > /dev/null +5.2 Using cgroup v2 cpuset controller +------------------------------------- + + Assuming the cgroup v2 root is mounted at ``/sys/fs/cgroup``. + + cd /sys/fs/cgroup + echo '+cpuset' > cgroup.subtree_control + mkdir deadline_group + echo 0 > deadline_group/cpuset.cpus + echo 'root' > deadline_group/cpuset.cpus.partition + echo $$ > deadline_group/cgroup.procs + chrt --sched-runtime 100000 --sched-period 200000 --deadline 0 yes > /dev/null + 6. Future plans ===============