In order to use SCHED_DEADLINE we need sched_setattr(), as sched_setscheduler() does not support all the necessary parameters. Signed-off-by: Sasha Algisi <sasha.algisi@xxxxxxxxxxxx> Signed-off-by: Dario Faggioli <dfaggioli@xxxxxxxx> --- src/util/virprocess.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/util/virprocess.c b/src/util/virprocess.c index 013afd91b4..a8f86784e1 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -51,6 +51,10 @@ # include <sys/cpuset.h> #endif +#if WITH_SYS_SYSCALL_H +# include <sys/syscall.h> +#endif + #ifdef WIN32 # define WIN32_LEAN_AND_MEAN # include <windows.h> @@ -67,6 +71,10 @@ #define VIR_FROM_THIS VIR_FROM_NONE +#if defined(__linux__) && !defined(SCHED_FLAG_RESET_ON_FORK) +# define SCHED_FLAG_RESET_ON_FORK 0x01 +#endif + VIR_LOG_INIT("util.process"); VIR_ENUM_IMPL(virProcessSchedPolicy, @@ -79,6 +87,37 @@ VIR_ENUM_IMPL(virProcessSchedPolicy, ); +#if defined(__linux__) && defined(SCHED_DEADLINE) + +struct sched_attr { + uint32_t size; + uint32_t sched_policy; + uint64_t sched_flags; + + /*SCHED_OTHER, SCHED_BATCH*/ + int32_t sched_nice; + + /*SCHED_FIFO, SCHED_RR*/ + uint32_t sched_priority; + + /*SCHED_DEADLINE*/ + uint64_t sched_runtime; + uint64_t sched_deadline; + uint64_t sched_period; +}; + + +static +int sched_setattr(pid_t pid, + struct sched_attr *attr, + unsigned int flags) +{ + return syscall(SYS_sched_setattr, pid, attr, flags); +} + +#endif + + #ifndef WIN32 /** * virProcessTranslateStatus: -- 2.37.1 -- ------------------------ Indirizzo istituzionale di posta elettronica degli studenti e dei laureati dell'Università di TorinoOfficial University of Turin email address for students and graduates