Skip to content

Commit 4994f15

Browse files
intelfxbluca
authored andcommitted
core/exec-invoke: call setpriority() after sched_setattr()
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 711a157) (cherry picked from commit b628d4d)
1 parent e6f8282 commit 4994f15

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/core/exec-invoke.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4279,14 +4279,6 @@ int exec_invoke(
42794279
}
42804280
}
42814281

4282-
if (context->nice_set) {
4283-
r = setpriority_closest(context->nice);
4284-
if (r < 0) {
4285-
*exit_status = EXIT_NICE;
4286-
return log_exec_error_errno(context, params, r, "Failed to set up process scheduling priority (nice level): %m");
4287-
}
4288-
}
4289-
42904282
if (context->cpu_sched_set) {
42914283
struct sched_attr attr = {
42924284
.size = sizeof(attr),
@@ -4302,6 +4294,14 @@ int exec_invoke(
43024294
}
43034295
}
43044296

4297+
if (context->nice_set) {
4298+
r = setpriority_closest(context->nice);
4299+
if (r < 0) {
4300+
*exit_status = EXIT_NICE;
4301+
return log_exec_error_errno(context, params, r, "Failed to set up process scheduling priority (nice level): %m");
4302+
}
4303+
}
4304+
43054305
if (context->cpu_affinity_from_numa || context->cpu_set.set) {
43064306
_cleanup_(cpu_set_reset) CPUSet converted_cpu_set = {};
43074307
const CPUSet *cpu_set;

0 commit comments

Comments
 (0)