Skip to content

Conversation

@saku3
Copy link
Member

@saku3 saku3 commented May 6, 2025

Description

Add cpu affinity setting to the executed process.
Based on the following code, I added support for setting cpu affinity in Youki.
The implementation sets cpu affinity both before and after moving the intermediate process into the cgroup.
I also created tests based on the test cases from runc.

Summary

  • Applies initial CPU affinity in container_intermediate_process before moving to cgroup.
  • Applies final CPU affinity in container_intermediate_process after cgroup move.
  • Adds cpu_affinity module for parsing cpuset strings and calling sched_setaffinity.

Includes test coverage via contest for:

  • CPU affinity from config.json
  • CPU affinity from process.json in exec
  • Partial affinity (only initial) case

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test updates
  • CI/CD related changes
  • Other (please describe):

Testing

  • Added new unit tests
  • Added new integration tests
  • Ran existing test suite
  • Tested manually (please provide steps)

Related Issues

Fixes #2795

Additional Context

In runc, exec_cpu_affinity is introduced in version 1.3.0.
Since the current CI uses an older version of runc1.1.11, exec_cpu_affinity is not available and the test(just validate-contest-runc) will be skipped. The tests passed successfully when using runc version 1.3.0-rc.1.

@saku3 saku3 force-pushed the feat-exec-cpu-affinity branch from 2246207 to cdeae9a Compare May 25, 2025 00:36
Copy link
Member

@utam0k utam0k left a comment

Choose a reason for hiding this comment

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

💯

@utam0k
Copy link
Member

utam0k commented Jun 8, 2025

@saku3 LGTM except for the conflicts.

Signed-off-by: Yusuke Sakurai <[email protected]>
@saku3 saku3 force-pushed the feat-exec-cpu-affinity branch from cdeae9a to c304660 Compare June 9, 2025 11:04
@saku3
Copy link
Member Author

saku3 commented Jun 9, 2025

@utam0k
Thank you for the review! I've resolved the conflicts.

@utam0k utam0k merged commit 58c6cd6 into youki-dev:main Jun 10, 2025
29 checks passed
@github-actions github-actions bot mentioned this pull request Jun 10, 2025
@saku3 saku3 deleted the feat-exec-cpu-affinity branch June 10, 2025 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add CPU affinity to executed processes

3 participants