Skip to contentSkip to conversation

cgroup, docs: Clarify interaction of RT processes with cgroup v2 cpu controller

PATCH Applied Shashank Balaji 4 participants 13 messages Mar 5, 2025 – Apr 2, 2025

Subsystems (2)

v1 of 3 Applied Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover cgroup, docs: Clarify interaction of RT processes with cgroup v2 cpu controller

Currently, CONFIG_RT_GROUP_SCHED is practically unusable. If enabled,
the cpu controller can be enabled only when all the realtime processes are in the root cgroup. This has been clarified by Waiman Long in commit
20d4628 (cgroup, docs: Clarify limitation of RT processes with cgroup v2 cpu controller): https://lore.kernel.org/lkml/[email protected]/

But this limitation does not affect any of the other controllers:
irrespective of CONFIG_RT_GROUP_SCHED, the other controllers can be used for the resource control of realtime processes. This is made more explicit in the first patch.

Even when CONFIG_RT_GROUP_SCHED is disabled, the runtime of realtime processes is accounted for by cpu.pressure, and the usage_usec, user_usec, and system_usec fields of cpu.stat, and cpu.uclamp.{min, max} affect realtime processes as well. This is documented in the second patch.

---
Shashank Balaji (2):
cgroup, docs: Be explicit about independence of RT_GROUP_SCHED and non-cpu controllers cgroup, docs: Document interaction of RT processes with cpu controller

 Documentation/admin-guide/cgroup-v2.rst | 41 ++++++++++++++++++++++-----------
 1 file changed, 27 insertions(+), 14 deletions(-)

---
base-commit: 9b381a28f44a49b92b03bb3982728f9cb67ee225
change-id: 20250226-rt-and-cpu-controller-doc-8a8aac572f3e

Best regards,

Signature · 1 line
Shashank Balaji <[email protected]>
#1 lore raw

PATCH 1/2 cgroup, docs: Be explicit about independence of RT_GROUP_SCHED and non-cpu controllers

The cgroup v2 cpu controller has a limitation that if CONFIG_RT_GROUP_SCHED is enabled, the cpu controller can be enabled only if all the realtime processes are in the root cgroup. The other controllers have no such restriction. They can be used for the resource control of realtime processes irrespective of whether CONFIG_RT_GROUP_SCHED is enabled or not.

---
 Documentation/admin-guide/cgroup-v2.rst | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)
Documentation/admin-guide/cgroup-v2.rst +14 -9
index cb1b4e759b7e267c24d7f4f69564c16fb29c4d89..f293a13b42ed69e7c6bf5e974cb86e228411af4e 100644
@@ -1076,15 +1076,20 @@ cpufreq governor about the minimum desired frequency which should always be
 provided by a CPU, as well as the maximum desired frequency, which should not
 be exceeded by a CPU.
 
-WARNING: cgroup2 doesn't yet support control of realtime processes. For
-a kernel built with the CONFIG_RT_GROUP_SCHED option enabled for group
-scheduling of realtime processes, the cpu controller can only be enabled
-when all RT processes are in the root cgroup.  This limitation does
-not apply if CONFIG_RT_GROUP_SCHED is disabled.  Be aware that system
-management software may already have placed RT processes into nonroot
-cgroups during the system boot process, and these processes may need
-to be moved to the root cgroup before the cpu controller can be enabled
-with a CONFIG_RT_GROUP_SCHED enabled kernel.
+WARNING: cgroup2 cpu controller doesn't yet fully support the control of
+realtime processes. For a kernel built with the CONFIG_RT_GROUP_SCHED option
+enabled for group scheduling of realtime processes, the cpu controller can only
+be enabled when all RT processes are in the root cgroup. Be aware that system
+management software may already have placed RT processes into non-root cgroups
+during the system boot process, and these processes may need to be moved to the
+root cgroup before the cpu controller can be enabled with a
+CONFIG_RT_GROUP_SCHED enabled kernel.
+
+With CONFIG_RT_GROUP_SCHED disabled, this limitation does not apply and some of
+the interface files either affect realtime processes or account for them. See
+the following section for details. Only the cpu controller is affected by
+CONFIG_RT_GROUP_SCHED. Other controllers can be used for the resource control of
+realtime processes irrespective of CONFIG_RT_GROUP_SCHED.
 
 
 CPU Interface Files
Signature · 1 line
2.43.0
Acked-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] cgroup, docs: Be explicit about independence of RT_GROUP_SCHED and non-cpu controllers

Quoted 38 lines · On 3/4/25 11:12 PM, Shashank Balaji via B4 Relay wrote:

From: Shashank Balaji <[email protected]>

The cgroup v2 cpu controller has a limitation that if CONFIG_RT_GROUP_SCHED is enabled, the cpu controller can be enabled only if all the realtime processes are in the root cgroup. The other controllers have no such restriction. They can be used for the resource control of realtime processes irrespective of whether CONFIG_RT_GROUP_SCHED is enabled or not.

---
  Documentation/admin-guide/cgroup-v2.rst | 23 ++++++++++++++---------
  1 file changed, 14 insertions(+), 9 deletions(-)
Documentation/admin-guide/cgroup-v2.rst +7 -9
index cb1b4e759b7e267c24d7f4f69564c16fb29c4d89..f293a13b42ed69e7c6bf5e974cb86e228411af4e 100644
@@ -1076,15 +1076,20 @@ cpufreq governor about the minimum desired frequency which should always be
  provided by a CPU, as well as the maximum desired frequency, which should not
  be exceeded by a CPU.
 
-WARNING: cgroup2 doesn't yet support control of realtime processes. For
-a kernel built with the CONFIG_RT_GROUP_SCHED option enabled for group
-scheduling of realtime processes, the cpu controller can only be enabled
-when all RT processes are in the root cgroup.  This limitation does
-not apply if CONFIG_RT_GROUP_SCHED is disabled.  Be aware that system
-management software may already have placed RT processes into nonroot
-cgroups during the system boot process, and these processes may need
-to be moved to the root cgroup before the cpu controller can be enabled
-with a CONFIG_RT_GROUP_SCHED enabled kernel.
+WARNING: cgroup2 cpu controller doesn't yet fully support the control of
+realtime processes. For a kernel built with the CONFIG_RT_GROUP_SCHED option
+enabled for group scheduling of realtime processes, the cpu controller can only
+be enabled when all RT processes are in the root cgroup. Be aware that system
+management software may already have placed RT processes into non-root cgroups
+during the system boot process, and these processes may need to be moved to the
+root cgroup before the cpu controller can be enabled with a

Documentation/admin-guide/cgroup-v2.rst cpufreq governor about the minimum desired frequency which should always be · line 1095

Quoted 10 lines
Documentation/admin-guide/cgroup-v2.rst +7 -0
+CONFIG_RT_GROUP_SCHED enabled kernel.
+
+With CONFIG_RT_GROUP_SCHED disabled, this limitation does not apply and some of
+the interface files either affect realtime processes or account for them. See
+the following section for details. Only the cpu controller is affected by
+CONFIG_RT_GROUP_SCHED. Other controllers can be used for the resource control of
+realtime processes irrespective of CONFIG_RT_GROUP_SCHED.
 
 
  CPU Interface Files

LGTM

maintainer Acked-by on v1 1/2
#3 lore raw

Re: [PATCH 1/2] cgroup, docs: Be explicit about independence of RT_GROUP_SCHED and non-cpu controllers

In reply to Shashank Balaji
Quoted 9 lines · On Wed, Mar 05, 2025 at 01:12:43PM +0900, Shashank Balaji via B4 Relay…

From: Shashank Balaji <[email protected]>

The cgroup v2 cpu controller has a limitation that if CONFIG_RT_GROUP_SCHED is enabled, the cpu controller can be enabled only if all the realtime processes are in the root cgroup. The other controllers have no such restriction. They can be used for the resource control of realtime processes irrespective of whether CONFIG_RT_GROUP_SCHED is enabled or not.

Quoted 5 lines
---
 Documentation/admin-guide/cgroup-v2.rst | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)
maintainer Applied
#4 lore raw

Re: [PATCH 1/2] cgroup, docs: Be explicit about independence of RT_GROUP_SCHED and non-cpu controllers

In reply to Shashank Balaji
Quoted 10 lines · On Wed, Mar 05, 2025 at 01:12:43PM +0900, Shashank Balaji via B4 Relay wrote:

From: Shashank Balaji <[email protected]>

The cgroup v2 cpu controller has a limitation that if CONFIG_RT_GROUP_SCHED is enabled, the cpu controller can be enabled only if all the realtime processes are in the root cgroup. The other controllers have no such restriction. They can be used for the resource control of realtime processes irrespective of whether CONFIG_RT_GROUP_SCHED is enabled or not.

Applied to cgroup/for-6.15.

Thanks.

Signature · 1 line
tejun
#5 lore raw

PATCH 2/2 cgroup, docs: Document interaction of RT processes with cpu controller

In reply to Shashank Balaji

If the cpu controller is enabled in a CONFIG_RT_GROUP_SCHED disabled setting, cpu.stat and cpu.pressure account for realtime processes, and cpu.uclamp.{min, max} affect realtime processes as well. None of the other interface files are affected by or affect realtime processes.

---
 Documentation/admin-guide/cgroup-v2.rst | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
Documentation/admin-guide/cgroup-v2.rst +13 -5
index f293a13b42ed69e7c6bf5e974cb86e228411af4e..2c267f42e5fef9c4e2c3530ce73330d680b9b2dc 100644
@@ -1095,7 +1095,9 @@ realtime processes irrespective of CONFIG_RT_GROUP_SCHED.
 CPU Interface Files
 ~~~~~~~~~~~~~~~~~~~
 
-All time durations are in microseconds.
+All time durations are in microseconds. Only cpu.stat and cpu.pressure account
+for realtime processes, and only cpu.uclamp.min and cpu.uclamp.max
+affect realtime processes.
 
   cpu.stat
 	A read-only flat-keyed file.
@@ -1115,6 +1117,9 @@ All time durations are in microseconds.
 	- nr_bursts
 	- burst_usec
 
+    The runtime of realtime processes is accounted for only by the usage_usec,
+	user_usec, and system_usec fields.
+
   cpu.weight
 	A read-write single value file which exists on non-root
 	cgroups.  The default is "100".
@@ -1158,8 +1163,9 @@ All time durations are in microseconds.
   cpu.pressure
 	A read-write nested-keyed file.
 
-	Shows pressure stall information for CPU. See
-	:ref:`Documentation/accounting/psi.rst <psi>` for details.
+	Shows pressure stall information for CPU, including the contribution of
+	realtime processes. See :ref:`Documentation/accounting/psi.rst <psi>`
+	for details.
 
   cpu.uclamp.min
         A read-write single value file which exists on non-root cgroups.
@@ -1170,7 +1176,8 @@ All time durations are in microseconds.
 
         This interface allows reading and setting minimum utilization clamp
         values similar to the sched_setattr(2). This minimum utilization
-        value is used to clamp the task specific minimum utilization clamp.
+        value is used to clamp the task specific minimum utilization clamp,
+        including those of realtime processes.
 
         The requested minimum utilization (protection) is always capped by
         the current value for the maximum utilization (limit), i.e.
@@ -1185,7 +1192,8 @@ All time durations are in microseconds.
 
         This interface allows reading and setting maximum utilization clamp
         values similar to the sched_setattr(2). This maximum utilization
-        value is used to clamp the task specific maximum utilization clamp.
+        value is used to clamp the task specific maximum utilization clamp,
+        including those of realtime processes.
 
   cpu.idle
 	A read-write single value file which exists on non-root cgroups.
Signature · 1 line
2.43.0
#6 lore raw

Re: [PATCH 2/2] cgroup, docs: Document interaction of RT processes with cpu controller

Quoted 29 lines · On 3/4/25 11:12 PM, Shashank Balaji via B4 Relay wrote:

From: Shashank Balaji <[email protected]>

If the cpu controller is enabled in a CONFIG_RT_GROUP_SCHED disabled setting, cpu.stat and cpu.pressure account for realtime processes, and cpu.uclamp.{min, max} affect realtime processes as well. None of the other interface files are affected by or affect realtime processes.

---
  Documentation/admin-guide/cgroup-v2.rst | 18 +++++++++++++-----
  1 file changed, 13 insertions(+), 5 deletions(-)
Documentation/admin-guide/cgroup-v2.rst +3 -1
index f293a13b42ed69e7c6bf5e974cb86e228411af4e..2c267f42e5fef9c4e2c3530ce73330d680b9b2dc 100644
@@ -1095,7 +1095,9 @@ realtime processes irrespective of CONFIG_RT_GROUP_SCHED.
  CPU Interface Files
  ~~~~~~~~~~~~~~~~~~~
 
-All time durations are in microseconds.
+All time durations are in microseconds. Only cpu.stat and cpu.pressure account
+for realtime processes, and only cpu.uclamp.min and cpu.uclamp.max
+affect realtime processes.
 
    cpu.stat
  	A read-only flat-keyed file.

Documentation/admin-guide/cgroup-v2.rst All time durations are in microseconds. · line 1122

Quoted 6 lines
Documentation/admin-guide/cgroup-v2.rst +3 -0
@@ -1115,6 +1117,9 @@ All time durations are in microseconds.
  	- nr_bursts
  	- burst_usec
 
+    The runtime of realtime processes is accounted for only by the usage_usec,
+	user_usec, and system_usec fields.
+

Alignment problem!

Anyway, I am not familiar enough with these cpu control files to give a review yet.

Cheers,
Longman

Quoted 36 lines
Documentation/admin-guide/cgroup-v2.rst +7 -4
    cpu.weight
  	A read-write single value file which exists on non-root
  	cgroups.  The default is "100".
@@ -1158,8 +1163,9 @@ All time durations are in microseconds.
    cpu.pressure
  	A read-write nested-keyed file.
 
-	Shows pressure stall information for CPU. See
-	:ref:`Documentation/accounting/psi.rst <psi>` for details.
+	Shows pressure stall information for CPU, including the contribution of
+	realtime processes. See :ref:`Documentation/accounting/psi.rst <psi>`
+	for details.
 
    cpu.uclamp.min
          A read-write single value file which exists on non-root cgroups.
@@ -1170,7 +1176,8 @@ All time durations are in microseconds.
 
          This interface allows reading and setting minimum utilization clamp
          values similar to the sched_setattr(2). This minimum utilization
-        value is used to clamp the task specific minimum utilization clamp.
+        value is used to clamp the task specific minimum utilization clamp,
+        including those of realtime processes.
 
          The requested minimum utilization (protection) is always capped by
          the current value for the maximum utilization (limit), i.e.
@@ -1185,7 +1192,8 @@ All time durations are in microseconds.
 
          This interface allows reading and setting maximum utilization clamp
          values similar to the sched_setattr(2). This maximum utilization
-        value is used to clamp the task specific maximum utilization clamp.
+        value is used to clamp the task specific maximum utilization clamp,
+        including those of realtime processes.
 
    cpu.idle
  	A read-write single value file which exists on non-root cgroups.
#7 lore raw

Re: [PATCH 2/2] cgroup, docs: Document interaction of RT processes with cpu controller

Hi Longman,

Quoted 38 lines
Quoted 29 lines

From: Shashank Balaji <[email protected]>

If the cpu controller is enabled in a CONFIG_RT_GROUP_SCHED disabled setting, cpu.stat and cpu.pressure account for realtime processes, and cpu.uclamp.{min, max} affect realtime processes as well. None of the other interface files are affected by or affect realtime processes.

---
  Documentation/admin-guide/cgroup-v2.rst | 18 +++++++++++++-----
  1 file changed, 13 insertions(+), 5 deletions(-)
Documentation/admin-guide/cgroup-v2.rst +3 -1
index f293a13b42ed69e7c6bf5e974cb86e228411af4e..2c267f42e5fef9c4e2c3530ce73330d680b9b2dc 100644
@@ -1095,7 +1095,9 @@ realtime processes irrespective of CONFIG_RT_GROUP_SCHED.
  CPU Interface Files
  ~~~~~~~~~~~~~~~~~~~
 
-All time durations are in microseconds.
+All time durations are in microseconds. Only cpu.stat and cpu.pressure account
+for realtime processes, and only cpu.uclamp.min and cpu.uclamp.max
+affect realtime processes.
 
    cpu.stat
  	A read-only flat-keyed file.

Documentation/admin-guide/cgroup-v2.rst All time durations are in microseconds. · line 1122

Quoted 6 lines
Documentation/admin-guide/cgroup-v2.rst +3 -0
@@ -1115,6 +1117,9 @@ All time durations are in microseconds.
  	- nr_bursts
  	- burst_usec
 
+    The runtime of realtime processes is accounted for only by the usage_usec,
+	user_usec, and system_usec fields.
+

Alignment problem!

Quoted 5 lines

Anyway, I am not familiar enough with these cpu control files to give a review yet.

Cheers,
Longman

My bad, I'll fix the alignment.

Thanks,
Shashank

maintainer
#8 lore raw

Re: [PATCH 2/2] cgroup, docs: Document interaction of RT processes with cpu controller

In reply to Shashank Balaji

Hello Shashank.

Quoted 7 lines · On Wed, Mar 05, 2025 at 01:12:44PM +0900, Shashank Balaji via B4 Relay…

From: Shashank Balaji <[email protected]>

If the cpu controller is enabled in a CONFIG_RT_GROUP_SCHED disabled setting, cpu.stat and cpu.pressure account for realtime processes, and cpu.uclamp.{min, max} affect realtime processes as well. None of the other interface files are affected by or affect realtime processes.

I'm not sure the changed formulation make it clearer.
What was the unexpected value with !CONFIG_RT_GROUP_SCHED that made you change this docs?

(Please note the docs is for generic cgroup, not only root cgroup.)

Michal

#9 lore raw

Re: [PATCH 2/2] cgroup, docs: Document interaction of RT processes with cpu controller

Hi Michal,

Quoted 11 lines

Hello Shashank.

Quoted 7 lines · On Wed, Mar 05, 2025 at 01:12:44PM +0900, Shashank Balaji via B4 Relay…

From: Shashank Balaji <[email protected]>

If the cpu controller is enabled in a CONFIG_RT_GROUP_SCHED disabled setting, cpu.stat and cpu.pressure account for realtime processes, and cpu.uclamp.{min, max} affect realtime processes as well. None of the other interface files are affected by or affect realtime processes.

Quoted 5 lines

I'm not sure the changed formulation make it clearer.
What was the unexpected value with !CONFIG_RT_GROUP_SCHED that made you change this docs?

(Please note the docs is for generic cgroup, not only root cgroup.)

The documentation covers what happens when CONFIG_RT_GROUP_SCHED is enabled, i.e. all the realtime processes have to be in the root cgroup for the cpu controller to be enabled. But what is not documented is how realtime processes are treated with !CONFIG_RT_GROUP_SCHED. Initially I was under the impression "oh, the other interface files seem to affect only processes under the fair class scheduler, so maybe they don't affect realtime processes". But on further digging, I found that cpu.stat and cpu.pressure account for realtime processes, and cpu.uclamp.{min, max} affect realtime processes as well.

Do you think it should be rephrased to make it clearer?

Thanks,
Shashank

maintainer
#10 lore raw

Re: [PATCH 2/2] cgroup, docs: Document interaction of RT processes with cpu controller

Quoted 1 line · On Thu, Mar 06, 2025 at 11:02:22AM +0000, "[email protected]"…

Do you think it should be rephrased to make it clearer?

Aha, I understand now why it confused you (with the paragraph about realtime tasks right above interface files).

I'd consider such a minimal correction:

Documentation/admin-guide/cgroup-v2.rst +1 -1
@@ -1076,7 +1076,7 @@ cpufreq governor about the minimum desired frequency which should always be
 provided by a CPU, as well as the maximum desired frequency, which should not
 be exceeded by a CPU.
 
-WARNING: cgroup2 doesn't yet support control of realtime processes. For
+WARNING: cgroup2 doesn't yet support (bandwidth) control of realtime processes. For
 a kernel built with the CONFIG_RT_GROUP_SCHED option enabled for group
 scheduling of realtime processes, the cpu controller can only be enabled
 when all RT processes are in the root cgroup.  This limitation does

Of course wordier rewrite is possible but I find the text as you originally proposed unclear due to several uses of "only" that imply restrictions that aren't in place in reality.

Thanks,
Michal

#11 lore raw

Re: [PATCH 2/2] cgroup, docs: Document interaction of RT processes with cpu controller

Hi Michal,

Apologies for the delay :)

Quoted 16 lines · On Thu, Mar 06, 2025 at 11:02:22AM +0000, "[email protected]"…
Quoted 1 line

Do you think it should be rephrased to make it clearer?

Aha, I understand now why it confused you (with the paragraph about realtime tasks right above interface files).

I'd consider such a minimal correction:

Documentation/admin-guide/cgroup-v2.rst +0 -0
@@ -1076,7 +1076,7 @@ cpufreq governor about the minimum desired frequency which should always be

 provided by a CPU, as well as the maximum desired frequency, which should not be exceeded by a CPU.

Documentation/admin-guide/cgroup-v2.rst +1 -1
-WARNING: cgroup2 doesn't yet support control of realtime processes. For
+WARNING: cgroup2 doesn't yet support (bandwidth) control of realtime processes. For
Quoted 3 lines

 a kernel built with the CONFIG_RT_GROUP_SCHED option enabled for group scheduling of realtime processes, the cpu controller can only be enabled when all RT processes are in the root cgroup.  This limitation does

I'll incorporate this in v2. Thanks!

Quoted 3 lines

Of course wordier rewrite is possible but I find the text as you originally proposed unclear due to several uses of "only" that imply restrictions that aren't in place in reality.

Given the different scheduling classes (fair, ext, rt, deadline), it would be nice to document which cpu interface files are related to which scheduling classes. Like, cpu.idle applies to only the fair class, cpu.weight applies to the fair class, as well as ext, if configured so, cpu.stat accounts for all classes (I'm not sure about this, I haven't tested this yet), etc.

The proposed patch is in this direction, but just for the rt class. Any suggestions on how this intent can be made clearer? How about something like this:

CPU Interface Files
~~~~~~~~~~~~~~~~~~~

All time durations are in microseconds. The scheduling classes mentioned beside the interface files are the only classes they are related to.

  cpu.stat    (fair, ext, rt, deadline)
    ...

  cpu.weight    (fair, ext)
    ...

  cpu.weight.nice    (fair, ext)
    ...

  cpu.max    (fair)
    ...

  cpu.max.burst    (fair)
    ...

  cpu.pressure    (fair, ext, rt, deadline)
    ...

  cpu.uclamp.min    (fair, rt)
    ...

  cpu.uclamp.max    (fair, rt)
    ...

  cpu.idle    (fair)

Thanks,
Shashank

maintainer
#12 lore raw

Re: [PATCH 2/2] cgroup, docs: Document interaction of RT processes with cpu controller

Hello.

Quoted 8 lines · On Fri, Mar 28, 2025 at 10:45:02AM +0000, "[email protected]"…

Given the different scheduling classes (fair, ext, rt, deadline), it would be nice to document which cpu interface files are related to which scheduling classes. Like, cpu.idle applies to only the fair class, cpu.weight applies to the fair class, as well as ext, if configured so, cpu.stat accounts for all classes (I'm not sure about this, I haven't tested this yet), etc.

The proposed patch is in this direction, but just for the rt class. Any suggestions on how this intent can be made clearer? How about something like this:

Classes are implementation terminology but userspace knows this under scheduling policies (SCHED_NORMAL,..., SCHED_EXT). It might be better to use that categories.

Quoted 6 lines

CPU Interface Files
~~~~~~~~~~~~~~~~~~~

All time durations are in microseconds. The scheduling classes mentioned beside the interface files are the only classes they are related to.

list of related <categories> is only indicative as implementation may change

(Even when talking about policies I think the relation still tends to be an implementation detail, so I'd also add something like the above. But I think it's good to have such an overview to know what is where implemented.)

HTH,
Michal