process-util: Add support SCHED_EXT scheduling policy
Allow CPUSchedulingPolicy to be set to "ext". SCHED_EXT is a new scheduling policy in Linux v6.12 that allows processes to be scheduled using custom BPF schedulers instead of the default in-kernel ones. Selectively setting the SCHED_EXT policy is useful for systems running in "partial mode" where not all processes are run using a custom scheduler. Fallback to SCHED_OTHER and print an error message for systems where SCHED_EXT isn't available.
This commit is contained in:
@@ -3167,7 +3167,7 @@ int bus_exec_context_set_transient_property(
|
||||
return r;
|
||||
|
||||
c->cpu_sched_policy = q;
|
||||
c->cpu_sched_priority = CLAMP(c->cpu_sched_priority, sched_get_priority_min(q), sched_get_priority_max(q));
|
||||
c->cpu_sched_priority = CLAMP(c->cpu_sched_priority, sched_get_priority_min_safe(q), sched_get_priority_max_safe(q));
|
||||
c->cpu_sched_set = true;
|
||||
|
||||
unit_write_settingf(u, flags, name, "CPUSchedulingPolicy=%s", s);
|
||||
|
||||
@@ -5473,8 +5473,12 @@ int exec_invoke(
|
||||
|
||||
r = sched_setattr(/* pid= */ 0, &attr, /* flags= */ 0);
|
||||
if (r < 0) {
|
||||
*exit_status = EXIT_SETSCHEDULER;
|
||||
return log_error_errno(errno, "Failed to set up CPU scheduling: %m");
|
||||
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");
|
||||
}
|
||||
|
||||
log_warning_errno(errno, "CPU scheduling policy %u is not supported, ignoring: %m", attr.sched_policy);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1539,9 +1539,12 @@ int config_parse_exec_cpu_sched_policy(
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!sched_policy_supported(x))
|
||||
log_syntax(unit, LOG_WARNING, filename, line, x, "Unsupported CPU scheduling policy: %s", rvalue);
|
||||
|
||||
c->cpu_sched_policy = x;
|
||||
/* Moving to or from real-time policy? We need to adjust the priority */
|
||||
c->cpu_sched_priority = CLAMP(c->cpu_sched_priority, sched_get_priority_min(x), sched_get_priority_max(x));
|
||||
c->cpu_sched_priority = CLAMP(c->cpu_sched_priority, sched_get_priority_min_safe(x), sched_get_priority_max_safe(x));
|
||||
c->cpu_sched_set = true;
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user