container: set scheduling policy
All checks were successful
Test / Create distribution (push) Successful in 1m59s
Test / Hakurei (push) Successful in 10m58s
Test / ShareFS (push) Successful in 11m11s
Test / Hakurei (race detector) (push) Successful in 15m14s
Test / Sandbox (push) Successful in 4m4s
Test / Hpkg (push) Successful in 4m29s
Test / Sandbox (race detector) (push) Successful in 2m49s
Test / Flake checks (push) Successful in 1m50s
All checks were successful
Test / Create distribution (push) Successful in 1m59s
Test / Hakurei (push) Successful in 10m58s
Test / ShareFS (push) Successful in 11m11s
Test / Hakurei (race detector) (push) Successful in 15m14s
Test / Sandbox (push) Successful in 4m4s
Test / Hpkg (push) Successful in 4m29s
Test / Sandbox (race detector) (push) Successful in 2m49s
Test / Flake checks (push) Successful in 1m50s
This is thread-directed so cannot be done externally. The glibc wrapper exposes this behaviour so most multithreaded programs using this is straight up incorrect. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -37,6 +37,9 @@ type (
|
||||
Container struct {
|
||||
// Whether the container init should stay alive after its parent terminates.
|
||||
AllowOrphan bool
|
||||
// Scheduling policy to set via sched_setscheduler(2). The zero value
|
||||
// skips this call. Supported policies are [SCHED_BATCH], [SCHED_IDLE].
|
||||
SchedPolicy int
|
||||
// Cgroup fd, nil to disable.
|
||||
Cgroup *int
|
||||
// ExtraFiles passed through to initial process in the container,
|
||||
@@ -342,6 +345,23 @@ func (p *Container) Start() error {
|
||||
landlockOut:
|
||||
}
|
||||
|
||||
// sched_setscheduler: thread-directed but acts on all processes
|
||||
// created from that thread
|
||||
if p.SchedPolicy > 0 {
|
||||
p.msg.Verbosef("setting scheduling policy %d", p.SchedPolicy)
|
||||
if err := schedSetscheduler(
|
||||
0, // calling thread
|
||||
p.SchedPolicy,
|
||||
&schedParam{0},
|
||||
); err != nil {
|
||||
return &StartError{
|
||||
Fatal: true,
|
||||
Step: "enforce landlock ruleset",
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
p.msg.Verbose("starting container init")
|
||||
if err := p.cmd.Start(); err != nil {
|
||||
return &StartError{false, "start container init", err, false, true}
|
||||
|
||||
Reference in New Issue
Block a user