Skip to content

api,adaptation,generate: allow setting container I/O priority. #155

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

klihub
Copy link
Member

@klihub klihub commented Apr 7, 2025

Allow plugins to set container I/O class/priority.

Here is corresponding Process.IOPriority OCI Spec field this PR allows adjusting: https://github.com/opencontainers/runtime-spec/blob/524fc0e1b8ab0180e2fc9abd31837a0f4ed1fd6b/specs-go/config.go#L96

Here is how LinuxIOPriority and other related types are defined in the OCI Spec: https://github.com/opencontainers/runtime-spec/blob/524fc0e1b8ab0180e2fc9abd31837a0f4ed1fd6b/specs-go/config.go#L117

The related NRI types are all straightforward protobuf defined message representations of the corresponding OCI Spec types.

@klihub klihub requested review from mikebrow and fuweid April 7, 2025 10:32
@klihub klihub force-pushed the devel/linux-io-priority branch 11 times, most recently from cb1dc14 to 820728f Compare April 8, 2025 08:29
Copy link
Member

@mikebrow mikebrow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see question/comment.. on the ability to use ioprio_set() to send the mask 0 meaning class & value is none.. to request kernel 2.6.24+ to unset any previously set priority

@@ -340,6 +341,13 @@ func (g *Generator) AdjustOomScoreAdj(score *nri.OptionalInt) {
}
}

// AdjustIOPriority adjusts the IO priority of the container.
func (g *Generator) AdjustIOPriority(ioprio *nri.LinuxIOPriority) {
if ioprio != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this indicate once the optional linux process io priority has been set, it can't be adjusted to unset?

was surprised to see there was no description for setting the IO priority class to default in the oci runtime... excerpt from linux man: If no I/O scheduler has been set for a thread, then by default the I/O priority will follow the CPU nice value ([setpriority(2)](https://www.man7.org/linux/man-pages/man2/setpriority.2.html)). Before Linux 2.6.24, once an I/O priority had been set using ioprio_set(), there was no way to reset the I/O scheduling behavior to the default. Since Linux 2.6.24, specifying ioprio as 0 can be used to reset to the default I/O scheduling behavior.

Copy link
Member Author

@klihub klihub Apr 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mikebrow Hey, it's almost like you read my mind. This is just what I was addressing in the last force push, but you beat me to it with your review comment. Now setting I/O priority to IOPRIO_CLASS_NONE on the NRI side should cause clearing any set I/O priority in the container's OCI Spec. Although it is not handled here but in SetProcessIOPriority. IOPRIO_CLASS_NONE will cause an empty ("") runtime Spec I/O priority class to be set, which is then interpreted as a marker for clearing any potentially set I/O priority in the Spec.

@klihub klihub force-pushed the devel/linux-io-priority branch from 820728f to 0baf766 Compare April 8, 2025 17:37
@klihub klihub requested a review from mikebrow April 8, 2025 17:47

case "clear I/O priority":
a.SetLinuxIOPriority(&nri.LinuxIOPriority{
Class: api.IOPrioClass_IOPRIO_CLASS_NONE,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:
Priority: 0, // :-)

Copy link
Member

@mikebrow mikebrow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dmcgowan dmcgowan self-requested a review May 8, 2025 16:26
@klihub klihub force-pushed the devel/linux-io-priority branch 3 times, most recently from 7c0510d to 7f12b29 Compare June 13, 2025 07:11
klihub added 2 commits June 13, 2025 10:27
Allow setting/resetting container I/O priority.

Signed-off-by: Krisztian Litkey <[email protected]>
@klihub klihub force-pushed the devel/linux-io-priority branch from 7f12b29 to 06bf5aa Compare June 13, 2025 07:27
@klihub klihub requested a review from djdongjin June 14, 2025 07:41
Copy link
Member

@djdongjin djdongjin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants