Skip to content

Commit

Permalink
core/exec-invoke: call setpriority() after sched_setattr()
Browse files Browse the repository at this point in the history
The nice value is part of struct sched_attr, and consequently invoking
sched_setattr() after setpriority() would clobber the nice value with
the default (as we are not setting it in struct sched_attr).

It would be best to combine both calls, but for now simply invoke
setpriority() after sched_setattr() to make sure Nice= remains effective
when used together with CPUSchedulingPolicy=.

(cherry picked from commit 711a157738b3dcd29a5ebc8f498eb46bfac59652)
(cherry picked from commit b628d4dfa61234d28ffaa648ec09c5e9972f832a)
  • Loading branch information
intelfx authored and bluca committed Aug 16, 2024
1 parent e6f8282 commit 4994f15
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/core/exec-invoke.c
Original file line number Diff line number Diff line change
Expand Up @@ -4279,14 +4279,6 @@ int exec_invoke(
}
}

if (context->nice_set) {
r = setpriority_closest(context->nice);
if (r < 0) {
*exit_status = EXIT_NICE;
return log_exec_error_errno(context, params, r, "Failed to set up process scheduling priority (nice level): %m");
}
}

if (context->cpu_sched_set) {
struct sched_attr attr = {
.size = sizeof(attr),
Expand All @@ -4302,6 +4294,14 @@ int exec_invoke(
}
}

if (context->nice_set) {
r = setpriority_closest(context->nice);
if (r < 0) {
*exit_status = EXIT_NICE;
return log_exec_error_errno(context, params, r, "Failed to set up process scheduling priority (nice level): %m");
}
}

if (context->cpu_affinity_from_numa || context->cpu_set.set) {
_cleanup_(cpu_set_reset) CPUSet converted_cpu_set = {};
const CPUSet *cpu_set;
Expand Down

0 comments on commit 4994f15

Please sign in to comment.