From: Furkan Caliskan <frn1furkan10@gmail.com>
To: util-linux@vger.kernel.org
Cc: kzak@redhat.com, bensberg@telfort.nl, vineethr@linux.ibm.com,
Furkan Caliskan <frn1furkan10@gmail.com>
Subject: [PATCH] chrt: Add support for (GRUB) bandwidth reclaim
Date: Thu, 23 Apr 2026 13:14:07 +0300 [thread overview]
Message-ID: <20260423101407.35502-1-frn1furkan10@gmail.com> (raw)
The SCHED_DEADLINE policy supports the (GRUB) Greedy Reclamation
of Unused Bandwidth algorithm. This allows tasks to reclaim
bandwidth that are left over by other deadline tasks that finish
their work early, or voluntarily yield the cpu.
Currently, chrt has no way to set the SCHED_FLAG_RECLAIM bit in
the sched_flags field of the sched_attr structure.
Add -G/--reclaim-grub option to allow users to toggle this feature
using the deadline scheduling class.
Signed-off-by: Furkan Caliskan <frn1furkan10@gmail.com>
---
schedutils/chrt.1.adoc | 3 +++
schedutils/chrt.c | 13 ++++++++++++-
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/schedutils/chrt.1.adoc b/schedutils/chrt.1.adoc
index b8d8874bc..da607d958 100644
--- a/schedutils/chrt.1.adoc
+++ b/schedutils/chrt.1.adoc
@@ -83,6 +83,9 @@ Specifies deadline parameter for *SCHED_DEADLINE* policy (Linux-specific).
*-R*, *--reset-on-fork*::
Use *SCHED_RESET_ON_FORK* or *SCHED_FLAG_RESET_ON_FORK* flag. Linux-specific, supported since 2.6.31.
+
+*-G*, *--reclaim-grub*::
+Enables GRUB (Greedy Reclamation of Unused Bandwidth) algorithm.
+
Each thread has a _reset-on-fork_ scheduling flag. When this flag is set, children created by *fork*(2) do not inherit privileged scheduling policies. After the _reset-on-fork_ flag has been enabled, it can be reset only if the thread has the *CAP_SYS_NICE* capability. This flag is disabled in child processes created by *fork*(2).
+
diff --git a/schedutils/chrt.c b/schedutils/chrt.c
index 273905e5d..1a081e566 100644
--- a/schedutils/chrt.c
+++ b/schedutils/chrt.c
@@ -46,6 +46,7 @@ struct chrt_ctl {
uint64_t runtime; /* --sched-* options */
uint64_t deadline;
uint64_t period;
+ uint64_t flag; /* For sched_attr->sched_flags member */
unsigned int all_tasks : 1, /* all threads of the PID */
reset_on_fork : 1, /* SCHED_RESET_ON_FORK or SCHED_FLAG_RESET_ON_FORK */
@@ -79,6 +80,7 @@ static void __attribute__((__noreturn__)) usage(void)
fputs(USAGE_SEPARATOR, out);
fputs(_("Scheduling options:\n"), out);
fputs(_(" -R, --reset-on-fork set reset-on-fork flag\n"), out);
+ fputs(_(" -G, --reclaim-grub set SCHED_FLAG_RECLAIM\n"), out);
fputs(_(" -T, --sched-runtime <ns> runtime parameter for DEADLINE\n"), out);
fputs(_(" -P, --sched-period <ns> period parameter for DEADLINE\n"), out);
fputs(_(" -D, --sched-deadline <ns> deadline parameter for DEADLINE\n"), out);
@@ -349,7 +351,7 @@ static int set_sched_one(struct chrt_ctl *ctl, pid_t pid)
/* old API is good enough for non-deadline */
if (!supports_runtime_param(ctl->policy))
return set_sched_one_by_setscheduler(ctl, pid);
-
+
/* not changed by chrt, follow the current setting */
sa.sched_nice = getpriority(PRIO_PROCESS, pid);
@@ -359,6 +361,7 @@ static int set_sched_one(struct chrt_ctl *ctl, pid_t pid)
sa.sched_runtime = ctl->runtime;
sa.sched_period = ctl->period;
sa.sched_deadline = ctl->deadline;
+ sa.sched_flags = ctl->flag;
# ifdef SCHED_FLAG_RESET_ON_FORK
/* Don't use SCHED_RESET_ON_FORK for sched_setattr()! */
@@ -417,6 +420,7 @@ int main(int argc, char **argv)
{ "sched-period", required_argument, NULL, 'P' },
{ "sched-deadline", required_argument, NULL, 'D' },
{ "reset-on-fork", no_argument, NULL, 'R' },
+ { "reclaim-grub", no_argument, NULL, 'G' },
{ "verbose", no_argument, NULL, 'v' },
{ "version", no_argument, NULL, 'V' },
{ NULL, no_argument, NULL, 0 }
@@ -460,6 +464,11 @@ int main(int argc, char **argv)
case 'R':
ctl->reset_on_fork = 1;
break;
+ case 'G':
+#ifdef SCHED_DEADLINE
+ ctl->flag |= SCHED_FLAG_RECLAIM;
+#endif
+ break;
case 'i':
#ifdef SCHED_IDLE
ctl->policy = SCHED_IDLE;
@@ -546,6 +555,8 @@ int main(int argc, char **argv)
if ((ctl->deadline || ctl->period) && ctl->policy != SCHED_DEADLINE)
errx(EXIT_FAILURE, _("--sched-{deadline,period} options are "
"supported for SCHED_DEADLINE only"));
+ if ((ctl->flag & SCHED_FLAG_RECLAIM) && ctl->policy != SCHED_DEADLINE)
+ errx(EXIT_FAILURE, _("--reclaim-grub is only supported for SCHED_DEADLINE"));
if (ctl->policy == SCHED_DEADLINE) {
/* The basic rule is runtime <= deadline <= period, so we can
* make deadline and runtime optional on command line. Note we
--
2.34.1
next reply other threads:[~2026-04-23 10:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-23 10:14 Furkan Caliskan [this message]
2026-05-11 11:10 ` [PATCH] chrt: Add support for (GRUB) bandwidth reclaim Karel Zak
2026-05-11 14:10 ` [PATCH v2] " Furkan Caliskan
2026-05-13 9:56 ` Karel Zak
2026-05-11 11:20 ` [PATCH] " Karel Zak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260423101407.35502-1-frn1furkan10@gmail.com \
--to=frn1furkan10@gmail.com \
--cc=bensberg@telfort.nl \
--cc=kzak@redhat.com \
--cc=util-linux@vger.kernel.org \
--cc=vineethr@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox