← Back to Pull requests

DRA: publish PCIe roots on topology-aware devices #831

Merged
bart0sh merged 13 files (475 lines) on Oct 16, 2026 11:25 UTC
View on GitHub
bart0sh bart0sh commented on Oct 12, 2026 12:54 UTC
Author

Publishing PCIe roots on topology-aware DRA devices

Ninth PR of the DRA series, on top of #829. Four commits.

Each topology-aware DRA device now has the standard resource.kubernetes.io/pcieRoot attribute: the PCIe roots of the device's CPU socket. With it, a claim can use matchAttribute to get CPUs and a device of another driver, such as a NIC, under the same PCIe root.

Which roots a device lists

The kernel reports the CPUs local to a PCIe root in /sys/devices/pciDDDD:BB/pci_bus/DDDD:BB/cpulistaffinity. It computes them from the NUMA node of the root. With sub-NUMA clustering, this is one zone of the socket, but the root is equally close to all zones of the socket. So sysfs discovery gives a root to every package that its local CPUs are in. Every NUMA device of a package lists all the roots of that package.

For example, on a two-socket machine with SNC2, so four NUMA nodes, root pci0000:5d reports only the CPUs of node 2. Nodes 0 and 2 both list pci0000:00, pci0000:17, pci0000:3a and pci0000:5d.

CPUPackage.PCIeRoots() returns the roots of a package, sorted. A root whose cpulistaffinity cannot be read is skipped.

Clusters without list attributes

pcieRoot is a list attribute. List attributes need the DRAListTypeAttributes feature gate (KEP-5491), which is alpha and off by default. Without the gate, the API server rejects the whole ResourceSlice, so no devices would be published at all.

A driver cannot read the gate, so the DRA plugin asks the API server. When the plugin is created, it does a server-side dry run of a slice with a list attribute. Any failure counts as no support. Policies get the result from Owner.DRAListAttributesSupported(), and topology-aware leaves pcieRoot out without support. The driver itself still does not look at device attributes.

A slice with list attributes holds at most 64 devices, not 128. The plugin now always splits the devices into slices of 64.

What is not here

  • The probe runs once, when the plugin starts. If the feature gate changes later, the plugin needs a restart to see it.

  • Claims do not survive a restart, and no DeviceClass ships yet, as in the earlier PRs of the series.
  • Verification

  • go test -race passes for sysfs, resmgr, the DRA plugin and the template, balloons and topology-aware policies, and golangci-lint finds no issues.

  • TestRecordedPCIeRoots checks the roots of each package in the recorded sample. TestDiscoverPCIeRoots also covers a root reporting CPUs of both sockets, a root in no package, and roots that cannot be read.

  • TestProbeListAttributes covers an accepted, a rejected and a failed probe, and checks that the probe is a dry run.

  • TestDRAPCIeRoots checks that no roots are published without support, and that the roots of package 0 appear on its two NUMA nodes once there is support.

  • test43-dra-pcie-roots and test42-dra-devices pass on n4c16 with Kubernetes 1.37 and containerd v2.4.1, with and without DRAListTypeAttributes. With the gate, every device lists the only root of the VM, pci0000:00. Without it, the devices are published without pcieRoot.

  • The discovery also ran on the real two-socket SNC2 machine, and gave the same roots as the recorded sample.
  • Diff: 475 lines (+455 / -20) across 13 files Reviewer: klihub Review duration: 5671m
    All Vouch review confidence checks passed
    Residual risk 0.25 = Change Risk (0.57) × (1 − Review Confidence (0.56)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.57 · 475 lines diff across 13 files
    0.57
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.12 · 1 substantive comment(s)
    0.12
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.369
    Shallow Review Depth shallow_review_depth
    0.309
    Real PR Conversation Timeline
    4 items
    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Oct 12, 2026 13:20 UTC
    Reviewer

    <!-- ccr-overview-v2 -->

    🟢 Approval recommended

    Discovery, compatibility probing, publication, and slice sizing are consistently implemented and well tested.

    0 open findings

    <details>
    <summary><strong>What changed in this PR</strong></summary>

    Adds PCIe-root topology attributes to topology-aware DRA devices while remaining compatible with clusters lacking list-attribute support.

    Changes:

  • Discovers and maps PCIe roots to CPU packages.

  • Probes API-server support for list attributes and publishes roots conditionally.

  • Adds unit, recorded-sysfs, and end-to-end coverage.
  • | File | Description |
    | ---- | ----------- |
    | pkg/​sysfs/​system.go | Discovers package-local PCIe roots. |
    | pkg/​sysfs/​pcie_test.go | Tests PCIe-root discovery edge cases. |
    | pkg/​sysfs/​system_test.go | Verifies recorded root topology. |
    | pkg/​sysfs/​test-setup.sh | Extracts the new sample. |
    | pkg/​sysfs/​test-data-sample3.tar.xz | Provides recorded SNC topology. |
    | pkg/​resmgr/​dra/​plugin.go | Probes list support and limits slice size. |
    | pkg/​resmgr/​dra/​plugin_test.go | Tests probing and slice splitting. |
    | pkg/​resmgr/​dra.go | Exposes probe results to policies. |
    | pkg/​resmgr/​policy/​policy.go | Extends the policy-owner contract. |
    | cmd/​plugins/​topology-aware/​policy/​dra.go | Publishes PCIe-root attributes. |
    | cmd/​plugins/​topology-aware/​policy/​dra_test.go | Tests conditional root publication. |
    | cmd/​plugins/​topology-aware/​policy/​mocks_test.go | Updates package mocks. |
    | cmd/​plugins/​topology-aware/​policy/​coldstart_test.go | Updates the test owner interface. |
    | test/​e2e/​policies.test-suite/​topology-aware/​n4c16/​test43-dra-pcie-roots/​code.var.sh | Verifies cluster-level publication behavior. |
    </details>

    🧠 Review effort: Balanced

    ---

    💡 <a href="/containers/nri-plugins/new/stacked/bart0sh/DRA/008-resmgr-refresh-node-resources?filename=.github/skills/code-review/SKILL.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add a code-review agent skill</a> or configure MCP servers for context-aware, tailored reviews. <a href="https://docs.github.com/copilot/how-tos/use-copilot-agents/request-a-code-review/use-code-review?tool=webui#mcp-servers-and-agent-skills" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn more in the docs.</a>

    klihub klihub approved these changes on Oct 16, 2026 11:15 UTC
    Approved Reviewer

    LGTM

    askervin askervin approved these changes on Oct 16, 2026 11:23 UTC
    Approved Reviewer

    LGTM

    Reviewers
    Assignees
    bart0sh bart0sh
    Labels
    risk: low confidence: 56.3% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 57.5% (MEDIUM) · Higher = larger blast radius
    57.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.3% · Lower = rushed or shallow review
    56.3%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 25.1% · Safe to merge
    25.1%