sys: add AdjustOOMScore() utility

Handle the limits in this function so that consumers don't have to
perform the boundary checks.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2021-03-23 11:50:32 +01:00
parent 44240116aa
commit 91e7d21ee8
4 changed files with 21 additions and 8 deletions

View File

@@ -182,10 +182,7 @@ func setupOOMScore(shimPid int) error {
return errors.Wrap(err, "get daemon OOM score")
}
shimScore := score + 1
if shimScore > sys.OOMScoreAdjMax {
shimScore = sys.OOMScoreAdjMax
}
if err := sys.SetOOMScore(shimPid, shimScore); err != nil {
if err := sys.AdjustOOMScore(shimPid, shimScore); err != nil {
return errors.Wrap(err, "set shim OOM score")
}
return nil