oci: correct sub-core CPU quota mapping and add cpuset to cpu_cores affinity#102
Merged
Conversation
Signed-off-by: Cong Wang <cwang@multikernel.io>
Signed-off-by: Cong Wang <cwang@multikernel.io>
Contributor
Author
|
@sachin2605 Please take a look. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Improves OCI CPU resource mapping in
sandlock-oci, correcting one mapping and adding a missing one. Two focused commits.1. Map only enforceable sub-core CPU quota to
max_cputhrottlecpu.quota/cpu.periodwas mapped with((quota/period)*100).min(100.0). The.min(100.0)silently discarded any>= 1-core request, and combined with core'sif cpu_pct < 100guard a>= 1-core quota becamemax_cpu = 100, which core reads as no limit at all.quota < period): map to 1-99%, flooring to 1 so a tiny fraction isn't truncated to 0 (and silently dropped to "no limit").>= 1core: left unmapped.max_cpuis a coarse globalSIGSTOP/SIGCONTwall-clock duty cycle, not a bandwidth controller, and a multi-core allowance can't be expressed as a 1-100 value. A multi-core cap belongs on affinity, not this throttle.2. Map
cpu.cpuscpuset tocpu_coresaffinityOCI
cpu.cpus(e.g."0-3,7") was dropped entirely. It maps exactly to core'scpu_cores(sched_setaffinity), so this is genuine, non-approximate multi-core enforcement, and it is what the field means.parse_cpusethelper: comma-separated indices and inclusive ranges, sorted and de-duplicated; malformed/empty input drops toNone(no partial pinning).OciPolicy.cpu_coresfield, wired throughfrom_specandto_sandbox.Testing
9 new unit tests (CPU quota cases + cpuset parsing + end-to-end mapping). Full
sandlock-ocisuite: 37 passed, clean build.Out of scope
A pure multi-core quota with no
cpu.cpuspresent (the approximate pin-to-N-cores hack) is intentionally not implemented, its bandwidth-vs-pinning tradeoff is a separate design decision.