Skip to contentSkip to conversation

In cgroup v2, setting a smaller value for sched_rt_runtime_us fails.

PATCH In review Chen Jinghuang 1 participant 2 messages Jun 25 – Jul 1 Scheduler

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 In cgroup v2, setting a smaller value for sched_rt_runtime_us fails.

For example:

	# cat /proc/sys/kernel/sched_rt_runtime_us
	950000
	# echo 940000 > /proc/sys/kernel/sched_rt_runtime_us
	-bash: echo: write error: Invalid argument

With CONFIG_RT_GROUP_SCHED enabled, reducing the global RT quota causes the unchanged root cgroup quota to exceed the new global limit. The root cgroup quota should be updated accordingly when the global quota changes.

Adjust the root cgroup's RT quota whenever the global RT quota is modified.

---
Change since v1: https://lore.kernel.org/all/[email protected]/
- Rebase the patch onto mainline.

---
 kernel/sched/rt.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
kernel/sched/rt.c +4 -1
index e474c31d8fe6..b1b082e365af 100644
@@ -2858,9 +2858,12 @@ static int sched_rt_global_validate(void)
 #ifdef CONFIG_RT_GROUP_SCHED
 	if (!rt_group_sched_enabled())
 		return 0;
+	
+	u64 period = global_rt_period();
+	u64 runtime = global_rt_runtime();
 
 	scoped_guard(mutex, &rt_constraints_mutex)
-		return __rt_schedulable(NULL, 0, 0);
+		return __rt_schedulable(&root_task_group, period, runtime);
 #endif
 	return 0;
 }
Signature · 1 line
2.34.1
#1 lore raw
Quoted 6 lines · Chen Jinghuang

For example:

	# cat /proc/sys/kernel/sched_rt_runtime_us
	950000
	# echo 940000 > /proc/sys/kernel/sched_rt_runtime_us
	-bash: echo: write error: Invalid argument

Sorry, I forgot that sched_rt_runtime_us is currently set to 1000000, so it should be the following case:

# cat /proc/sys/kernel/sched_rt_runtime_us
1000000
# echo 940000 > /proc/sys/kernel/sched_rt_runtime_us
-bash: echo: write error: Invalid argument
Quoted 26 lines

With CONFIG_RT_GROUP_SCHED enabled, reducing the global RT quota causes the unchanged root cgroup quota to exceed the new global limit. The root cgroup quota should be updated accordingly when the global quota changes.

Adjust the root cgroup's RT quota whenever the global RT quota is modified.

---
Change since v1: https://lore.kernel.org/all/[email protected]/
- Rebase the patch onto mainline.

---
 kernel/sched/rt.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
kernel/sched/rt.c +0 -0
index e474c31d8fe6..b1b082e365af 100644
@@ -2858,9 +2858,12 @@ static int sched_rt_global_validate(void)
 #ifdef CONFIG_RT_GROUP_SCHED
 	if (!rt_group_sched_enabled())
 		return 0;

kernel/sched/rt.c static int sched_rt_global_validate(void) · line 2869

Quoted 10 lines
kernel/sched/rt.c +4 -1
+	
+	u64 period = global_rt_period();
+	u64 runtime = global_rt_runtime();
 
 	scoped_guard(mutex, &rt_constraints_mutex)
-		return __rt_schedulable(NULL, 0, 0);
+		return __rt_schedulable(&root_task_group, period, runtime);
 #endif
 	return 0;
 }

Gently ping!