public inbox for linux-doc@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sched_deadline, docs: add affinity setting with cgroup2 cpuset controller
@ 2025-05-22  8:06 Shashank Balaji
  2025-05-27 13:11 ` Juri Lelli
  0 siblings, 1 reply; 3+ messages in thread
From: Shashank Balaji @ 2025-05-22  8:06 UTC (permalink / raw)
  To: Jonathan Corbet, Juri Lelli, Peter Zijlstra
  Cc: linux-doc, linux-kernel, Shinya Takumi, Shashank Balaji

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>
---
 Documentation/scheduler/sched-deadline.rst | 29 +++++++++++++++++++++++------
 1 file changed, 23 insertions(+), 6 deletions(-)

diff --git a/Documentation/scheduler/sched-deadline.rst b/Documentation/scheduler/sched-deadline.rst
index a727827b8dd52710f880c2b92d3a8224c259873c..e3d7968ff6c3c43f87e249dbcb309619dbd616bf 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 <cpusets>` and
+ :ref:`Documentation/admin-guide/cgroup-v2.rst <cgroup-v2>` 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 (rt-app is used to create a -deadline task)::
@@ -695,6 +699,19 @@ Deadline Task Scheduling
    rt-app -t 100000:10000:d:0 -D5 # it is now actually superfluous to specify
 				  # task affinity
 
+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
+   rt-app -t 100000:10000:d:0 -D5
+
 6. Future plans
 ===============
 

---
base-commit: a5806cd506af5a7c19bcd596e4708b5c464bfd21
change-id: 20250522-sched-deadline-cpu-affinity-b0b4edf0ddc9

Best regards,
-- 
Shashank Balaji <shashank.mahadasyam@sony.com>


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] sched_deadline, docs: add affinity setting with cgroup2 cpuset controller
  2025-05-22  8:06 [PATCH] sched_deadline, docs: add affinity setting with cgroup2 cpuset controller Shashank Balaji
@ 2025-05-27 13:11 ` Juri Lelli
  2025-05-27 13:26   ` Shashank Balaji
  0 siblings, 1 reply; 3+ messages in thread
From: Juri Lelli @ 2025-05-27 13:11 UTC (permalink / raw)
  To: Shashank Balaji
  Cc: Jonathan Corbet, Peter Zijlstra, linux-doc, linux-kernel,
	Shinya Takumi

Hello!

On 22/05/25 17:06, Shashank Balaji wrote:
> 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.

Thanks a lot for working on this. Really appreaciated.

> Signed-off-by: Shashank Balaji <shashank.mahadasyam@sony.com>
> ---
>  Documentation/scheduler/sched-deadline.rst | 29 +++++++++++++++++++++++------
>  1 file changed, 23 insertions(+), 6 deletions(-)
> 
> diff --git a/Documentation/scheduler/sched-deadline.rst b/Documentation/scheduler/sched-deadline.rst
> index a727827b8dd52710f880c2b92d3a8224c259873c..e3d7968ff6c3c43f87e249dbcb309619dbd616bf 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 <cpusets>` and
> + :ref:`Documentation/admin-guide/cgroup-v2.rst <cgroup-v2>` 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 (rt-app is used to create a -deadline task)::
> @@ -695,6 +699,19 @@ Deadline Task Scheduling
>     rt-app -t 100000:10000:d:0 -D5 # it is now actually superfluous to specify
>  				  # task affinity
>  
> +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
> +   rt-app -t 100000:10000:d:0 -D5

Sadly, the example with cgroup v1 was made at a time when rt-app still
supported command line parameters like the above. I believe nowadays
that is not the case anymore and one needs to create a json file
describing the task to run it with rt-app.

I would say we should update both examples to use something a little
more generic, e.g.,

# chrt --deadline --sched-runtime 10000000 --sched-period 100000000 0 yes >/dev/null &

What do you think?

Best,
Juri


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] sched_deadline, docs: add affinity setting with cgroup2 cpuset controller
  2025-05-27 13:11 ` Juri Lelli
@ 2025-05-27 13:26   ` Shashank Balaji
  0 siblings, 0 replies; 3+ messages in thread
From: Shashank Balaji @ 2025-05-27 13:26 UTC (permalink / raw)
  To: Juri Lelli
  Cc: Jonathan Corbet, Peter Zijlstra, linux-doc, linux-kernel,
	Shinya Takumi

Hi Juri,

On Tue, May 27, 2025 at 03:11:45PM +0200, Juri Lelli wrote:
> Hello!
> 
> On 22/05/25 17:06, Shashank Balaji wrote:
> > 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.
> 
> Thanks a lot for working on this. Really appreaciated.

Thank you :)

> > +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
> > +   rt-app -t 100000:10000:d:0 -D5
> 
> Sadly, the example with cgroup v1 was made at a time when rt-app still
> supported command line parameters like the above. I believe nowadays
> that is not the case anymore and one needs to create a json file
> describing the task to run it with rt-app.
> 
> I would say we should update both examples to use something a little
> more generic, e.g.,
> 
> # chrt --deadline --sched-runtime 10000000 --sched-period 100000000 0 yes >/dev/null &
> 
> What do you think?
> 
> Best,
> Juri

Haha, I was just about to send the patch with the chrt example, when I
checked out the rt-app repo and saw that it's much more powerful. I
thought, "they must have had a good reason for using rt-app instead of
chrt for the example", and switched it to rt-app at the last second. I
didn't know that rt-app doesn't support command line parameters anymore.
I'll send out v2 with the chrt example.

Thanks!

Regards,
Shashank

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-05-27 13:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-22  8:06 [PATCH] sched_deadline, docs: add affinity setting with cgroup2 cpuset controller Shashank Balaji
2025-05-27 13:11 ` Juri Lelli
2025-05-27 13:26   ` Shashank Balaji

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox