core: several follow-ups (#40140)

Replaces #39925
Closes #39925
This commit is contained in:
Yu Watanabe
2026-01-05 06:31:48 +09:00
committed by GitHub
3 changed files with 29 additions and 22 deletions
+6 -9
View File
@@ -5463,17 +5463,14 @@ int exec_invoke(
.sched_flags = context->cpu_sched_reset_on_fork ? SCHED_FLAG_RESET_ON_FORK : 0,
};
r = sched_setattr(/* pid= */ 0, &attr, /* flags= */ 0);
if (r < 0) {
if (errno != EINVAL || sched_policy_supported(attr.sched_policy)) {
*exit_status = EXIT_SETSCHEDULER;
return log_error_errno(errno, "Failed to set up CPU scheduling: %m");
}
r = RET_NERRNO(sched_setattr(/* pid= */ 0, &attr, /* flags= */ 0));
if (r == -EINVAL && !sched_policy_supported(context->cpu_sched_policy)) {
_cleanup_free_ char *s = NULL;
(void) sched_policy_to_string_alloc(context->cpu_sched_policy, &s);
log_warning_errno(errno, "CPU scheduling policy %s is not supported, proceeding without.", strna(s));
log_warning_errno(r, "CPU scheduling policy %s is not supported, proceeding without.", strna(s));
} else if (r < 0) {
*exit_status = EXIT_SETSCHEDULER;
return log_error_errno(r, "Failed to set up CPU scheduling: %m");
}
}