Skip to content

DRA: export claimed CPUs to topology-aware containers - #834

Merged
klihub merged 2 commits into
mainfrom
stacked/bart0sh/DRA/010-export-claimed-cpus
Oct 16, 2026
Merged

klihub merged 2 commits into
mainfrom
stacked/bart0sh/DRA/010-export-claimed-cpus

Conversation

@bart0sh

@bart0sh bart0sh commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

Exporting claimed CPUs to topology-aware containers

Tenth PR of the DRA series, on top of #831. Two commits.

As requested in the #821 review, ExportResourceData() now also exports the CPUs of the DRA claims of a container. The container finds them as CLAIMED_CPUS in /.nri-resource-policy/resources.sh, next to ISOLATED_CPUS, EXCLUSIVE_CPUS and SHARED_CPUS. For example, for a container with a claim for CPUs 8-9 and a small CPU request of its own:

CLAIMED_CPUS="8-9"
SHARED_CPUS="10-11"

CLAIMED_CPUS is the union of all claims of the container. The CPUs of each claim are still in the DRA_CPUSET_<claim UID> environment variables in this PR; #852, the next one, drops them, so CLAIMED_CPUS then becomes the only place. The other variables keep listing only the container's own CPUs, so a claimed CPU that is kernel-isolated is listed only in CLAIMED_CPUS.

The name is a common constant in pkg/resmgr/policy, ExportClaimedCPUs, next to the existing ones. Balloons and template export no resource data, so they are not changed.

Commits

  1. topology-aware: export the CPUs of DRA claims.
  2. e2e: test exporting claimed CPUs. Extends test42-dra-devices.

Testing

  • TestExportClaimedCPUs covers a besteffort and an exclusive container holding a claim, and a container holding none. It also checks that the other exported CPU sets have no claimed CPUs.
  • test42-dra-devices passes on n4c16 with Kubernetes 1.37 and containerd v2.4.1. pod0 exports the CPUs of its claim, pod4 holds no claim and exports none, and pod7, which also has a CPU request of its own, exports its claimed CPUs and the rest of its node as SHARED_CPUS.

@bart0sh
bart0sh added this pull request to stack #807 October 13, 2026 08:53
@bart0sh bart0sh changed the title stacked/bart0sh/DRA/010 export claimed cpus DRA: export claimed CPUs to topology-aware containers Oct 13, 2026
@bart0sh
bart0sh force-pushed the stacked/bart0sh/DRA/010-export-claimed-cpus branch 2 times, most recently from f144bdb to f241508 Compare October 15, 2026 11:34
@klihub
klihub force-pushed the stacked/bart0sh/DRA/010-export-claimed-cpus branch from f241508 to 0d7382c Compare October 15, 2026 11:41
@bart0sh
bart0sh force-pushed the stacked/bart0sh/DRA/010-export-claimed-cpus branch from 0d7382c to e79e8c3 Compare October 15, 2026 12:09
@bart0sh
bart0sh force-pushed the stacked/bart0sh/DRA/010-export-claimed-cpus branch 2 times, most recently from f241508 to b904425 Compare October 15, 2026 12:55
@bart0sh
bart0sh marked this pull request as ready for review October 15, 2026 13:48
@bart0sh
bart0sh requested a balanced review from Copilot October 15, 2026 13:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The additive export uses existing claim accounting consistently, with focused test coverage and no identified blocking issues.

0 open findings

What changed in this PR

Adds CLAIMED_CPUS to topology-aware containers’ exported resource data, keeping DRA claim CPUs separate from their own CPU allocations.

Changes:

  • Defines and exports the shared CLAIMED_CPUS variable.
  • Adds unit and end-to-end checks for claimed CPUs and separation from other exported CPU sets.
File Description
test/​e2e/​policies.test-suite/​topology-aware/​n4c16/​test42-dra-devices/​code.var.sh Checks claimed and shared CPU exports in containers.
pkg/​resmgr/​policy/​policy.go Defines the claimed-CPU export constant.
cmd/​plugins/​topology-aware/​policy/​topology-aware-policy.go Exports nonempty claimed CPU sets.
cmd/​plugins/​topology-aware/​policy/​dra_test.go Tests exports with and without claims.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@klihub klihub left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM.

@askervin askervin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@klihub
klihub force-pushed the stacked/bart0sh/DRA/010-export-claimed-cpus branch from b904425 to dddf38e Compare October 16, 2026 09:05
Base automatically changed from stacked/bart0sh/DRA/009-pcie-roots to main October 16, 2026 11:25
Export the CPUs of the DRA claims of a container in CLAIMED_CPUS, next
to its own isolated, exclusive and shared CPUs.

Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
@askervin
askervin force-pushed the stacked/bart0sh/DRA/010-export-claimed-cpus branch from dddf38e to 7299cee Compare October 16, 2026 11:26
@klihub
klihub merged commit 0cba4c1 into main Oct 16, 2026
12 checks passed
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.

4 participants