Skip to contentSkip to conversation

RT throttling

RFC PATCH In review Richard Weinberger (sigma star gmbh) 3 participants 11 messages Dec 1

lore
Share & tools
lore
#0 lore raw

cover RT throttling

From: Richard Weinberger <[email protected]>

This patch series implements an RT throttle like Linux has. It allows limiting the total CPU time used by Cobalt threads, if the limit is reached, Linux gets the CPU.

That way, misbehaving applications won't kill the system and will only get throttled instead of killed by the Xenomai runaway thread detection.
The main reason I need this feature is because for a rather specific use case, I need to limit the total available CPU time for all userspace, so Xenomai plus Linux.

I'm curious to read how much you'll hate this. ;-)

Thanks,
//richard

Richard Weinberger (5):
cobalt/trace: add cobalt_sched_throttle tracepoint cobalt/sched: add RT throttling cobalt/sched-sporadic: stop budget accounting on RT throttling cobalt/sched-quota: charge the running group on RT throttling testsuite/smokey: add sched-throttle test

 configure.ac                                  |   1 +
 doc/asciidoc/README.INSTALL.adoc              |  12 +
 include/cobalt/kernel/sched-throttle.h        |  92 ++++++
 include/cobalt/kernel/sched.h                 |  25 +-
 kernel/cobalt/Kconfig                         |  26 ++
 kernel/cobalt/Makefile                        |   1 +
 kernel/cobalt/sched-quota.c                   |  39 ++-
 kernel/cobalt/sched-sporadic.c                |   7 +
 kernel/cobalt/sched-throttle.c                | 266 ++++++++++++++++++
 kernel/cobalt/sched.c                         |  31 +-
 kernel/cobalt/trace/cobalt-core.h             |  17 ++
 testsuite/smokey/Makefile.am                  |   2 +
 testsuite/smokey/sched-throttle/Makefile.am   |   8 +
 .../smokey/sched-throttle/sched-throttle.c    | 251 +++++++++++++++++
 14 files changed, 763 insertions(+), 15 deletions(-)
 create mode 100644 include/cobalt/kernel/sched-throttle.h
 create mode 100644 kernel/cobalt/sched-throttle.c
 create mode 100644 testsuite/smokey/sched-throttle/Makefile.am
 create mode 100644 testsuite/smokey/sched-throttle/sched-throttle.c
Signature · 1 line
2.56.1
#1 lore raw

PATCH 1/5 cobalt/trace: add cobalt_sched_throttle tracepoint

From: Richard Weinberger <[email protected]>

Add a tracepoint for RT throttling, to be emitted when a CPU gets throttled and when the throttle is lifted.

---
 kernel/cobalt/trace/cobalt-core.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
kernel/cobalt/trace/cobalt-core.h +17 -0
index f534121cb..4cd72d5ee 100644
@@ -197,6 +197,23 @@ TRACE_EVENT(cobalt_schedule_remote,
 	TP_printk("status=0x%lx", __entry->status)
 );
 
+TRACE_EVENT(cobalt_sched_throttle,
+	TP_PROTO(int cpu, bool throttled),
+	TP_ARGS(cpu, throttled),
+
+	TP_STRUCT__entry(
+		__field(int, cpu)
+		__field(bool, throttled)
+	),
+
+	TP_fast_assign(
+		__entry->cpu = cpu;
+		__entry->throttled = throttled;
+	),
+
+	TP_printk("cpu=%d throttled=%d", __entry->cpu, __entry->throttled)
+);
+
 TRACE_EVENT(cobalt_switch_context,
 	TP_PROTO(struct xnthread *prev, struct xnthread *next),
 	TP_ARGS(prev, next),
Signature · 1 line
2.56.1
#2 lore raw

PATCH 2/5 cobalt/sched: add RT throttling

In reply to Richard Weinberger (sigma star gmbh)

From: Richard Weinberger <[email protected]>

Add an optional per-CPU limit on the CPU time Cobalt may use, similar to sched_rt_runtime_us/sched_rt_period_us in Linux. Within each window of xenomai.sched_rt_period_us, Cobalt threads may run for at most xenomai.sched_rt_runtime_us. Once the budget is used up, Linux gets the CPU until the window ends.

The use cases are CPU bandwidth throttling and a safety net against buggy real-time applications, which would otherwise lock up a CPU and starve Linux.

The limit applies to every Cobalt thread regardless of its scheduling class and overrides the scheduler lock. The parameters can only be set at boot time.

Scheduling classes keeping per-thread budgets can implement the new sched_throttle hook to stop accounting when the throttle switches a thread out.

---
 doc/asciidoc/README.INSTALL.adoc       |  12 ++
 include/cobalt/kernel/sched-throttle.h |  92 +++++++++
 include/cobalt/kernel/sched.h          |  25 ++-
 kernel/cobalt/Kconfig                  |  26 +++
 kernel/cobalt/Makefile                 |   1 +
 kernel/cobalt/sched-throttle.c         | 266 +++++++++++++++++++++++++
 kernel/cobalt/sched.c                  |  31 ++-
 7 files changed, 450 insertions(+), 3 deletions(-)
 create mode 100644 include/cobalt/kernel/sched-throttle.h
 create mode 100644 kernel/cobalt/sched-throttle.c
doc/asciidoc/README.INSTALL.adoc +12 -0
index 5797b8fc0..8f8d7a0aa 100644
@@ -150,6 +150,18 @@ This option activates a watchdog aimed at detecting runaway Cobalt threads.
 Timeout value can be set via CONFIG_XENO_OPT_WATCHDOG_TIMEOUT, with a range
 from 1 to 60. | 4
 
+|xenomai.sched_rt_period_us=<usecs> | Length of the real-time throttling
+window. Requires CONFIG_XENO_OPT_SCHED_THROTTLE to be enabled in kernel
+configuration.
+| 1000000
+
+|xenomai.sched_rt_runtime_us=<usecs> | CPU time Cobalt threads may
+consume on each CPU within every throttling window, regardless of their
+scheduling class. Once exhausted, Linux runs until the window ends, even
+if a Cobalt thread holds the scheduler lock. -1 disables throttling.
+Requires CONFIG_XENO_OPT_SCHED_THROTTLE to be enabled in kernel configuration.
+| 950000
+
 |xenomai.smi=<state> | *x86-specific*: Set the state of the SMI
 workaround. The possible values are _disabled_, _detect_ and
 _enabled_. See the discussion about link:dealing-with-x86-SMI[SMIs]
include/cobalt/kernel/sched-throttle.h new file +92 -0

92 lines not on this page · raw message

include/cobalt/kernel/sched.h +24 -1
index e0b4249a4..539d4148e 100644
@@ -28,6 +28,7 @@
 #include <cobalt/kernel/sched-sporadic.h>
 #include <cobalt/kernel/sched-quota.h>
 #include <cobalt/kernel/vfile.h>
+#include <cobalt/kernel/sched-throttle.h>
 #include <cobalt/kernel/assert.h>
 #include <asm/xenomai/machine.h>
 #include <pipeline/sched.h>
@@ -47,6 +48,7 @@
 #define XNHTICK		0x00008000	/* Host tick pending  */
 #define XNINIRQ		0x00004000	/* In IRQ handling context */
 #define XNHDEFER	0x00002000	/* Host tick deferred */
+#define XNTHROTTLED	0x00001000	/* RT budget exhausted */
 
 /*
  * Hardware timer is stopped.
@@ -108,6 +110,10 @@ struct xnsched {
 	/*!< Watchdog timer object. */
 	struct xntimer wdtimer;
 #endif
+#ifdef CONFIG_XENO_OPT_SCHED_THROTTLE
+	/*!< RT throttling state. */
+	struct xnsched_throttle throttle;
+#endif
 #ifdef CONFIG_XENO_OPT_STATS
 	/*!< Last account switch date (ticks). */
 	xnticks_t last_account_switch;
@@ -179,6 +185,14 @@ struct xnsched_class {
 			     const union xnsched_policy_param *p);
 	void (*sched_forget)(struct xnthread *thread);
 	void (*sched_kick)(struct xnthread *thread);
+	/**
+	 * Called on the base class of @a curr when RT throttling
+	 * switches it out in favour of the root thread, bypassing
+	 * sched_pick(). Classes that keep per-thread budgets should
+	 * stop accounting @a curr here, as they would when picking a
+	 * successor.
+	 */
+	void (*sched_throttle)(struct xnthread *curr);
 #ifdef CONFIG_XENO_OPT_VFILE
 	int (*sched_init_vfile)(struct xnsched_class *schedclass,
 				struct xnvfile_directory *vfroot);
@@ -307,6 +321,12 @@ static inline int __xnsched_run(struct xnsched *sched)
 	return pipeline_schedule(sched);
 }
 
+/* RT budget used up, Linux owns the CPU until the window ends. */
+static inline bool xnsched_throttled(struct xnsched *sched)
+{
+	return sched->lflags & XNTHROTTLED;
+}
+
 static inline int xnsched_run(void)
 {
 	struct xnsched *sched = xnsched_current();
@@ -323,7 +343,10 @@ static inline int xnsched_run(void)
 	 * If running over the root thread, hard irqs must be off
 	 * (asserted out of line in ___xnsched_run()).
 	 */
-	return curr->lock_count > 0 ? 0 : __xnsched_run(sched);
+	if (curr->lock_count > 0 && !xnsched_throttled(sched))
+		return 0;
+
+	return __xnsched_run(sched);
 }
 
 void xnsched_lock(void);
kernel/cobalt/Kconfig +26 -0
index 4b61b2f59..266643a0d 100644
@@ -126,6 +126,32 @@ config XENO_OPT_SCHED_QUOTA_NR_GROUPS
 	  The overall number of thread groups which may be defined
 	  across all CPUs.
 
+config XENO_OPT_SCHED_THROTTLE
+	bool "Real-time throttling"
+	default n
+	help
+	  Limit the CPU time Cobalt threads may consume on each CPU,
+	  similar to the RT throttling of the Linux scheduler. Within
+	  every period of xenomai.sched_rt_period_us microseconds,
+	  Cobalt threads may run for at most
+	  xenomai.sched_rt_runtime_us microseconds on a given CPU.
+	  Once this budget is exhausted, Linux gets the CPU until the
+	  period ends. Both parameters are boot-time only. Setting
+	  xenomai.sched_rt_runtime_us to -1 disables throttling.
+
+	  Windows are aligned to multiples of the period. Every Cobalt
+	  thread counts against the budget, whatever its scheduling
+	  class (including SCHED_WEAK threads running in primary
+	  mode), and throttling overrides the scheduler lock. Threads
+	  which wake up, switch to primary mode or need to relax while
+	  the CPU is throttled wait until the window ends.
+
+	  Throttling preempts real-time threads regardless of their
+	  priority, so enabling it voids real-time guarantees whenever
+	  the budget runs out. Use with care.
+
+	  If in doubt, say N.
+
 config XENO_OPT_STATS
 	bool "Runtime statistics"
 	depends on XENO_OPT_VFILE
kernel/cobalt/Makefile +1 -0
index 6cd2d5994..4bba9a742 100644
@@ -21,6 +21,7 @@ xenomai-$(CONFIG_XENO_OPT_SCHED_QUOTA) += sched-quota.o
 xenomai-$(CONFIG_XENO_OPT_SCHED_WEAK) += sched-weak.o
 xenomai-$(CONFIG_XENO_OPT_SCHED_SPORADIC) += sched-sporadic.o
 xenomai-$(CONFIG_XENO_OPT_SCHED_TP) += sched-tp.o
+xenomai-$(CONFIG_XENO_OPT_SCHED_THROTTLE) += sched-throttle.o
 xenomai-$(CONFIG_XENO_OPT_DEBUG) += debug.o
 xenomai-$(CONFIG_XENO_OPT_PIPE) += pipe.o
 xenomai-$(CONFIG_XENO_OPT_MAP) += map.o
kernel/cobalt/sched-throttle.c new file +266 -0

266 lines not on this page · raw message

kernel/cobalt/sched.c +29 -2
index ed99ddd0a..e0e01a222 100644
@@ -149,6 +149,7 @@ static void watchdog_handler(struct xntimer *timer)
 
 #endif /* CONFIG_XENO_OPT_WATCHDOG */
 
+
 static void roundrobin_handler(struct xntimer *timer)
 {
 	struct xnsched *sched = container_of(timer, struct xnsched, rrbtimer);
@@ -223,6 +224,7 @@ static void xnsched_init(struct xnsched *sched, int cpu)
 	xntimer_set_name(&sched->wdtimer, "[watchdog]");
 	xntimer_set_priority(&sched->wdtimer, XNTIMER_LOPRIO);
 #endif /* CONFIG_XENO_OPT_WATCHDOG */
+	xnsched_throttle_init(sched);
 }
 
 void xnsched_init_all(void)
@@ -230,6 +232,8 @@ void xnsched_init_all(void)
 	struct xnsched *sched;
 	int cpu;
 
+	xnsched_throttle_setup();
+
 	for_each_online_cpu(cpu) {
 		sched = &per_cpu(nksched, cpu);
 		xnsched_init(sched, cpu);
@@ -247,6 +251,7 @@ static void xnsched_destroy(struct xnsched *sched)
 #ifdef CONFIG_XENO_OPT_WATCHDOG
 	xntimer_destroy(&sched->wdtimer);
 #endif /* CONFIG_XENO_OPT_WATCHDOG */
+	xnsched_throttle_destroy(sched);
 }
 
 void xnsched_destroy_all(void)
@@ -297,9 +302,9 @@ struct xnthread *xnsched_pick_next(struct xnsched *sched)
 	if (!xnthread_test_state(curr, XNTHREAD_BLOCK_BITS | XNZOMBIE)) {
 		/*
 		 * Do not preempt the current thread if it holds the
-		 * scheduler lock.
+		 * scheduler lock, unless the RT budget is exhausted.
 		 */
-		if (curr->lock_count > 0) {
+		if (curr->lock_count > 0 && !xnsched_throttled(sched)) {
 			xnsched_set_self_resched(sched);
 			return curr;
 		}
@@ -314,6 +319,21 @@ struct xnthread *xnsched_pick_next(struct xnsched *sched)
 		}
 	}
 
+	/*
+	 * Hand the CPU over to Linux until the RT window ends. This
+	 * applies to every scheduling class and overrides the
+	 * scheduler lock: the holder keeps its lock count and no
+	 * other Cobalt thread can run until the window ends.
+	 */
+	if (unlikely(xnsched_throttled(sched))) {
+		/* Per-thread budgets belong to the base class. */
+		if (curr->base_class->sched_throttle)
+			curr->base_class->sched_throttle(curr);
+		thread = &sched->rootcb;
+		set_thread_running(sched, thread);
+		return thread;
+	}
+
 	/*
 	 * Find the runnable thread having the highest priority among
 	 * all scheduling classes, scanned by decreasing priority.
@@ -876,6 +896,7 @@ static inline void enter_root(struct xnthread *root)
 #ifdef CONFIG_XENO_OPT_WATCHDOG
 	xntimer_stop(&root->sched->wdtimer);
 #endif
+	xnsched_throttle_enter_root(root->sched);
 }
 
 static inline void leave_root(struct xnthread *root)
@@ -886,6 +907,7 @@ static inline void leave_root(struct xnthread *root)
 	xntimer_start(&root->sched->wdtimer, get_watchdog_timeout(),
 		      XN_INFINITE, XN_RELATIVE);
 #endif
+	xnsched_throttle_leave_root(root->sched);
 }
 
 static inline void do_lazy_user_work(struct xnthread *curr)
@@ -1412,6 +1434,10 @@ int xnsched_init_proc(void)
 	xnvfile_init_regular("affinity", &affinity_vfile, &cobalt_vfroot);
 #endif /* CONFIG_SMP */
 
+	ret = xnsched_throttle_init_proc(&sched_vfroot);
+	if (ret)
+		return ret;
+
 	return 0;
 }
 
@@ -1424,6 +1450,7 @@ void xnsched_cleanup_proc(void)
 			p->sched_cleanup_vfile(p);
 	}
 
+	xnsched_throttle_cleanup_proc();
 #ifdef CONFIG_SMP
 	xnvfile_destroy_regular(&affinity_vfile);
 #endif /* CONFIG_SMP */
Signature · 1 line
2.56.1
#3 lore raw

PATCH 3/5 cobalt/sched-sporadic: stop budget accounting on RT throttling

In reply to Richard Weinberger (sigma star gmbh)

From: Richard Weinberger <[email protected]>

When RT throttling switches a sporadic thread out, sched_pick() is bypassed and sporadic_suspend_activity() is not called. The drop timer keeps running while the CPU is throttled, charging the thread for time it did not run and possibly demoting it to its low priority.

Implement the sched_throttle hook to suspend budget accounting.

---
 kernel/cobalt/sched-sporadic.c | 7 +++++++
 1 file changed, 7 insertions(+)
kernel/cobalt/sched-sporadic.c +7 -0
index bec8dcb53..78687bf92 100644
@@ -395,6 +395,12 @@ swap:
 	return next;
 }
 
+static void xnsched_sporadic_throttle(struct xnthread *curr)
+{
+	if (curr->pss)
+		sporadic_suspend_activity(curr);
+}
+
 #ifdef CONFIG_XENO_OPT_VFILE
 
 struct xnvfile_directory sched_sporadic_vfroot;
@@ -549,6 +555,7 @@ struct xnsched_class xnsched_class_sporadic = {
 	.sched_declare		=	xnsched_sporadic_declare,
 	.sched_forget		=	xnsched_sporadic_forget,
 	.sched_kick		=	NULL,
+	.sched_throttle		=	xnsched_sporadic_throttle,
 #ifdef CONFIG_XENO_OPT_VFILE
 	.sched_init_vfile	=	xnsched_sporadic_init_vfile,
 	.sched_cleanup_vfile	=	xnsched_sporadic_cleanup_vfile,
Signature · 1 line
2.56.1
#4 lore raw

PATCH 4/5 cobalt/sched-quota: charge the running group on RT throttling

In reply to Richard Weinberger (sigma star gmbh)

From: Richard Weinberger <[email protected]>

When RT throttling switches a quota thread out, xnsched_quota_pick() is bypassed, so the time the thread ran since it was picked is never charged to its group.

Implement the sched_throttle hook to charge the group and stop the limit timer, factoring the charging out of xnsched_quota_pick().

---
 kernel/cobalt/sched-quota.c | 39 +++++++++++++++++++++++++------------
 1 file changed, 27 insertions(+), 12 deletions(-)
kernel/cobalt/sched-quota.c +27 -12
index f821f54bd..16a50aca3 100644
@@ -405,27 +405,32 @@ static void xnsched_quota_requeue(struct xnthread *thread)
 	tg->nr_active++;
 }
 
+/*
+ * Charge the time consumed by the outgoing thread to the group it
+ * belongs to.
+ */
+static void quota_charge(struct xnsched_quota_group *tg, xnticks_t now)
+{
+	xnticks_t elapsed = now - tg->run_start_ns;
+
+	if (elapsed < tg->run_budget_ns)
+		tg->run_budget_ns -= elapsed;
+	else
+		tg->run_budget_ns = 0;
+}
+
 static struct xnthread *xnsched_quota_pick(struct xnsched *sched)
 {
 	struct xnthread *next, *curr = sched->curr;
 	struct xnsched_quota *qs = &sched->quota;
 	struct xnsched_quota_group *otg, *tg;
-	xnticks_t now, elapsed;
+	xnticks_t now;
 	int ret;
 
 	now = xnclock_read_monotonic(&nkclock);
 	otg = curr->quota;
-	if (otg == NULL)
-		goto pick;
-	/*
-	 * Charge the time consumed by the outgoing thread to the
-	 * group it belongs to.
-	 */
-	elapsed = now - otg->run_start_ns;
-	if (elapsed < otg->run_budget_ns)
-		otg->run_budget_ns -= elapsed;
-	else
-		otg->run_budget_ns = 0;
+	if (otg)
+		quota_charge(otg, now);
 pick:
 	next = xnsched_getq(&sched->rt.runnable);
 	if (next == NULL) {
@@ -690,6 +695,15 @@ EXPORT_SYMBOL_GPL(xnsched_quota_sum_all);
 
 /** @} */
 
+static void xnsched_quota_throttle(struct xnthread *curr)
+{
+	if (curr->quota == NULL)
+		return;
+
+	quota_charge(curr->quota, xnclock_read_monotonic(&nkclock));
+	xntimer_stop(&curr->sched->quota.limit_timer);
+}
+
 #ifdef CONFIG_XENO_OPT_VFILE
 
 struct xnvfile_directory sched_quota_vfroot;
@@ -824,6 +838,7 @@ struct xnsched_class xnsched_class_quota = {
 	.sched_protectprio	=	xnsched_quota_protectprio,
 	.sched_forget		=	xnsched_quota_forget,
 	.sched_kick		=	xnsched_quota_kick,
+	.sched_throttle		=	xnsched_quota_throttle,
 #ifdef CONFIG_XENO_OPT_VFILE
 	.sched_init_vfile	=	xnsched_quota_init_vfile,
 	.sched_cleanup_vfile	=	xnsched_quota_cleanup_vfile,
Signature · 1 line
2.56.1
#5 lore raw

PATCH 5/5 testsuite/smokey: add sched-throttle test

In reply to Richard Weinberger (sigma star gmbh)

From: Richard Weinberger <[email protected]>

Spin a SCHED_FIFO thread on one CPU next to a regular Linux thread pinned to the same CPU, once normally and once with the scheduler locked. Check that the Linux thread makes progress and that the throttle counter in /proc/xenomai/sched/throttle went up about once per window.

The test is skipped if RT throttling is not enabled.

---
 configure.ac                                  |   1 +
 testsuite/smokey/Makefile.am                  |   2 +
 testsuite/smokey/sched-throttle/Makefile.am   |   8 +
 .../smokey/sched-throttle/sched-throttle.c    | 251 ++++++++++++++++++
 4 files changed, 262 insertions(+)
 create mode 100644 testsuite/smokey/sched-throttle/Makefile.am
 create mode 100644 testsuite/smokey/sched-throttle/sched-throttle.c
configure.ac +1 -0
index d707fb11d..8aaae4589 100644
@@ -1073,6 +1073,7 @@ AC_CONFIG_FILES([ \
 	testsuite/smokey/arith/Makefile \
 	testsuite/smokey/dlopen/Makefile \
 	testsuite/smokey/sched-quota/Makefile \
+	testsuite/smokey/sched-throttle/Makefile \
 	testsuite/smokey/sched-tp/Makefile \
 	testsuite/smokey/setsched/Makefile \
 	testsuite/smokey/rtdm/Makefile \
testsuite/smokey/Makefile.am +2 -0
index c49a5d77f..ee6791fbb 100644
@@ -33,6 +33,7 @@ COBALT_SUBDIRS = 	\
 	posix-select 	\
 	rtdm 		\
 	sched-quota 	\
+	sched-throttle	\
 	sched-tp 	\
 	setsched	\
 	sigdebug	\
@@ -78,6 +79,7 @@ DIST_SUBDIRS = 		\
 	posix-select 	\
 	rtdm 		\
 	sched-quota 	\
+	sched-throttle	\
 	sched-tp 	\
 	setsched	\
 	sigdebug	\
testsuite/smokey/sched-throttle/Makefile.am new file +8 -0
new file mode 100644
index 000000000..2e7e03275
@@ -0,0 +1,8 @@
+
+noinst_LIBRARIES = libsched-throttle.a
+
+libsched_throttle_a_SOURCES = sched-throttle.c
+
+libsched_throttle_a_CPPFLAGS = 	\
+	@XENO_USER_CFLAGS@	\
+	-I$(top_srcdir)/include
testsuite/smokey/sched-throttle/sched-throttle.c new file +251 -0

251 lines not on this page · raw message

Signature · 1 line
2.56.1
#6 lore raw
In reply to Richard Weinberger (sigma star gmbh)
Quoted 6 lines · Richard Weinberger (sigma star gmbh)

From: Richard Weinberger <[email protected]>

This patch series implements an RT throttle like Linux has. It allows limiting the total CPU time used by Cobalt threads, if the limit is reached, Linux gets the CPU.

Quoted 9 lines

That way, misbehaving applications won't kill the system and will only get throttled instead of killed by the Xenomai runaway thread detection.
The main reason I need this feature is because for a rather specific use case, I need to limit the total available CPU time for all userspace, so Xenomai plus Linux.

I'm curious to read how much you'll hate this. ;-)

We unfortunately still have to fix the quota scheduler first. Then the test case should operate over all scheduler types.

And the watchdog should be come a feature on top of the throttling: When enabled, also signal the currently running thread. When not, just throttle.

Jan

Signature · 2 lines
Siemens AG, Foundational Technologies
Linux Expert Center
#7 lore raw
Quoted 14 lines · On Dienstag, 1. Dezember 2026 16:29 'Jan Kiszka' via upstream wrote:
Quoted 13 lines · Richard Weinberger (sigma star gmbh)

From: Richard Weinberger <[email protected]>

This patch series implements an RT throttle like Linux has. It allows limiting the total CPU time used by Cobalt threads, if the limit is reached, Linux gets the CPU.

That way, misbehaving applications won't kill the system and will only get throttled instead of killed by the Xenomai runaway thread detection.
The main reason I need this feature is because for a rather specific use case, I need to limit the total available CPU time for all userspace, so Xenomai plus Linux.

Quoted 5 lines
Quoted 2 lines

I'm curious to read how much you'll hate this. ;-)

We unfortunately still have to fix the quota scheduler first. Then the test case should operate over all scheduler types.

What is broken about the quota scheduler?
I have never used it TBH.

Quoted 2 lines

And the watchdog should be come a feature on top of the throttling: When enabled, also signal the currently running thread. When not, just throttle.

Fair.

Thanks,
//richard

Signature · 2 lines
​​​​​sigma star gmbh | Eduard-Bodem-Gasse 6, 6020 Innsbruck, AUT UID/VAT Nr:
ATU 66964118 | FN: 374287y
#8 lore raw
Quoted 15 lines · Richard Weinberger
Quoted 14 lines · On Dienstag, 1. Dezember 2026 16:29 'Jan Kiszka' via upstream wrote:
Quoted 13 lines · Richard Weinberger (sigma star gmbh)

From: Richard Weinberger <[email protected]>

This patch series implements an RT throttle like Linux has. It allows limiting the total CPU time used by Cobalt threads, if the limit is reached, Linux gets the CPU.

That way, misbehaving applications won't kill the system and will only get throttled instead of killed by the Xenomai runaway thread detection.
The main reason I need this feature is because for a rather specific use case, I need to limit the total available CPU time for all userspace, so Xenomai plus Linux.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

I'm curious to read how much you'll hate this. ;-)

We unfortunately still have to fix the quota scheduler first. Then the test case should operate over all scheduler types.

What is broken about the quota scheduler?
I have never used it TBH.

Everything. Still in my backlock to finalize the fix qualification.

You triggered that finding back then via the SIGSHADOW analysis. ;)

Quoted 9 lines
Quoted 3 lines

And the watchdog should be come a feature on top of the throttling: When enabled, also signal the currently running thread. When not, just throttle.

Fair.

Thanks,
//richard

Jan

Signature · 2 lines
Siemens AG, Foundational Technologies
Linux Expert Center
#9 lore raw
Quoted 9 lines · On Dienstag, 1. Dezember 2026 16:36 Jan Kiszka wrote:
Quoted 5 lines
Quoted 2 lines

We unfortunately still have to fix the quota scheduler first. Then the test case should operate over all scheduler types.

What is broken about the quota scheduler?
I have never used it TBH.

Everything. Still in my backlock to finalize the fix qualification.

You triggered that finding back then via the SIGSHADOW analysis. ;)

When it's broken all over the place, it has likely no users, so let's drop it?

Thanks,
/richard

Signature · 2 lines
​​​​​sigma star gmbh | Eduard-Bodem-Gasse 6, 6020 Innsbruck, AUT UID/VAT Nr:
ATU 66964118 | FN: 374287y
#10 lore raw
Quoted 4 lines · Richard Weinberger
Quoted 3 lines · On Dienstag, 1. Dezember 2026 16:36 Jan Kiszka wrote:
Quoted 3 lines
Quoted 2 lines

We unfortunately still have to fix the quota scheduler first. Then the test case should operate over all scheduler types.

Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

What is broken about the quota scheduler?
I have never used it TBH.

Everything. Still in my backlock to finalize the fix qualification.

You triggered that finding back then via the SIGSHADOW analysis. ;)

When it's broken all over the place, it has likely no users, so let's drop it?

It's part of Xenomai 4 as well, probably fixed there, but we need to qualify both anyway.

Jan

Signature · 2 lines
Siemens AG, Foundational Technologies
Linux Expert Center