mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
libct: unify IOPriority setting
For some reason, io priority is set in different places between runc
start/run and runc exec:
- for runc start/run, it is done in the middle of (*linuxStandardInit).Init,
close to the place where we exec runc init.
- for runc exec, it is done much earlier, in (*setnsProcess) start().
Let's move setIOPriority call for runc exec to (*linuxSetnsInit).Init,
so it is in the same logical place as for runc start/run.
Also, move the function itself to init_linux.go as it's part of init.
Should not have any visible effect, except part of runc init is run with
a different I/O priority.
While at it, rename setIOPriority to setupIOPriority, and make it accept
the whole *configs.Config, for uniformity with other similar functions.
Fixes: bfbd0305 ("Add I/O priority")
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@@ -678,6 +678,28 @@ func setupScheduler(config *configs.Config) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func setupIOPriority(config *configs.Config) error {
|
||||
const ioprioWhoPgrp = 1
|
||||
|
||||
ioprio := config.IOPriority
|
||||
if ioprio == nil {
|
||||
return nil
|
||||
}
|
||||
class, ok := configs.IOPrioClassMapping[ioprio.Class]
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid io priority class: %s", ioprio.Class)
|
||||
}
|
||||
|
||||
// Combine class and priority into a single value
|
||||
// https://github.com/torvalds/linux/blob/v5.18/include/uapi/linux/ioprio.h#L5-L17
|
||||
iop := (class << 13) | ioprio.Priority
|
||||
_, _, errno := unix.RawSyscall(unix.SYS_IOPRIO_SET, ioprioWhoPgrp, 0, uintptr(iop))
|
||||
if errno != 0 {
|
||||
return fmt.Errorf("failed to set io priority: %w", errno)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func setupPersonality(config *configs.Config) error {
|
||||
return system.SetLinuxPersonality(config.Personality.Domain)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user