From: Shashank Balaji Date: Fri, 16 May 2025 09:33:45 +0000 (+0900) Subject: chrt: add support for SCHED_EXT X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ae4e6b20e2f6d140478627ec2df1e9f8a5113ef8;p=thirdparty%2Futil-linux.git chrt: add support for SCHED_EXT SCHED_EXT lets processes be scheduled by a BPF program-defined scheduler. This is supported since kernel version 6.12. Signed-off-by: Shashank Balaji --- diff --git a/schedutils/chrt.c b/schedutils/chrt.c index 4f6a027f3..075b592bb 100644 --- a/schedutils/chrt.c +++ b/schedutils/chrt.c @@ -71,6 +71,7 @@ static void __attribute__((__noreturn__)) usage(void) fputs(_("Policy options:\n"), out); fputs(_(" -b, --batch set policy to SCHED_BATCH\n"), out); fputs(_(" -d, --deadline set policy to SCHED_DEADLINE\n"), out); + fputs(_(" -e, --ext set policy to SCHED_EXT\n"), out); fputs(_(" -f, --fifo set policy to SCHED_FIFO\n"), out); fputs(_(" -i, --idle set policy to SCHED_IDLE\n"), out); fputs(_(" -o, --other set policy to SCHED_OTHER\n"), out); @@ -120,6 +121,10 @@ static const char *get_policy_name(int policy) #ifdef SCHED_DEADLINE case SCHED_DEADLINE: return "SCHED_DEADLINE"; +#endif +#ifdef SCHED_EXT + case SCHED_EXT: + return "SCHED_EXT"; #endif default: break; @@ -289,6 +294,9 @@ static void show_min_max(void) #endif #ifdef SCHED_DEADLINE SCHED_DEADLINE, +#endif +#ifdef SCHED_EXT + SCHED_EXT, #endif }; @@ -397,6 +405,7 @@ int main(int argc, char **argv) { "all-tasks", no_argument, NULL, 'a' }, { "batch", no_argument, NULL, 'b' }, { "deadline", no_argument, NULL, 'd' }, + { "ext", no_argument, NULL, 'e' }, { "fifo", no_argument, NULL, 'f' }, { "idle", no_argument, NULL, 'i' }, { "pid", no_argument, NULL, 'p' }, @@ -418,7 +427,7 @@ int main(int argc, char **argv) textdomain(PACKAGE); close_stdout_atexit(); - while((c = getopt_long(argc, argv, "+abdD:fiphmoP:T:rRvV", longopts, NULL)) != -1) + while((c = getopt_long(argc, argv, "+abdD:efiphmoP:T:rRvV", longopts, NULL)) != -1) { switch (c) { case 'a': @@ -433,6 +442,11 @@ int main(int argc, char **argv) case 'd': #ifdef SCHED_DEADLINE ctl->policy = SCHED_DEADLINE; +#endif + break; + case 'e': +#ifdef SCHED_EXT + ctl->policy = SCHED_EXT; #endif break; case 'f': diff --git a/schedutils/sched_attr.h b/schedutils/sched_attr.h index b7559434c..e597bced8 100644 --- a/schedutils/sched_attr.h +++ b/schedutils/sched_attr.h @@ -124,4 +124,12 @@ static int sched_getattr(pid_t pid, struct sched_attr *attr, unsigned int size, # define SCHED_DEADLINE 6 #endif +/* the SCHED_EXT is supported since Linux 6.12 + * commit id f0e1a0643a59bf1f922fa209cec86a170b784f3f + * -- temporary workaround for people with old glibc headers + */ +#if defined(__linux__) && !defined(SCHED_EXT) +# define SCHED_EXT 7 +#endif + #endif /* UTIL_LINUX_SCHED_ATTR_H */