Skip to content

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 fuweid and mikebrow 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


// 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 4 times, most recently 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

@klihub
Copy link
Member Author

klihub commented Jul 3, 2025

@mikebrow Should we merge this ?

klihub added 2 commits July 14, 2025 16:50
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 06bf5aa to 3ad35fa Compare July 14, 2025 14:16
@mikebrow mikebrow added the v.next to be merged into the next release label Jul 14, 2025
@mikebrow mikebrow merged commit 60a9851 into containerd:main Jul 14, 2025
7 checks passed
@klihub klihub deleted the devel/linux-io-priority branch July 15, 2025 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v.next to be merged into the next release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants