Skip to contentSkip to conversation

sched: RT throttling cleanup and a bit of documentation

PATCH In review Sebastian Andrzej Siewior 3 participants 21 messages Nov 23 – Nov 24

Subsystems (5)
Documentation arm64 Scheduler cgroup +1 more subsystems
lore
Share & tools
lore
#0 lore raw

v4 cover sched: RT throttling cleanup and a bit of documentation

People used to disable the RT throttling mechanism by writing -1 to /proc/sys/kernel/sched_rt_runtime_us. Since v6.12 they can still do this but they don't disable RT throttling anymore. Instead this throttling mechanism has been taken over by the fair_server which can be configured via debugfs.
This is not really documented but a hint appeared a few cycles later in Documentation/scheduler/sched-rt-group.rst. This can be found once you know what you are looking for because this document describes the RT group scheduling (CONFIG_RT_GROUP_SCHED). The fair_server is used even without it.
The then there is global DL resource control which also shares this file proc file (which is stuck if CONFIG_RT_GROUP_SCHED is enabled).

This little series:
- Marks CONFIG_RT_GROUP_SCHED as broken because I was not allowed to remove it.

- Untangles DL usage of sched_rt_runtime_us and moves it to /sys/kernel/sched/dl_period_us /sys/kernel/sched/dl_runtime_us

This keeps the _us semantic that we used to have /proc. It _could_ be changed to ns instead.
The updates to the proc interface are mirrored to the /sys interface and produce warning on the first write without CONFIG_RT_GROUP_SCHED enabled.

- rcutorture is not touched anymore. Joel Fernandes is working on it. The rcutorture can be fixed independently since the sysctl variables are no longer removed.

- Adds sysfs interface under /sys/kernel/sched/cpuX to represent the runqueues. The only knob for now is fair_server_{period|runtime} representing the fair_server parameters. If all goes well, debugfs could be removed. The ext server could be moved, too.

- I tried to correct/ update documentation while at it. I added the -doc folks on Cc so they are aware. I can drop them in the next posting, I expect that this gets routed via the sched/-tip.

v3…v4: https://patch.msgid.link/[email protected]
- Drop the cpu_active() verification for DL admission control updates. Mathieu is working on getting it to work so I preserve it and don't touch it.

- Drop the RCU-torture changes. Joel is reworking it so it no longer needs to disable the RT-throttling (or the fair_server now).

- The proc/ sysctl knobs are not removed. Update to the sysctl interface are mirror to the sysfs admission control but not the other way around. An update to the sysctl interface without CONFIG_RT_GROUP_SCHED enabled will print a warning.
LTP was complaining about the removal. On the other hand it was just complaining that writting -2 to runtime resulted in EBADF instead EINVAL. So…

v2…v3: https://patch.msgid.link/[email protected]
- Corrected in wording sched-rt-group.rst (Pointed out by Randy)
- RCU-torture now disables the fair_server from its boost-thread. The code expects the CPU to be active which is after the CPU-hotplug notifier is run. An alternative would be to not start the fair_server (in the RCU-torture built-in case).
- sched_dl_try_boundary() has now a private mutex to perform the update. sashiko complains that the values are read outside of sched_domains_mutex and written back while it is held, making it possible to write stale period/ runtime values back.
- proper u64 casting for NSEC_PER_USEC multiplication.
- sysfs_dl_runtime is not static and accessed in dl_bandwidth_enabled(). This was missed earlier.
The remaining sysctl_sched_rt_{runtime|period} are now also hidden behind CONFIG_RT_GROUP_SCHED.

v1…v2: https://lore.kernel.org/all/[email protected]/
- Tejun and PeterZ asked for marking CONFIG_RT_GROUP_SCHED broken first.
- Everything after patch #1 that got queued up.

RFC…v1: https://lore.kernel.org/all/[email protected]/
- Try to remove RT-GROUP-sched after figuring out that it is useless.

---
Sebastian Andrzej Siewior (6):
sched: Mark RT_GROUP_SCHED broken
sched: Move DL's admission control to sysfs
sched: Add sysfs files for the per-CPU fair_server knobs
sched: Limit sysctl sched_rt_{period|runtime}_us to RT_GROUP_SCHED Documentation/sched: Drop the section enumeration in sched-deadline Documentation/sched: Add fairserver to sched-deadline

 Documentation/arch/arm64/asymmetric-32bit.rst |   2 +-
 Documentation/scheduler/sched-deadline.rst    | 149 ++++++------
 Documentation/scheduler/sched-rt-group.rst    |   7 +-
 init/Kconfig                                  |   2 +-
 kernel/sched/deadline.c                       | 312 +++++++++++++++++++++++++-
 kernel/sched/debug.c                          |  56 +----
 kernel/sched/features.h                       |   2 +
 kernel/sched/rt.c                             |  27 +--
 kernel/sched/sched.h                          |  65 +++---
 9 files changed, 432 insertions(+), 190 deletions(-)

---
base-commit: a4d7daea71be591034445c17d4d81132a1785a12
change-id: 20261110-sched_dl-a9727787112f

Best regards,

Signature · 1 line
Sebastian Andrzej Siewior <[email protected]>
#1 lore raw

PATCH v4 1/6 sched: Mark RT_GROUP_SCHED broken

The RT_GROUP_SCHED is broken beyond repair and it is best to not enable it during compile. If enabled it is recommended to disable it at boot time with the rt_group_sched= option.
With it enabled it is not possible to set the policy of a task to SCHED_{FIFO|RR} because its cgroup has no runtime assigned. The runtime can not be assigned with cgroup v2. The root group has however all the runtime assigned meaning the global sysctl runtime parameter (sched_rt_runtime_us) can no be reduced because the new bandwidth will be less than what is current available.
It is possible to schedule SCHED_DEADLINE tasks but the admission control is stuck can only be disabled via -1 (same sysctl parameter).

As a result all major distors (Debian, Open Suse, Fedora, Archlinux) have it disabled.

There is work on Hierarchical constant bandwidth server (HCBS) which aim to group multiple real-time tasks within one deadline configuration.

Mark CONFIG_RT_GROUP_SCHED broken. Move code which is not under RT_GROUP_SCHED but only used by it within its IFDEF section. This includes also RT_RUNTIME_SHARE.
Update the documentation, to state that it is not related to real-time tasks in general but only to RT-group scheduling. While at it, also update the current defaults.

---
 Documentation/scheduler/sched-rt-group.rst |  7 ++++++-
 init/Kconfig                               |  2 +-
 kernel/sched/features.h                    |  2 ++
 kernel/sched/rt.c                          |  6 ------
 kernel/sched/sched.h                       | 19 +++++++++++--------
 5 files changed, 20 insertions(+), 16 deletions(-)
Documentation/scheduler/sched-rt-group.rst +6 -1
index ab464335d3204..cd69c93baeb6a 100644
@@ -18,6 +18,11 @@ Real-Time group scheduling
 0. WARNING
 ==========
 
+ This document applies to RT group scheduling provided by CONFIG_RT_GROUP_SCHED.
+ If you don't use RT-group scheduling, schedule real-time tasks and experience
+ throttling issues please look into Documentation/scheduler/sched-deadline.rst
+ for the fair_server.
+
  Fiddling with these settings can result in an unstable system, the knobs are
  root only and assumes root knows what he is doing.
 
@@ -111,7 +116,7 @@ lack an EDF scheduler to make non-uniform periods usable.
 ---------------------
 
 The default values for sched_rt_period_us (1000000 or 1s) and
-sched_rt_runtime_us (950000 or 0.95s).  This gives 0.05s to be used by
+sched_rt_runtime_us (1000000 or 1s).  This gives 0s to be used by
 SCHED_OTHER (non-RT tasks). These defaults were chosen so that a run-away
 real-time tasks will not lock up the machine but leave a little time to recover
 it.  By setting runtime to -1 you'd get the old behaviour back.
init/Kconfig +1 -1
index c8a7cfa60a6ea..4c00c02aa1c14 100644
@@ -981,7 +981,7 @@ config CFS_BANDWIDTH
 
 config RT_GROUP_SCHED
 	bool "Group scheduling for SCHED_RR/FIFO"
-	depends on CGROUP_SCHED
+	depends on CGROUP_SCHED && BROKEN
 	default n
 	help
 	  This feature lets you explicitly allocate real CPU bandwidth
kernel/sched/features.h +2 -0
index 8f0dee8fc4755..acc1c3fdfe2a2 100644
@@ -122,7 +122,9 @@ SCHED_FEAT(RT_PUSH_IPI, false)
 # endif
 #endif
 
+#ifdef CONFIG_RT_GROUP_SCHED
 SCHED_FEAT(RT_RUNTIME_SHARE, false)
+#endif
 SCHED_FEAT(LB_MIN, false)
 SCHED_FEAT(ATTACH_AGE_LOAD, true)
 
kernel/sched/rt.c +0 -6
index 1535046a23ffa..cdeddd3fc9af2 100644
@@ -944,12 +944,6 @@ static inline const struct cpumask *sched_rt_period_mask(void)
 	return cpu_online_mask;
 }
 
-static inline
-struct rt_rq *sched_rt_period_rt_rq(struct rt_bandwidth *rt_b, int cpu)
-{
-	return &cpu_rq(cpu)->rt;
-}
-
 static void __enable_runtime(struct rq *rq) { }
 static void __disable_runtime(struct rq *rq) { }
 
kernel/sched/sched.h +11 -8
index a4e6696e3a516..4d4128d5600f3 100644
@@ -313,6 +313,7 @@ struct rt_prio_array {
 	struct list_head queue[MAX_RT_PRIO];
 };
 
+#ifdef CONFIG_RT_GROUP_SCHED
 struct rt_bandwidth {
 	/* nests inside the rq lock: */
 	raw_spinlock_t		rt_runtime_lock;
@@ -321,6 +322,7 @@ struct rt_bandwidth {
 	struct hrtimer		rt_period_timer;
 	unsigned int		rt_period_active;
 };
+#endif
 
 static inline int dl_bandwidth_enabled(void)
 {
@@ -581,6 +583,7 @@ extern void start_cfs_bandwidth(struct cfs_bandwidth *cfs_b);
 extern void unthrottle_cfs_rq(struct cfs_rq *cfs_rq);
 extern bool cfs_task_bw_constrained(struct task_struct *p);
 
+#ifdef CONFIG_RT_GROUP_SCHED
 extern void init_tg_rt_entry(struct task_group *tg, struct rt_rq *rt_rq,
 		struct sched_rt_entity *rt_se, int cpu,
 		struct sched_rt_entity *parent);
@@ -589,6 +592,14 @@ extern int sched_group_set_rt_period(struct task_group *tg, u64 rt_period_us);
 extern long sched_group_rt_runtime(struct task_group *tg);
 extern long sched_group_rt_period(struct task_group *tg);
 extern int sched_rt_can_attach(struct task_group *tg, struct task_struct *tsk);
+extern void init_rt_bandwidth(struct rt_bandwidth *rt_b, u64 period, u64 runtime);
+extern bool sched_rt_bandwidth_account(struct rt_rq *rt_rq);
+
+static inline int rt_bandwidth_enabled(void)
+{
+	return sysctl_sched_rt_runtime >= 0;
+}
+#endif
 
 extern struct task_group *sched_create_group(struct task_group *parent);
 extern void sched_online_group(struct task_group *tg,
@@ -877,11 +888,6 @@ struct scx_rq {
 };
 #endif /* CONFIG_SCHED_CLASS_EXT */
 
-static inline int rt_bandwidth_enabled(void)
-{
-	return sysctl_sched_rt_runtime >= 0;
-}
-
 /* RT IPI pull logic requires IRQ_WORK */
 #if defined(CONFIG_IRQ_WORK) && defined(CONFIG_SMP)
 # define HAVE_RT_PUSH_IPI
@@ -3076,9 +3082,6 @@ extern void resched_curr(struct rq *rq);
 extern void resched_curr_lazy(struct rq *rq);
 extern void resched_cpu(int cpu);
 
-extern void init_rt_bandwidth(struct rt_bandwidth *rt_b, u64 period, u64 runtime);
-extern bool sched_rt_bandwidth_account(struct rt_rq *rt_rq);
-
 extern void init_dl_entity(struct sched_dl_entity *dl_se);
 
 extern void init_cfs_throttle_work(struct task_struct *p);
Signature · 1 line
2.55.0
#2 lore raw

PATCH v4 2/6 sched: Move DL's admission control to sysfs

In reply to Sebastian Andrzej Siewior

SCHED_DL uses the sysctl sched_rt_{period|runtime}_us to configure its admission control. It is used to verify that it does not allocate more time globally to SCHED_DL tasks than it can theoretically handle.

This sysctl used to control RT throttling. With the introduction of the DL server this knob controls RT throttling within a RT-cgroup if CONFIG_RT_GROUP_SCHED is enabled. In this case the knob is also stuck and can not be changed. So it can not be used for SCHED_DL control at all. Unless to disable it by writing -1.

Split the DL bits into its knob at sysfs' location. Once the DL logic is out, sched_domains_mutex.*() and rebuild_sched_domains() can be removed from sched_rt_handler().

Move SCHED_DL usage of this sysctl to /sys/kernel/sched/ as dl_runtime_us + dl_period_us. Replace global_rt_period()/ global_rt_runtime() with sysfs_dl_period/ sysfs_dl_runtime. Store the new attributes in ns. Move global_rt_period()/ global_rt_runtime() to CONFIG_RT_GROUP_SCHED.
Preserve compatibility for DL-admission update via the proc interface.

---
 Documentation/arch/arm64/asymmetric-32bit.rst |   2 +-
 Documentation/scheduler/sched-deadline.rst    |  23 ++--
 kernel/sched/deadline.c                       | 162 ++++++++++++++++++++++++--
 kernel/sched/rt.c                             |  13 +--
 kernel/sched/sched.h                          |  33 +++---
 5 files changed, 179 insertions(+), 54 deletions(-)
Documentation/arch/arm64/asymmetric-32bit.rst +1 -1
index fc0c350c5e001..375958f8971e5 100644
@@ -105,7 +105,7 @@ affinity for the task is updated and any saved mask from a prior
 Explicit admission of a 32-bit deadline task to the default root domain
 (e.g. by calling ``sched_setattr(2)``) is rejected on an asymmetric
 32-bit system unless admission control is disabled by writing -1 to
-``/proc/sys/kernel/sched_rt_runtime_us``.
+``/sys/kernel/sched/dl_runtime_us``.
 
 ``execve(2)`` of a 32-bit program from a 64-bit deadline task will
 return ``-ENOEXEC`` if the root domain for the task contains any
Documentation/scheduler/sched-deadline.rst +9 -14
index 9019b66f6a5ba..4441bb689cca1 100644
@@ -590,24 +590,19 @@ Deadline Task Scheduling
 4.1 System wide settings
 ------------------------
 
- The system wide settings are configured under the /proc virtual file system.
+ The system wide settings are configured under /sys/kernel/sched.
 
- For now the -rt knobs are used for -deadline admission control and with
- CONFIG_RT_GROUP_SCHED the -deadline runtime is accounted against the (root)
- -rt runtime. With !CONFIG_RT_GROUP_SCHED the knob only serves for the -dl
- admission control. We realize that this isn't entirely desirable; however, it
- is better to have a small interface for now, and be able to change it easily
- later. The ideal situation (see 5.) is to run -rt tasks from a -deadline
- server; in which case the -rt bandwidth is a direct subset of dl_bw.
+ The ideal situation (see 5.) is to run -rt tasks from a -deadline server; in
+ which case the -rt bandwidth is a direct subset of dl_bw.
 
  This means that, for a root_domain comprising M CPUs, -deadline tasks
  can be created while the sum of their bandwidths stays below:
 
-   M * (sched_rt_runtime_us / sched_rt_period_us)
+   M * (dl_runtime_us / dl_period_us)
 
  It is also possible to disable this bandwidth management logic, and
  be thus free of oversubscribing the system up to any arbitrary level.
- This is done by writing -1 in /proc/sys/kernel/sched_rt_runtime_us.
+ This is done by writing -1 in /sys/kernel/sched/dl_runtime_us.
 
 
 4.2 Task interface
@@ -648,11 +643,11 @@ Deadline Task Scheduling
 4.3 Default behavior
 ---------------------
 
- The default value for SCHED_DEADLINE bandwidth is to have rt_runtime equal to
- 950000. With rt_period equal to 1000000, by default, it means that -deadline
- tasks can use at most 95%, multiplied by the number of CPUs that compose the
+ The default value for SCHED_DEADLINE bandwidth is to have dl_runtime_us equal to
+ 1000000. With rt_period equal to 1000000, by default, it means that -deadline
+ tasks can use at most 100%, multiplied by the number of CPUs that compose the
  root_domain, for each root_domain.
- This means that non -deadline tasks will receive at least 5% of the CPU time,
+ This means that non -deadline tasks will receive at least 0% of the CPU time,
  and that -deadline tasks will receive their runtime with a guaranteed
  worst-case delay respect to the "deadline" parameter. If "deadline" = "period"
  and the cpuset mechanism is used to implement partitioned scheduling (see
kernel/sched/deadline.c +150 -12

205 lines not on this page · raw message

kernel/sched/rt.c +2 -11
index cdeddd3fc9af2..bd37dbf2bebbe 100644
@@ -2871,7 +2871,6 @@ static int sched_rt_handler(const struct ctl_table *table, int write, void *buff
 	int ret;
 
 	mutex_lock(&mutex);
-	sched_domains_mutex_lock();
 	old_period = sysctl_sched_rt_period;
 	old_runtime = sysctl_sched_rt_runtime;
 
@@ -2882,26 +2881,18 @@ static int sched_rt_handler(const struct ctl_table *table, int write, void *buff
 		if (ret)
 			goto undo;
 
-		ret = sched_dl_global_validate();
+		ret = sched_dl_try_boundary(sysctl_sched_rt_runtime,
+					    sysctl_sched_rt_period);
 		if (ret)
 			goto undo;
-
-		sched_dl_do_global();
 	}
 	if (0) {
 undo:
 		sysctl_sched_rt_period = old_period;
 		sysctl_sched_rt_runtime = old_runtime;
 	}
-	sched_domains_mutex_unlock();
 	mutex_unlock(&mutex);
 
-	/*
-	 * After changing maximum available bandwidth for DEADLINE, we need to
-	 * recompute per root domain and per cpus variables accordingly.
-	 */
-	rebuild_sched_domains();
-
 	return ret;
 }
 
kernel/sched/sched.h +17 -16
index 4d4128d5600f3..e755572f1cbb1 100644
@@ -109,6 +109,7 @@ extern long calc_load_fold_active(struct rq *this_rq, long adjust);
 
 extern void call_trace_sched_update_nr_running(struct rq *rq, int count);
 
+extern u64 sysfs_dl_runtime;
 extern int sysctl_sched_rt_period;
 extern int sysctl_sched_rt_runtime;
 extern int sched_rr_timeslice;
@@ -326,7 +327,7 @@ struct rt_bandwidth {
 
 static inline int dl_bandwidth_enabled(void)
 {
-	return sysctl_sched_rt_runtime >= 0;
+	return sysfs_dl_runtime >= 0 && sysfs_dl_runtime != RUNTIME_INF;
 }
 
 /*
@@ -354,8 +355,6 @@ struct dl_bw {
 };
 
 extern void init_dl_bw(struct dl_bw *dl_b);
-extern int  sched_dl_global_validate(void);
-extern void sched_dl_do_global(void);
 extern int  sched_dl_overflow(struct task_struct *p, int policy, const struct sched_attr *attr);
 extern void __setparam_dl(struct task_struct *p, const struct sched_attr *attr);
 extern void __getparam_dl(struct task_struct *p, struct sched_attr *attr, unsigned int flags);
@@ -364,6 +363,8 @@ extern bool dl_param_changed(struct task_struct *p, const struct sched_attr *att
 extern int  dl_cpuset_cpumask_can_shrink(const struct cpumask *cur, const struct cpumask *trial);
 extern int  dl_bw_deactivate(int cpu);
 extern s64 dl_scaled_delta_exec(struct rq *rq, struct sched_dl_entity *dl_se, s64 delta_exec);
+extern int sched_dl_try_boundary(int runtime, int period);
+
 /*
  * SCHED_DEADLINE supports servers (nested scheduling) with the following
  * interface:
@@ -599,6 +600,19 @@ static inline int rt_bandwidth_enabled(void)
 {
 	return sysctl_sched_rt_runtime >= 0;
 }
+
+static inline u64 global_rt_period(void)
+{
+	return (u64)sysctl_sched_rt_period * NSEC_PER_USEC;
+}
+
+static inline u64 global_rt_runtime(void)
+{
+	if (sysctl_sched_rt_runtime < 0)
+		return RUNTIME_INF;
+
+	return (u64)sysctl_sched_rt_runtime * NSEC_PER_USEC;
+}
 #endif
 
 extern struct task_group *sched_create_group(struct task_group *parent);
@@ -2532,19 +2546,6 @@ extern union sched_feat_key sched_feat_keys[__SCHED_FEAT_NR];
 extern struct static_key_false sched_numa_balancing;
 extern struct static_key_false sched_schedstats;
 
-static inline u64 global_rt_period(void)
-{
-	return (u64)sysctl_sched_rt_period * NSEC_PER_USEC;
-}
-
-static inline u64 global_rt_runtime(void)
-{
-	if (sysctl_sched_rt_runtime < 0)
-		return RUNTIME_INF;
-
-	return (u64)sysctl_sched_rt_runtime * NSEC_PER_USEC;
-}
-
 /*
  * Is p the current execution context?
  */
Signature · 1 line
2.55.0
maintainer
#3 lore raw

Re: [PATCH v4 2/6] sched: Move DL's admission control to sysfs

Hello,

On 23/11/26 14:41, Sebastian Andrzej Siewior wrote:

...

kernel/sched/rt.c static int sched_rt_handler(const struct ctl_table *table, int write, void *buff · line 2889

Quoted 11 lines
kernel/sched/rt.c +2 -3
@@ -2882,26 +2881,18 @@ static int sched_rt_handler(const struct ctl_table *table, int write, void *buff
 		if (ret)
 			goto undo;
 
-		ret = sched_dl_global_validate();
+		ret = sched_dl_try_boundary(sysctl_sched_rt_runtime,
+					    sysctl_sched_rt_period);
 		if (ret)
 			goto undo;
-
-		sched_dl_do_global();

Nothing updates sysctl_sched_rt_{period,runtime} when the sysfs files are written, but this always passes both, so a procfs write of one knob resets the other to its stale sysctl value? E.g. write 2000000 to dl_period_us, then -1 to sched_rt_runtime_us: admission control is disabled as expected, but sysctl_sched_rt_period is still 1000000 and the period is back to 1s.

Thanks,
Juri

#4 lore raw

Re: [PATCH v4 2/6] sched: Move DL's admission control to sysfs

Quoted 1 line · Juri Lelli

Hello,

Hi,

Quoted 8 lines · Sebastian Andrzej Siewior

...

Quoted 4 lines
kernel/sched/rt.c +0 -0
@@ -2882,26 +2881,18 @@ static int sched_rt_handler(const struct ctl_table *table, int write, void *buff
 		if (ret)
 			goto undo;
 
Quoted 14 lines

kernel/sched/rt.c static int sched_rt_handler(const struct ctl_table *table, int write, void *buff · line 2889

Quoted 7 lines
kernel/sched/rt.c +2 -3
-		ret = sched_dl_global_validate();
+		ret = sched_dl_try_boundary(sysctl_sched_rt_runtime,
+					    sysctl_sched_rt_period);
 		if (ret)
 			goto undo;
-
-		sched_dl_do_global();

Nothing updates sysctl_sched_rt_{period,runtime} when the sysfs files are written, but this always passes both, so a procfs write of one knob resets the other to its stale sysctl value? E.g. write 2000000 to dl_period_us, then -1 to sched_rt_runtime_us: admission control is disabled as expected, but sysctl_sched_rt_period is still 1000000 and the period is back to 1s.

You want this working both ways?
I assumed you use the proc interface because you don't know better. The warning makes you aware that the throttling knobs and DL knobs moved to sysfs. The DL bits are mirror to the sysfs interface in case you ignore the warning and keep using proc.
If you move to using sysfs then everything is fine. From here, going back to proc looks odd.
I could look into making the sysfs values appear in proc, too.

Quoted 2 lines

Thanks,
Juri

Sebastian

maintainer
#5 lore raw

Re: [PATCH v4 2/6] sched: Move DL's admission control to sysfs

Quoted 28 lines · Sebastian Andrzej Siewior
Quoted 1 line · Juri Lelli

Hello,

Hi,

Quoted 8 lines · Sebastian Andrzej Siewior

...

Quoted 4 lines
kernel/sched/rt.c +0 -0
@@ -2882,26 +2881,18 @@ static int sched_rt_handler(const struct ctl_table *table, int write, void *buff
 		if (ret)
 			goto undo;
 
Quoted 14 lines

kernel/sched/rt.c static int sched_rt_handler(const struct ctl_table *table, int write, void *buff · line 2889

Quoted 7 lines
kernel/sched/rt.c +2 -3
-		ret = sched_dl_global_validate();
+		ret = sched_dl_try_boundary(sysctl_sched_rt_runtime,
+					    sysctl_sched_rt_period);
 		if (ret)
 			goto undo;
-
-		sched_dl_do_global();

Nothing updates sysctl_sched_rt_{period,runtime} when the sysfs files are written, but this always passes both, so a procfs write of one knob resets the other to its stale sysctl value? E.g. write 2000000 to dl_period_us, then -1 to sched_rt_runtime_us: admission control is disabled as expected, but sysctl_sched_rt_period is still 1000000 and the period is back to 1s.

Quoted 1 line

You want this working both ways?

Want is definitely too strong of a word. :)

Quoted 6 lines

I assumed you use the proc interface because you don't know better. The warning makes you aware that the throttling knobs and DL knobs moved to sysfs. The DL bits are mirror to the sysfs interface in case you ignore the warning and keep using proc.
If you move to using sysfs then everything is fine. From here, going back to proc looks odd.

Odd indeed, but I wondered if it might happen that a sysadmin configures things properly using the new interface and some time later, say, an old application that hasn't switched yet to the new interface resets/tweaks using the old interface?

#6 lore raw

Re: [PATCH v4 2/6] sched: Move DL's admission control to sysfs

Quoted 10 lines · Juri Lelli
Quoted 8 lines
Quoted 6 lines

Nothing updates sysctl_sched_rt_{period,runtime} when the sysfs files are written, but this always passes both, so a procfs write of one knob resets the other to its stale sysctl value? E.g. write 2000000 to dl_period_us, then -1 to sched_rt_runtime_us: admission control is disabled as expected, but sysctl_sched_rt_period is still 1000000 and the period is back to 1s.

You want this working both ways?

Want is definitely too strong of a word. :)

:)

Quoted 11 lines
Quoted 6 lines

I assumed you use the proc interface because you don't know better. The warning makes you aware that the throttling knobs and DL knobs moved to sysfs. The DL bits are mirror to the sysfs interface in case you ignore the warning and keep using proc.
If you move to using sysfs then everything is fine. From here, going back to proc looks odd.

Odd indeed, but I wondered if it might happen that a sysadmin configures things properly using the new interface and some time later, say, an old application that hasn't switched yet to the new interface resets/tweaks using the old interface?

Therefore I wanted to remove the old interface. The legitime users would want to change the default DL attributes. I am more afraid of those that intend to disable RT throttling and are failing to do so.

We could also make the proc interface return -EINVAL on read/ write once the sysfs was used. What about it?

Sebastian

maintainer
#7 lore raw

Re: [PATCH v4 2/6] sched: Move DL's admission control to sysfs

Quoted 1 line · Sebastian Andrzej Siewior

On 2026-11-24 10:57:54 [+0100], Juri Lelli wrote:

...

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

I assumed you use the proc interface because you don't know better. The warning makes you aware that the throttling knobs and DL knobs moved to sysfs. The DL bits are mirror to the sysfs interface in case you ignore the warning and keep using proc.
If you move to using sysfs then everything is fine. From here, going back to proc looks odd.

Quoted 8 lines
Quoted 4 lines

Odd indeed, but I wondered if it might happen that a sysadmin configures things properly using the new interface and some time later, say, an old application that hasn't switched yet to the new interface resets/tweaks using the old interface?

Therefore I wanted to remove the old interface. The legitime users would want to change the default DL attributes. I am more afraid of those that intend to disable RT throttling and are failing to do so.

Agreed, that's the group to worry about, but they never touch sysfs, so an error after sysfs was used wouldn't reach them; the warning and the docs do.

Quoted 2 lines

We could also make the proc interface return -EINVAL on read/ write once the sysfs was used. What about it?

Hummm, I'm not convinced. Whether old tools work would then depend on whether somebody wrote to sysfs since boot, which isn't visible anywhere: LTP's proc_sched_rt01 would fail again, just only sometimes?

Earlier you actually offered:

Quoted 1 line

I could look into making the sysfs values appear in proc, too.

This might be simpler. For !RT_GROUP_SCHED, procfs could become a view of the sysfs_dl_* state, with no second copy. sysctl_sched_rt_* would only be needed for RT_GROUP_SCHED (which is marked BROKEN anyway, and what we end up with depends on the HCBS discussion).

#8 lore raw

Re: [PATCH v4 2/6] sched: Move DL's admission control to sysfs

Quoted 9 lines · Juri Lelli

On 24/11/26 11:35, Sebastian Andrzej Siewior wrote:
...

Quoted 2 lines

We could also make the proc interface return -EINVAL on read/ write once the sysfs was used. What about it?

Hummm, I'm not convinced. Whether old tools work would then depend on whether somebody wrote to sysfs since boot, which isn't visible anywhere: LTP's proc_sched_rt01 would fail again, just only sometimes?

LTP's proc_sched_rt01 (should) fail once you touch sysfs. But we would have to make sure it is something != EINVAL or else it won't fail.

But yes, if you use the new knob, don't fallback to the old habits.

Quoted 8 lines

Earlier you actually offered:

Quoted 1 line

I could look into making the sysfs values appear in proc, too.

This might be simpler. For !RT_GROUP_SCHED, procfs could become a view of the sysfs_dl_* state, with no second copy. sysctl_sched_rt_* would only be needed for RT_GROUP_SCHED (which is marked BROKEN anyway, and what we end up with depends on the HCBS discussion).

Yes. I would hope that once we have RT_GROUP_SCHED broken for a year, it could be removed.
Anyway, if you think it makes it easier to have it mirrored both way, let me look into it.

Sebastian

#9 lore raw

PATCH v4 3/6 sched: Add sysfs files for the per-CPU fair_server knobs

In reply to Sebastian Andrzej Siewior

The fair_server exposes the runtime and period knobs per-CPU in the debugfs folder. The debugfs interface is not a stable ABI.
Make the /sys/kernel/debug/sched/fair_server/cpu*/{period|runtime} knobs available as /sys/kernel/sched/cpuX/{fair_server_period|fair_server_runtime}.

It adds a struct kobject to the rq and exposes only those two. The per-runqueue folder is named cpu' rather than rq' since it might be more intuitive to the user than rq' or runqueue'.

The set logic is pulled from the debugfs folder but it is still shared. That debugfs logic could be removed (after providing the same for ext-server) or symlinked for a while.

---
 kernel/sched/deadline.c | 152 +++++++++++++++++++++++++++++++++++++++++++++++-
 kernel/sched/debug.c    |  56 ++----------------
 kernel/sched/sched.h    |   8 +++
 3 files changed, 163 insertions(+), 53 deletions(-)
kernel/sched/deadline.c +151 -1
index 49ab477bb9bd1..64e20e281b016 100644
@@ -4106,6 +4106,59 @@ void print_dl_stats(struct seq_file *m, int cpu)
 	print_dl_rq(m, cpu, &cpu_rq(cpu)->dl);
 }
 
+static unsigned long dl_server_period_max = (1UL << 22) * NSEC_PER_USEC; /* ~4 seconds */
+static unsigned long dl_server_period_min = (100) * NSEC_PER_USEC;     /* 100 us */
+
+int __sched_server_write_common(enum dl_param param, u64 value, struct rq *rq,
+				struct sched_dl_entity *dl_se, const char *sname)
+{
+	u64 old_runtime, runtime, period;
+	int retval = 0;
+
+	scoped_guard (rq_lock_irqsave, rq) {
+		old_runtime = runtime = dl_se->dl_runtime;
+		period = dl_se->dl_period;
+
+		switch (param) {
+		case DL_RUNTIME:
+			if (runtime == value)
+				break;
+			runtime = value;
+			break;
+		case DL_PERIOD:
+			if (value == period)
+				break;
+			period = value;
+			break;
+		}
+
+		if (runtime > period ||
+		    period > dl_server_period_max ||
+		    period < dl_server_period_min) {
+			return  -EINVAL;
+		}
+
+		if (!cpu_online(cpu_of(rq)))
+			return -EBUSY;
+
+		update_rq_clock(rq);
+		dl_server_stop(dl_se);
+		retval = dl_server_apply_params(dl_se, runtime, period, 0);
+		dl_server_start(dl_se);
+
+		if (retval < 0)
+			return retval;
+	}
+	if (!!old_runtime ^ !!runtime) {
+		pr_info("%s server %sabled on CPU %d%s.\n",
+			sname,
+			runtime ? "en" : "dis",
+			cpu_of(rq),
+			runtime ? "" : ", system may malfunction due to starvation");
+	}
+	return 0;
+}
+
 #define SCHED_ATTR(_name)					\
 	static struct kobj_attribute sched_attr_## _name =	\
 	__ATTR(_name, 0644, sched_attr_##_name##_show, sched_attr_##_name##_store)
@@ -4227,13 +4280,110 @@ static const struct attribute_group sched_global_attrs_group = {
 	.attrs = sched_global_attrs,
 };
 
+/* RQ */
+#define RQ_ATTR(_name)						\
+	static struct kobj_attribute rq_## _name =	\
+	__ATTR(_name, 0644, rq_##_name##_show, rq_##_name##_store)
+
+#define kobj_to_rq(__kobj) container_of(__kobj, struct rq, rq_kobj)
+
+static ssize_t rq_fair_server_runtime_show(struct kobject *kobj, struct kobj_attribute *attr,
+					   char *buf)
+{
+	struct rq *rq = kobj_to_rq(kobj);
+	struct sched_dl_entity *dl_se;
+
+	dl_se = &rq->fair_server;
+
+	return sysfs_emit(buf, "%llu\n", dl_se->dl_runtime);
+}
+
+static ssize_t rq_fair_server_runtime_store(struct kobject *kobj, struct kobj_attribute *attr,
+					    const char *buf, size_t count)
+{
+	struct rq *rq = kobj_to_rq(kobj);
+	u64 val;
+	int ret;
+
+	ret = kstrtoull(buf, 10, &val);
+	if (ret)
+		return ret;
+
+	ret =  __sched_server_write_common(DL_RUNTIME, val, rq, &rq->fair_server, "Fair");
+	if (ret)
+		return ret;
+	return count;
+}
+RQ_ATTR(fair_server_runtime);
+
+static ssize_t rq_fair_server_period_show(struct kobject *kobj, struct kobj_attribute *attr,
+					  char *buf)
+{
+	struct rq *rq = kobj_to_rq(kobj);
+	struct sched_dl_entity *dl_se;
+
+	dl_se = &rq->fair_server;
+
+	return sysfs_emit(buf, "%llu\n", dl_se->dl_period);
+}
+
+static ssize_t rq_fair_server_period_store(struct kobject *kobj, struct kobj_attribute *attr,
+					   const char *buf, size_t count)
+{
+	struct rq *rq = kobj_to_rq(kobj);
+	u64 val;
+	int ret;
+
+	ret = kstrtoull(buf, 10, &val);
+	if (ret)
+		return ret;
+
+	ret =  __sched_server_write_common(DL_PERIOD, val, rq, &rq->fair_server, "Fair");
+	if (ret)
+		return ret;
+	return count;
+}
+RQ_ATTR(fair_server_period);
+
+static struct attribute *rq_attrs[] = {
+	&rq_fair_server_runtime.attr,
+	&rq_fair_server_period.attr,
+	NULL
+};
+ATTRIBUTE_GROUPS(rq);
+
+static const struct kobj_type rq_ktype = {
+	.sysfs_ops      = &kobj_sysfs_ops,
+	.default_groups = rq_groups,
+};
+
+static int sched_create_rq_sysfs(struct kobject *sched_kobj)
+{
+	unsigned int cpu;
+	int ret;
+
+	for_each_possible_cpu(cpu) {
+		struct rq *rq = cpu_rq(cpu);
+
+		ret = kobject_init_and_add(&rq->rq_kobj, &rq_ktype, sched_kobj,
+					   "cpu%d", cpu);
+		if (ret)
+			return ret;
+	}
+	return 0;
+}
+
 static int __init sched_dl_init(void)
 {
 	struct kobject *sched_kobj;
+	int ret;
 
 	sched_kobj = kobject_create_and_add("sched", kernel_kobj);
 	if (!sched_kobj)
 		return -ENOMEM;
-	return sysfs_create_group(sched_kobj, &sched_global_attrs_group);
+	ret = sysfs_create_group(sched_kobj, &sched_global_attrs_group);
+	if (ret)
+		return ret;
+	return sched_create_rq_sysfs(sched_kobj);
 }
 late_initcall(sched_dl_init);
kernel/sched/debug.c +4 -52

75 lines not on this page · raw message

kernel/sched/sched.h +8 -0
index e755572f1cbb1..eb215e3ac1260 100644
@@ -1443,6 +1443,7 @@ struct rq {
 #endif
 
 	atomic_t		nr_iowait;
+	struct kobject		rq_kobj;
 } __no_randomize_layout;
 
 #ifdef CONFIG_FAIR_GROUP_SCHED
@@ -3537,6 +3538,13 @@ extern void print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq);
 extern void print_rt_rq(struct seq_file *m, int cpu, struct rt_rq *rt_rq);
 extern void print_dl_rq(struct seq_file *m, int cpu, struct dl_rq *dl_rq);
 
+enum dl_param {
+	DL_RUNTIME = 0,
+	DL_PERIOD,
+};
+extern int __sched_server_write_common(enum dl_param param, u64 value, struct rq *rq,
+				       struct sched_dl_entity *dl_se, const char *sname);
+
 extern void resched_latency_warn(int cpu, u64 latency);
 
 #ifdef CONFIG_NUMA_BALANCING
Signature · 1 line
2.55.0
maintainer
#10 lore raw

Re: [PATCH v4 3/6] sched: Add sysfs files for the per-CPU fair_server knobs

Hello,

Quoted 12 lines · Sebastian Andrzej Siewior

The fair_server exposes the runtime and period knobs per-CPU in the debugfs folder. The debugfs interface is not a stable ABI.
Make the /sys/kernel/debug/sched/fair_server/cpu*/{period|runtime} knobs available as /sys/kernel/sched/cpuX/{fair_server_period|fair_server_runtime}.

It adds a struct kobject to the rq and exposes only those two. The per-runqueue folder is named cpu' rather than rq' since it might be more intuitive to the user than rq' or runqueue'.

The set logic is pulled from the debugfs folder but it is still shared. That debugfs logic could be removed (after providing the same for ext-server) or symlinked for a while.

...

kernel/sched/deadline.c static const struct attribute_group sched_global_attrs_group = { · line 4299

Quoted 10 lines
kernel/sched/deadline.c +10 -0
+static ssize_t rq_fair_server_runtime_show(struct kobject *kobj, struct kobj_attribute *attr,
+					   char *buf)
+{
+	struct rq *rq = kobj_to_rq(kobj);
+	struct sched_dl_entity *dl_se;
+
+	dl_se = &rq->fair_server;
+
+	return sysfs_emit(buf, "%llu\n", dl_se->dl_runtime);
+}

Since these files are new and meant to replace debugfs, how about using ns everywhere (you partly commented about it in the cover letter), as sched_attr and the dl_server parameters already do, with the unit in the name? I.e. fair_server_{runtime,period}_ns here and dl_{runtime,period}_ns in 2/6, with only the procfs compatibility path converting from us. Right now /sys/kernel/sched/ has dl_*_us in us next to cpuX/fair_server_* in ns without a suffix.

Related, do we need to add Documentation/ABI/testing/sysfs-kernel-sched entries for these and for the 2/6 files (units, defaults, limits, what 0 / -1 mean, -EBUSY on admission failure)?

Thanks,
Juri

#11 lore raw

Re: [PATCH v4 3/6] sched: Add sysfs files for the per-CPU fair_server knobs

Quoted 29 lines · Juri Lelli

Hello,

Quoted 12 lines · Sebastian Andrzej Siewior

The fair_server exposes the runtime and period knobs per-CPU in the debugfs folder. The debugfs interface is not a stable ABI.
Make the /sys/kernel/debug/sched/fair_server/cpu*/{period|runtime} knobs available as /sys/kernel/sched/cpuX/{fair_server_period|fair_server_runtime}.

It adds a struct kobject to the rq and exposes only those two. The per-runqueue folder is named cpu' rather than rq' since it might be more intuitive to the user than rq' or runqueue'.

The set logic is pulled from the debugfs folder but it is still shared. That debugfs logic could be removed (after providing the same for ext-server) or symlinked for a while.

...

kernel/sched/deadline.c static const struct attribute_group sched_global_attrs_group = { · line 4299

Quoted 10 lines
kernel/sched/deadline.c +10 -0
+static ssize_t rq_fair_server_runtime_show(struct kobject *kobj, struct kobj_attribute *attr,
+					   char *buf)
+{
+	struct rq *rq = kobj_to_rq(kobj);
+	struct sched_dl_entity *dl_se;
+
+	dl_se = &rq->fair_server;
+
+	return sysfs_emit(buf, "%llu\n", dl_se->dl_runtime);
+}
Quoted 7 lines

Since these files are new and meant to replace debugfs, how about using ns everywhere (you partly commented about it in the cover letter), as sched_attr and the dl_server parameters already do, with the unit in the name? I.e. fair_server_{runtime,period}_ns here and dl_{runtime,period}_ns in 2/6, with only the procfs compatibility path converting from us. Right now /sys/kernel/sched/ has dl_*_us in us next to cpuX/fair_server_* in ns without a suffix.

I can do both in ns (or us depending what is easier/ more useful). Let me update that then.

Quoted 3 lines

Related, do we need to add Documentation/ABI/testing/sysfs-kernel-sched entries for these and for the 2/6 files (units, defaults, limits, what 0 / -1 mean, -EBUSY on admission failure)?

Oh. That is a good one. Yes.

Quoted 2 lines

Thanks,
Juri

Sebastian

maintainer
#12 lore raw

Re: [PATCH v4 3/6] sched: Add sysfs files for the per-CPU fair_server knobs

Quoted 38 lines · Sebastian Andrzej Siewior
Quoted 29 lines · Juri Lelli

Hello,

Quoted 12 lines · Sebastian Andrzej Siewior

The fair_server exposes the runtime and period knobs per-CPU in the debugfs folder. The debugfs interface is not a stable ABI.
Make the /sys/kernel/debug/sched/fair_server/cpu*/{period|runtime} knobs available as /sys/kernel/sched/cpuX/{fair_server_period|fair_server_runtime}.

It adds a struct kobject to the rq and exposes only those two. The per-runqueue folder is named cpu' rather than rq' since it might be more intuitive to the user than rq' or runqueue'.

The set logic is pulled from the debugfs folder but it is still shared. That debugfs logic could be removed (after providing the same for ext-server) or symlinked for a while.

...

kernel/sched/deadline.c static const struct attribute_group sched_global_attrs_group = { · line 4299

Quoted 10 lines
kernel/sched/deadline.c +10 -0
+static ssize_t rq_fair_server_runtime_show(struct kobject *kobj, struct kobj_attribute *attr,
+					   char *buf)
+{
+	struct rq *rq = kobj_to_rq(kobj);
+	struct sched_dl_entity *dl_se;
+
+	dl_se = &rq->fair_server;
+
+	return sysfs_emit(buf, "%llu\n", dl_se->dl_runtime);
+}
Quoted 7 lines

Since these files are new and meant to replace debugfs, how about using ns everywhere (you partly commented about it in the cover letter), as sched_attr and the dl_server parameters already do, with the unit in the name? I.e. fair_server_{runtime,period}_ns here and dl_{runtime,period}_ns in 2/6, with only the procfs compatibility path converting from us. Right now /sys/kernel/sched/ has dl_*_us in us next to cpuX/fair_server_* in ns without a suffix.

Quoted 2 lines

I can do both in ns (or us depending what is easier/ more useful). Let me update that then.

Mind that it would be nice to hear from others in this thread before I make you do changes that others might not agree with. :)

#13 lore raw

Re: [PATCH v4 3/6] sched: Add sysfs files for the per-CPU fair_server knobs

Quoted 39 lines · On Tue, Nov 24, 2026 at 10:59:28AM +0100 Juri Lelli wrote:
Quoted 38 lines · Sebastian Andrzej Siewior
Quoted 36 lines · Juri Lelli

Hello,

Quoted 12 lines · Sebastian Andrzej Siewior

The fair_server exposes the runtime and period knobs per-CPU in the debugfs folder. The debugfs interface is not a stable ABI.
Make the /sys/kernel/debug/sched/fair_server/cpu*/{period|runtime} knobs available as /sys/kernel/sched/cpuX/{fair_server_period|fair_server_runtime}.

It adds a struct kobject to the rq and exposes only those two. The per-runqueue folder is named cpu' rather than rq' since it might be more intuitive to the user than rq' or runqueue'.

The set logic is pulled from the debugfs folder but it is still shared. That debugfs logic could be removed (after providing the same for ext-server) or symlinked for a while.

...

kernel/sched/deadline.c static const struct attribute_group sched_global_attrs_group = { · line 4299

Quoted 10 lines
kernel/sched/deadline.c +10 -0
+static ssize_t rq_fair_server_runtime_show(struct kobject *kobj, struct kobj_attribute *attr,
+					   char *buf)
+{
+	struct rq *rq = kobj_to_rq(kobj);
+	struct sched_dl_entity *dl_se;
+
+	dl_se = &rq->fair_server;
+
+	return sysfs_emit(buf, "%llu\n", dl_se->dl_runtime);
+}

Since these files are new and meant to replace debugfs, how about using ns everywhere (you partly commented about it in the cover letter), as sched_attr and the dl_server parameters already do, with the unit in the name? I.e. fair_server_{runtime,period}_ns here and dl_{runtime,period}_ns in 2/6, with only the procfs compatibility path converting from us. Right now /sys/kernel/sched/ has dl_*_us in us next to cpuX/fair_server_* in ns without a suffix.

Quoted 6 lines
Quoted 2 lines

I can do both in ns (or us depending what is easier/ more useful). Let me update that then.

Mind that it would be nice to hear from others in this thread before I make you do changes that others might not agree with. :)

I did notice the lack of units on the fair files. I'd certainly go along with adding the _ns to those at least. I don't have a strong preference about them both being the same unit if they are properly named.

It probably makes sense but I leave it to people who know dl better to say if sub-us configuration makes sense.

Cheers,
Phil

maintainer
#14 lore raw

Re: [PATCH v4 3/6] sched: Add sysfs files for the per-CPU fair_server knobs

Quoted 47 lines · Phil Auld
Quoted 39 lines · On Tue, Nov 24, 2026 at 10:59:28AM +0100 Juri Lelli wrote:
Quoted 38 lines · Sebastian Andrzej Siewior
Quoted 36 lines · Juri Lelli

Hello,

Quoted 12 lines · Sebastian Andrzej Siewior

The fair_server exposes the runtime and period knobs per-CPU in the debugfs folder. The debugfs interface is not a stable ABI.
Make the /sys/kernel/debug/sched/fair_server/cpu*/{period|runtime} knobs available as /sys/kernel/sched/cpuX/{fair_server_period|fair_server_runtime}.

It adds a struct kobject to the rq and exposes only those two. The per-runqueue folder is named cpu' rather than rq' since it might be more intuitive to the user than rq' or runqueue'.

The set logic is pulled from the debugfs folder but it is still shared. That debugfs logic could be removed (after providing the same for ext-server) or symlinked for a while.

...

kernel/sched/deadline.c static const struct attribute_group sched_global_attrs_group = { · line 4299

Quoted 10 lines
kernel/sched/deadline.c +10 -0
+static ssize_t rq_fair_server_runtime_show(struct kobject *kobj, struct kobj_attribute *attr,
+					   char *buf)
+{
+	struct rq *rq = kobj_to_rq(kobj);
+	struct sched_dl_entity *dl_se;
+
+	dl_se = &rq->fair_server;
+
+	return sysfs_emit(buf, "%llu\n", dl_se->dl_runtime);
+}

Since these files are new and meant to replace debugfs, how about using ns everywhere (you partly commented about it in the cover letter), as sched_attr and the dl_server parameters already do, with the unit in the name? I.e. fair_server_{runtime,period}_ns here and dl_{runtime,period}_ns in 2/6, with only the procfs compatibility path converting from us. Right now /sys/kernel/sched/ has dl_*_us in us next to cpuX/fair_server_* in ns without a suffix.

Quoted 6 lines
Quoted 2 lines

I can do both in ns (or us depending what is easier/ more useful). Let me update that then.

Mind that it would be nice to hear from others in this thread before I make you do changes that others might not agree with. :)

Quoted 6 lines

I did notice the lack of units on the fair files. I'd certainly go along with adding the _ns to those at least. I don't have a strong preference about them both being the same unit if they are properly named.

It probably makes sense but I leave it to people who know dl better to say if sub-us configuration makes sense.

On second thought, not in practice. DEADLINE rejects runtimes below 1024ns and periods (of tasks and dl-servers) below 100us; above that ns values are taken as is, but enforcement (tick, or hrtick plus overheads) isn't precise enough (today, at least) for sub-us differences to matter.

So it's mostly about consistency. For the fair_server files ns keeps the values unchanged for whoever migrates from the debugfs ones, and matches sched_attr. For dl_{runtime,period} us would match the procfs files and the sched_deadline_period_{min,max}_us sysctls, while ns would give a single unit under /sys/kernel/sched/. I'd lean towards ns everywhere, but either works for me as long as the unit is in the name (as you say).

#15 lore raw

PATCH v4 4/6 sched: Limit sysctl sched_rt_{period|runtime}_us to RT_GROUP_SCHED

In reply to Sebastian Andrzej Siewior

The admission control for SCHED_DL has been moved to sysfs and RT throttling has been moved (long ago) to the fair_server and its debugfs interface.

This file remains to have an impact only on RT_GROUP_SCHED. Keeping it for ABI/ compatibility reasons makes no sense because its original purpose (RT throttling) is no longer served. Anyone changing this file and hoping to change the throttling behaviour will be surprised.

Limit sysctl sched_rt_{period|runtime}_us to RT_GROUP_SCHED so everyone using this outdated file is aware.

---
 kernel/sched/rt.c    | 8 ++++++++
 kernel/sched/sched.h | 5 +++--
 2 files changed, 11 insertions(+), 2 deletions(-)
kernel/sched/rt.c +8 -0
index bd37dbf2bebbe..258b187459bb9 100644
@@ -2877,6 +2877,14 @@ static int sched_rt_handler(const struct ctl_table *table, int write, void *buff
 	ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
 
 	if (!ret && write) {
+		if (!IS_ENABLED(CONFIG_RT_GROUP_SCHED)) {
+			const char *msg =
+			"Please note that DL admission control (via sched_rt_period_us, sched_rt_runtime_us) moved to sysfs.\n"
+			"This update will be mirrored. Controls for RT throttling moved to the fair_server.\n"
+			"This will not be mirrored. The fair_server settings are under /sys/kernel/sched/cpuX/.\n";
+
+			pr_warn_once("%s", msg);
+		}
 		ret = sched_rt_global_validate();
 		if (ret)
 			goto undo;
kernel/sched/sched.h +3 -2
index eb215e3ac1260..922708b6aad65 100644
@@ -110,8 +110,6 @@ extern long calc_load_fold_active(struct rq *this_rq, long adjust);
 extern void call_trace_sched_update_nr_running(struct rq *rq, int count);
 
 extern u64 sysfs_dl_runtime;
-extern int sysctl_sched_rt_period;
-extern int sysctl_sched_rt_runtime;
 extern int sched_rr_timeslice;
 
 /*
@@ -585,6 +583,9 @@ extern void unthrottle_cfs_rq(struct cfs_rq *cfs_rq);
 extern bool cfs_task_bw_constrained(struct task_struct *p);
 
 #ifdef CONFIG_RT_GROUP_SCHED
+extern int sysctl_sched_rt_period;
+extern int sysctl_sched_rt_runtime;
+
 extern void init_tg_rt_entry(struct task_group *tg, struct rt_rq *rt_rq,
 		struct sched_rt_entity *rt_se, int cpu,
 		struct sched_rt_entity *parent);
Signature · 1 line
2.55.0
maintainer
#16 lore raw

Re: [PATCH v4 4/6] sched: Limit sysctl sched_rt_{period|runtime}_us to RT_GROUP_SCHED

Hello,

Quoted 9 lines · Sebastian Andrzej Siewior

The admission control for SCHED_DL has been moved to sysfs and RT throttling has been moved (long ago) to the fair_server and its debugfs interface.

This file remains to have an impact only on RT_GROUP_SCHED. Keeping it for ABI/ compatibility reasons makes no sense because its original purpose (RT throttling) is no longer served. Anyone changing this file and hoping to change the throttling behaviour will be surprised.

Quoted 5 lines

Limit sysctl sched_rt_{period|runtime}_us to RT_GROUP_SCHED so everyone using this outdated file is aware.

---

It looks like subject and changelog still describe the previous version, as we are not removing the interface anymore?

Quoted 9 lines
 kernel/sched/rt.c    | 8 ++++++++
 kernel/sched/sched.h | 5 +++--
 2 files changed, 11 insertions(+), 2 deletions(-)
kernel/sched/rt.c +0 -0
index bd37dbf2bebbe..258b187459bb9 100644

kernel/sched/rt.c static int sched_rt_handler(const struct ctl_table *table, int write, void *buff · line 2884

Quoted 8 lines
kernel/sched/rt.c +5 -0
@@ -2877,6 +2877,14 @@ static int sched_rt_handler(const struct ctl_table *table, int write, void *buff
 	ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
 
 	if (!ret && write) {
+		if (!IS_ENABLED(CONFIG_RT_GROUP_SCHED)) {
+			const char *msg =
+			"Please note that DL admission control (via sched_rt_period_us, sched_rt_runtime_us) moved to sysfs.\n"
+			"This update will be mirrored. Controls for RT throttling moved to the fair_server.\n"
+			"This will not be mirrored. The fair_server settings are under /sys/kernel/sched/cpuX/.\n";

I am not sure a user who hasn't followed this thread will understand what "mirrored" means in this context. What about something like (names depending on the unit discussion):

sched_rt_{period,runtime}_us only control SCHED_DEADLINE admission control,
now also available in /sys/kernel/sched/dl_{period,runtime}_us.
RT throttling is done by the fair server, see /sys/kernel/sched/cpuX/fair_server_{period,runtime}.

Thanks,
Juri

#17 lore raw

Re: [PATCH v4 4/6] sched: Limit sysctl sched_rt_{period|runtime}_us to RT_GROUP_SCHED

Quoted 1 line · Juri Lelli

Hello,

Hi,

Quoted 2 lines

It looks like subject and changelog still describe the previous version, as we are not removing the interface anymore?

Updated:

|sched: Issue a warning for sysctl sched_rt_{period|runtime}_us on !RT_GROUP_SCHED

|The admission control for SCHED_DL has been moved to sysfs and updates
|via proc are mirrored to the sysfs interface. The sysctl knob controls
|RT throttling within a RT group if RT_GROUP_SCHED is enabled. Without
|RT_GROUP_SCHED it serves no further purpose.
|Add a warning in the !RT_GROUP_SCHED case to encourage people to move to
|the new interface.
|Move the declaration of sysctl_sched_rt_{period|runtime} to
|RT_GROUP_SCHED because it is not accessed outside this define.
Quoted 22 lines
Quoted 9 lines
 kernel/sched/rt.c    | 8 ++++++++
 kernel/sched/sched.h | 5 +++--
 2 files changed, 11 insertions(+), 2 deletions(-)
kernel/sched/rt.c +0 -0
index bd37dbf2bebbe..258b187459bb9 100644

kernel/sched/rt.c static int sched_rt_handler(const struct ctl_table *table, int write, void *buff · line 2884

Quoted 8 lines
kernel/sched/rt.c +5 -0
@@ -2877,6 +2877,14 @@ static int sched_rt_handler(const struct ctl_table *table, int write, void *buff
 	ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
 
 	if (!ret && write) {
+		if (!IS_ENABLED(CONFIG_RT_GROUP_SCHED)) {
+			const char *msg =
+			"Please note that DL admission control (via sched_rt_period_us, sched_rt_runtime_us) moved to sysfs.\n"
+			"This update will be mirrored. Controls for RT throttling moved to the fair_server.\n"
+			"This will not be mirrored. The fair_server settings are under /sys/kernel/sched/cpuX/.\n";

I am not sure a user who hasn't followed this thread will understand what "mirrored" means in this context. What about something like (names depending on the unit discussion):

Quoted 3 lines

sched_rt_{period,runtime}_us only control SCHED_DEADLINE admission control,
now also available in /sys/kernel/sched/dl_{period,runtime}_us.
RT throttling is done by the fair server, see /sys/kernel/sched/cpuX/fair_server_{period,runtime}.

Updated.

Quoted 2 lines

Thanks,
Juri

Sebastian

#18 lore raw

PATCH v4 5/6 Documentation/sched: Drop the section enumeration in sched-deadline

In reply to Sebastian Andrzej Siewior

Each headline within the document has a manual numbering. If a new section is added in the middle of the document then one has to renumber the sections that follow plus update the maunal TOC at the top of the document.

Remove the manual created TOC and the numbers before the section. The rendered HTML has a TOC.

---
 Documentation/scheduler/sched-deadline.rst | 106 +++++++++++------------------
 1 file changed, 40 insertions(+), 66 deletions(-)
Documentation/scheduler/sched-deadline.rst +40 -66
index 4441bb689cca1..b76bb61cd48fd 100644
@@ -2,41 +2,16 @@
 Deadline Task Scheduling
 ========================
 
-.. CONTENTS
-
-    0. WARNING
-    1. Overview
-    2. Scheduling algorithm
-      2.1 Main algorithm
-      2.2 Bandwidth reclaiming
-    3. Scheduling Real-Time Tasks
-      3.1 Definitions
-      3.2 Schedulability Analysis for Uniprocessor Systems
-      3.3 Schedulability Analysis for Multiprocessor Systems
-      3.4 Relationship with SCHED_DEADLINE Parameters
-    4. Bandwidth management
-      4.1 System-wide settings
-      4.2 Task interface
-      4.3 Default behavior
-      4.4 Behavior of sched_yield()
-    5. Tasks CPU affinity
-      5.1 Using cgroup v1 cpuset controller
-      5.2 Using cgroup v2 cpuset controller
-    6. Future plans
-    A. Test suite
-    B. Minimal main()
-
-
-0. WARNING
-==========
+WARNING
+=======
 
  Fiddling with these settings can result in an unpredictable or even unstable
  system behavior. As for -rt (group) scheduling, it is assumed that root users
  know what they're doing.
 
 
-1. Overview
-===========
+Overview
+========
 
  The SCHED_DEADLINE policy contained inside the sched_dl scheduling class is
  basically an implementation of the Earliest Deadline First (EDF) scheduling
@@ -44,11 +19,11 @@ Deadline Task Scheduling
  that makes it possible to isolate the behavior of tasks between each other.
 
 
-2. Scheduling algorithm
-=======================
+Scheduling algorithm
+====================
 
-2.1 Main algorithm
-------------------
+Main algorithm
+--------------
 
  SCHED_DEADLINE [18] uses three parameters, named "runtime", "period", and
  "deadline", to schedule tasks. A SCHED_DEADLINE task should receive
@@ -123,8 +98,8 @@ Deadline Task Scheduling
  signals.
 
 
-2.2 Bandwidth reclaiming
-------------------------
+Bandwidth reclaiming
+--------------------
 
  Bandwidth reclaiming for deadline tasks is based on the GRUB (Greedy
  Reclamation of Unused Bandwidth) algorithm [15, 16, 17] and it is enabled
@@ -287,8 +262,8 @@ Deadline Task Scheduling
     running_bw is incremented.
 
 
-2.3 Energy-aware scheduling
----------------------------
+Energy-aware scheduling
+-----------------------
 
  When cpufreq's schedutil governor is selected, SCHED_DEADLINE implements the
  GRUB-PA [19] algorithm, reducing the CPU operating frequency to the minimum
@@ -300,8 +275,8 @@ Deadline Task Scheduling
  setting a fixed CPU frequency results in a lower amount of deadline misses.
 
 
-3. Scheduling Real-Time Tasks
-=============================
+Scheduling Real-Time Tasks
+==========================
 
 
 
@@ -323,8 +298,8 @@ Deadline Task Scheduling
  suited for periodic or sporadic real-time tasks that need guarantees on their
  timing behavior, e.g., multimedia, streaming, control applications, etc.
 
-3.1 Definitions
-------------------------
+Definitions
+-----------
 
  A typical real-time task is composed of a repetition of computation phases
  (task instances, or jobs) which are activated on a periodic or sporadic
@@ -369,8 +344,8 @@ Deadline Task Scheduling
  is the minimum WCET, and U_max = max{WCET_i/P_i} is the maximum
  utilization[12].
 
-3.2 Schedulability Analysis for Uniprocessor Systems
-----------------------------------------------------
+Schedulability Analysis for Uniprocessor Systems
+------------------------------------------------
 
  If M=1 (uniprocessor system), or in case of partitioned scheduling (each
  real-time task is statically assigned to one and only one CPU), it is
@@ -414,8 +389,8 @@ Deadline Task Scheduling
  time-consuming to be performed on-line. Hence, as explained in Section
  4 Linux uses an admission test based on the tasks' utilizations.
 
-3.3 Schedulability Analysis for Multiprocessor Systems
-------------------------------------------------------
+Schedulability Analysis for Multiprocessor Systems
+--------------------------------------------------
 
  On multiprocessor systems with global EDF scheduling (non partitioned
  systems), a sufficient test for schedulability can not be based on the
@@ -464,8 +439,8 @@ Deadline Task Scheduling
  the total utilization is smaller or equal than M then the response times of
  the tasks are limited.
 
-3.4 Relationship with SCHED_DEADLINE Parameters
------------------------------------------------
+Relationship with SCHED_DEADLINE Parameters
+-------------------------------------------
 
  Finally, it is important to understand the relationship between the
  SCHED_DEADLINE scheduling parameters described in Section 2 (runtime,
@@ -549,8 +524,8 @@ Deadline Task Scheduling
        2018), Pau, France, April 2018.
 
 
-4. Bandwidth management
-=======================
+Bandwidth management
+====================
 
  As previously mentioned, in order for -deadline scheduling to be
  effective and useful (that is, to be able to provide "runtime" time units
@@ -587,8 +562,8 @@ Deadline Task Scheduling
  interface we can put a cap on total utilization of -deadline tasks (i.e.,
  \Sum (runtime_i / period_i) < global_dl_utilization_cap).
 
-4.1 System wide settings
-------------------------
+System wide settings
+--------------------
 
  The system wide settings are configured under /sys/kernel/sched.
 
@@ -604,9 +579,8 @@ Deadline Task Scheduling
  be thus free of oversubscribing the system up to any arbitrary level.
  This is done by writing -1 in /sys/kernel/sched/dl_runtime_us.
 
-
-4.2 Task interface
-------------------
+Task interface
+--------------
 
  Specifying a periodic/sporadic task that executes for a given amount of
  runtime at each instance, and that is scheduled according to the urgency of
@@ -640,8 +614,8 @@ Deadline Task Scheduling
  reference, that is not directly usable from user-space.
 
 
-4.3 Default behavior
----------------------
+Default behavior
+----------------
 
  The default value for SCHED_DEADLINE bandwidth is to have dl_runtime_us equal to
  1000000. With rt_period equal to 1000000, by default, it means that -deadline
@@ -659,8 +633,8 @@ Deadline Task Scheduling
  -deadline task cannot fork.
 
 
-4.4 Behavior of sched_yield()
------------------------------
+Behavior of sched_yield()
+-------------------------
 
  When a SCHED_DEADLINE task calls sched_yield(), it gives up its
  remaining runtime and is immediately throttled, until the next
@@ -675,8 +649,8 @@ Deadline Task Scheduling
  SCHED_DEADLINE tasks.
 
 
-5. Tasks CPU affinity
-=====================
+Tasks CPU affinity
+==================
 
  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
@@ -685,8 +659,8 @@ Deadline Task Scheduling
  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 Using cgroup v1 cpuset controller
--------------------------------------
+Using cgroup v1 cpuset controller
+---------------------------------
 
  An example of a simple configuration (pin a -deadline task to CPU0) follows::
 
@@ -703,8 +677,8 @@ 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
--------------------------------------
+Using cgroup v2 cpuset controller
+---------------------------------
 
  Assuming the cgroup v2 root is mounted at ``/sys/fs/cgroup``, an example of a
  simple configuration (pin a -deadline task to CPU0) follows::
@@ -717,8 +691,8 @@ Deadline Task Scheduling
    echo $$ > deadline_group/cgroup.procs
    chrt --sched-runtime 100000 --sched-period 200000 --deadline 0 yes > /dev/null
 
-6. Future plans
-===============
+Future plans
+============
 
  Still missing:
 
Signature · 1 line
2.55.0
#19 lore raw

Re: [PATCH v4 5/6] Documentation/sched: Drop the section enumeration in sched-deadline

Quoted 7 lines · On 2026-11-23 14:41:11 [+0100], To [email protected] wrote:

Each headline within the document has a manual numbering. If a new section is added in the middle of the document then one has to renumber the sections that follow plus update the maunal TOC at the top of the document.

Remove the manual created TOC and the numbers before the section. The rendered HTML has a TOC.

sashiko complained that the that the references within the document (such ass "see 5.") are now broken.

This should deal with it:

Documentation/scheduler/sched-deadline.rst +61 -78
@@ -2,53 +2,29 @@
 Deadline Task Scheduling
 ========================
 
-.. CONTENTS
-
-    0. WARNING
-    1. Overview
-    2. Scheduling algorithm
-      2.1 Main algorithm
-      2.2 Bandwidth reclaiming
-    3. Scheduling Real-Time Tasks
-      3.1 Definitions
-      3.2 Schedulability Analysis for Uniprocessor Systems
-      3.3 Schedulability Analysis for Multiprocessor Systems
-      3.4 Relationship with SCHED_DEADLINE Parameters
-    4. Bandwidth management
-      4.1 System-wide settings
-      4.2 Task interface
-      4.3 Default behavior
-      4.4 Behavior of sched_yield()
-    5. Tasks CPU affinity
-      5.1 Using cgroup v1 cpuset controller
-      5.2 Using cgroup v2 cpuset controller
-    6. Future plans
-    A. Test suite
-    B. Minimal main()
-
-
-0. WARNING
-==========
+WARNING
+=======
 
  Fiddling with these settings can result in an unpredictable or even unstable
  system behavior. As for -rt (group) scheduling, it is assumed that root users
  know what they're doing.
 
 
-1. Overview
-===========
+Overview
+========
 
  The SCHED_DEADLINE policy contained inside the sched_dl scheduling class is
  basically an implementation of the Earliest Deadline First (EDF) scheduling
  algorithm, augmented with a mechanism (called Constant Bandwidth Server, CBS)
  that makes it possible to isolate the behavior of tasks between each other.
 
+.. _scheduling_algorithm:
 
-2. Scheduling algorithm
-=======================
+Scheduling algorithm
+====================
 
-2.1 Main algorithm
-------------------
+Main algorithm
+--------------
 
  SCHED_DEADLINE [18] uses three parameters, named "runtime", "period", and
  "deadline", to schedule tasks. A SCHED_DEADLINE task should receive
@@ -60,7 +36,7 @@ Deadline Task Scheduling
  scheduled using EDF[1] on these scheduling deadlines (the task with the
  earliest scheduling deadline is selected for execution). Notice that the
  task actually receives "runtime" time units within "deadline" if a proper
- "admission control" strategy (see Section "4. Bandwidth management") is used
+ "admission control" strategy (see :ref:`bandwidth_management`) is used
  (clearly, if the system is overloaded this guarantee cannot be respected).
 
  Summing up, the CBS[2,3] algorithm assigns scheduling deadlines to tasks so
@@ -68,8 +44,8 @@ Deadline Task Scheduling
  interference between different tasks (bandwidth isolation), while the EDF[1]
  algorithm selects the task with the earliest scheduling deadline as the one
  to be executed next. Thanks to this feature, tasks that do not strictly comply
- with the "traditional" real-time task model (see Section 3) can effectively
- use the new policy.
+ with the "traditional" real-time task model (see :ref:`scheduling_real_time_tasks`)
+ can effectively use the new policy.
 
  In more details, the CBS algorithm assigns scheduling deadlines to
  tasks in the following way:
@@ -123,8 +99,8 @@ Deadline Task Scheduling
  signals.
 
 
-2.2 Bandwidth reclaiming
-------------------------
+Bandwidth reclaiming
+--------------------
 
  Bandwidth reclaiming for deadline tasks is based on the GRUB (Greedy
  Reclamation of Unused Bandwidth) algorithm [15, 16, 17] and it is enabled
@@ -287,8 +263,8 @@ Deadline Task Scheduling
     running_bw is incremented.
 
 
-2.3 Energy-aware scheduling
----------------------------
+Energy-aware scheduling
+-----------------------
 
  When cpufreq's schedutil governor is selected, SCHED_DEADLINE implements the
  GRUB-PA [19] algorithm, reducing the CPU operating frequency to the minimum
@@ -299,9 +275,10 @@ Deadline Task Scheduling
  is of the same order of magnitude of the reservation period. In such cases,
  setting a fixed CPU frequency results in a lower amount of deadline misses.
 
+.. _scheduling_real_time_tasks:
 
-3. Scheduling Real-Time Tasks
-=============================
+Scheduling Real-Time Tasks
+==========================
 
 
 
@@ -311,7 +288,7 @@ Deadline Task Scheduling
 
    This section contains a (not-thorough) summary on classical deadline
    scheduling theory, and how it applies to SCHED_DEADLINE.
-   The reader can "safely" skip to Section 4 if only interested in seeing
+   The reader can "safely" skip to :ref:`bandwidth_management` if only interested in seeing
    how the scheduling policy can be used. Anyway, we strongly recommend
    to come back here and continue reading (once the urge for testing is
    satisfied :P) to be sure of fully understanding all technical details.
@@ -323,8 +300,8 @@ Deadline Task Scheduling
  suited for periodic or sporadic real-time tasks that need guarantees on their
  timing behavior, e.g., multimedia, streaming, control applications, etc.
 
-3.1 Definitions
-------------------------
+Definitions
+-----------
 
  A typical real-time task is composed of a repetition of computation phases
  (task instances, or jobs) which are activated on a periodic or sporadic
@@ -369,8 +346,8 @@ Deadline Task Scheduling
  is the minimum WCET, and U_max = max{WCET_i/P_i} is the maximum
  utilization[12].
 
-3.2 Schedulability Analysis for Uniprocessor Systems
-----------------------------------------------------
+Schedulability Analysis for Uniprocessor Systems
+------------------------------------------------
 
  If M=1 (uniprocessor system), or in case of partitioned scheduling (each
  real-time task is statically assigned to one and only one CPU), it is
@@ -411,11 +388,12 @@ Deadline Task Scheduling
  between 0 and a maximum value L. The cited papers contain all of the
  mathematical details and explain how to compute h(t) and L.
  In any case, this kind of analysis is too complex as well as too
- time-consuming to be performed on-line. Hence, as explained in Section
- 4 Linux uses an admission test based on the tasks' utilizations.
+ time-consuming to be performed on-line. Hence, as explained in
+ :ref:`bandwidth_management`
+ Linux uses an admission test based on the tasks' utilizations.
 
-3.3 Schedulability Analysis for Multiprocessor Systems
-------------------------------------------------------
+Schedulability Analysis for Multiprocessor Systems
+--------------------------------------------------
 
  On multiprocessor systems with global EDF scheduling (non partitioned
  systems), a sufficient test for schedulability can not be based on the
@@ -464,16 +442,17 @@ Deadline Task Scheduling
  the total utilization is smaller or equal than M then the response times of
  the tasks are limited.
 
-3.4 Relationship with SCHED_DEADLINE Parameters
------------------------------------------------
+Relationship with SCHED_DEADLINE Parameters
+-------------------------------------------
 
  Finally, it is important to understand the relationship between the
- SCHED_DEADLINE scheduling parameters described in Section 2 (runtime,
+ SCHED_DEADLINE scheduling parameters described in
+ :ref:`scheduling_algorithm` (runtime,
  deadline and period) and the real-time task parameters (WCET, D, P)
  described in this section. Note that the tasks' temporal constraints are
  represented by its absolute deadlines d_j = r_j + D described above, while
  SCHED_DEADLINE schedules the tasks according to scheduling deadlines (see
- Section 2).
+ :ref:`scheduling_algorithm`).
  If an admission test is used to guarantee that the scheduling deadlines
  are respected, then SCHED_DEADLINE can be used to schedule real-time tasks
  guaranteeing that all the jobs' deadlines of a task are respected.
@@ -549,8 +528,10 @@ Deadline Task Scheduling
        2018), Pau, France, April 2018.
 
 
-4. Bandwidth management
-=======================
+.. _bandwidth_management:
+
+Bandwidth management
+====================
 
  As previously mentioned, in order for -deadline scheduling to be
  effective and useful (that is, to be able to provide "runtime" time units
@@ -559,7 +540,8 @@ Deadline Task Scheduling
  This is usually called "admission control" and if it is not performed, then
  no guarantee can be given on the actual scheduling of the -deadline tasks.
 
- As already stated in Section 3, a necessary condition to be respected to
+ As already stated in :ref:`scheduling_real_time_tasks`,
+ a necessary condition to be respected to
  correctly schedule a set of real-time tasks is that the total utilization
  is smaller than M. When talking about -deadline tasks, this requires that
  the sum of the ratio between runtime and period for all tasks is smaller
@@ -587,13 +569,13 @@ Deadline Task Scheduling
  interface we can put a cap on total utilization of -deadline tasks (i.e.,
  \Sum (runtime_i / period_i) < global_dl_utilization_cap).
 
-4.1 System wide settings
-------------------------
+System wide settings
+--------------------
 
  The system wide settings are configured under /sys/kernel/sched.
 
- The ideal situation (see 5.) is to run -rt tasks from a -deadline server; in
- which case the -rt bandwidth is a direct subset of dl_bw.
+ The ideal situation (see ref:`tasks_cpu_affinity`) is to run -rt tasks from a
+ -deadline server; in which case the -rt bandwidth is a direct subset of dl_bw.
 
  This means that, for a root_domain comprising M CPUs, -deadline tasks
  can be created while the sum of their bandwidths stays below:
@@ -604,9 +586,8 @@ Deadline Task Scheduling
  be thus free of oversubscribing the system up to any arbitrary level.
  This is done by writing -1 in /sys/kernel/sched/dl_runtime_us.
 
-
-4.2 Task interface
-------------------
+Task interface
+--------------
 
  Specifying a periodic/sporadic task that executes for a given amount of
  runtime at each instance, and that is scheduled according to the urgency of
@@ -640,8 +621,8 @@ Deadline Task Scheduling
  reference, that is not directly usable from user-space.
 
 
-4.3 Default behavior
----------------------
+Default behavior
+----------------
 
  The default value for SCHED_DEADLINE bandwidth is to have dl_runtime_us equal to
  1000000. With rt_period equal to 1000000, by default, it means that -deadline
@@ -651,7 +632,8 @@ Deadline Task Scheduling
  and that -deadline tasks will receive their runtime with a guaranteed
  worst-case delay respect to the "deadline" parameter. If "deadline" = "period"
  and the cpuset mechanism is used to implement partitioned scheduling (see
- Section 5), then this simple setting of the bandwidth management is able to
+ :ref:`tasks_cpu_affinity`),
+ then this simple setting of the bandwidth management is able to
  deterministically guarantee that -deadline tasks will receive their runtime
  in a period.
 
@@ -659,8 +641,8 @@ Deadline Task Scheduling
  -deadline task cannot fork.
 
 
-4.4 Behavior of sched_yield()
------------------------------
+Behavior of sched_yield()
+-------------------------
 
  When a SCHED_DEADLINE task calls sched_yield(), it gives up its
  remaining runtime and is immediately throttled, until the next
@@ -674,9 +656,10 @@ Deadline Task Scheduling
  make the leftoever runtime available for reclamation by other
  SCHED_DEADLINE tasks.
 
+.. _tasks_cpu_affinity:
 
-5. Tasks CPU affinity
-=====================
+Tasks CPU affinity
+==================
 
  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
@@ -685,8 +668,8 @@ Deadline Task Scheduling
  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 Using cgroup v1 cpuset controller
--------------------------------------
+Using cgroup v1 cpuset controller
+---------------------------------
 
  An example of a simple configuration (pin a -deadline task to CPU0) follows::
 
@@ -703,8 +686,8 @@ 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
--------------------------------------
+Using cgroup v2 cpuset controller
+---------------------------------
 
  Assuming the cgroup v2 root is mounted at ``/sys/fs/cgroup``, an example of a
  simple configuration (pin a -deadline task to CPU0) follows::
@@ -717,8 +700,8 @@ Deadline Task Scheduling
    echo $$ > deadline_group/cgroup.procs
    chrt --sched-runtime 100000 --sched-period 200000 --deadline 0 yes > /dev/null
 
-6. Future plans
-===============
+Future plans
+============
 
  Still missing:
 
Signature · 4 lines
2.55.0


Sebastian
#20 lore raw

PATCH v4 6/6 Documentation/sched: Add fairserver to sched-deadline

In reply to Sebastian Andrzej Siewior

The fair_server ensures the fair-class gets CPU run-time and throttles even the rt-class if needed. Add this bit of wisdom and the recently added sysfs knobs for configutiation.

---
 Documentation/scheduler/sched-deadline.rst | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)
Documentation/scheduler/sched-deadline.rst +21 -1
index b76bb61cd48fd..b2c1ae8b7dddf 100644
@@ -552,7 +552,8 @@ Bandwidth management
  level.
 
  A main difference between deadline bandwidth management and RT-throttling
- is that -deadline tasks have bandwidth on their own (while -rt ones don't!),
+ is that -deadline tasks have bandwidth on their own (while -rt have only
+ throttling via the fair_server),
  and thus we don't need a higher level throttling mechanism to enforce the
  desired bandwidth. In other words, this means that interface parameters are
  only used at admission control time (i.e., when the user calls
@@ -579,6 +580,25 @@ System wide settings
  be thus free of oversubscribing the system up to any arbitrary level.
  This is done by writing -1 in /sys/kernel/sched/dl_runtime_us.
 
+Fair server settings
+--------------------
+
+ The fair server ensures that fair-class tasks (SCHED_OTHER) are not starved
+ and can be scheduled even when tasks in the RT scheduling class
+ (SCHED_FIFO and SCHED_RR) are consuming all CPU time. It replaces the
+ legacy RT throttling mechanism, which was configured through the procfs
+ interface.
+
+ The fair server executes fair-class tasks through a deadline-scheduling
+ server with a runtime budget. It guarantees that the runtime configured by
+ fair_server_runtime is provided within the interval defined by
+ fair_server_period.
+
+ Both values are specified in nanoseconds and can be configured on a
+ per-CPU basis through /sys/kernel/sched/cpuX. Setting
+ fair_server_runtime to 0 disables the fair server on the corresponding
+ CPU.
+
 Task interface
 --------------
 
Signature · 1 line
2.55.0