Skip to content

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

Merged
askervin merged 4 commits into
mainfrom
stacked/bart0sh/DRA/009-pcie-roots
Oct 16, 2026
Merged

askervin merged 4 commits into
mainfrom
stacked/bart0sh/DRA/009-pcie-roots

Conversation

@bart0sh

@bart0sh bart0sh commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

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.

@bart0sh
bart0sh added this pull request to stack #807 October 12, 2026 12:54
@bart0sh bart0sh changed the title stacked/bart0sh/DRA/009 pcie roots DRA: publish PCIe roots on topology-aware devices Oct 12, 2026
@bart0sh
bart0sh requested a balanced review from Copilot October 12, 2026 13:17
@bart0sh
bart0sh force-pushed the stacked/bart0sh/DRA/009-pcie-roots branch from a26dc21 to 9824ab5 Compare October 12, 2026 13:20

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

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

0 open findings

What changed in this PR

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.

🧠 Review effort: Balanced


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

@askervin
askervin force-pushed the stacked/bart0sh/DRA/009-pcie-roots branch from 9824ab5 to dd98db0 Compare October 12, 2026 14:53
@bart0sh
bart0sh force-pushed the stacked/bart0sh/DRA/009-pcie-roots branch from dd98db0 to 63c26de Compare October 13, 2026 08:51
@bart0sh
bart0sh force-pushed the stacked/bart0sh/DRA/009-pcie-roots branch from 63c26de to ea97aab Compare October 13, 2026 12:54
@bart0sh
bart0sh marked this pull request as ready for review October 15, 2026 10:46
@bart0sh
bart0sh force-pushed the stacked/bart0sh/DRA/009-pcie-roots branch from ea97aab to ca3923d Compare October 15, 2026 11:34
@klihub
klihub force-pushed the stacked/bart0sh/DRA/009-pcie-roots branch from ca3923d to 3a39d5f Compare October 15, 2026 11:41
@bart0sh
bart0sh force-pushed the stacked/bart0sh/DRA/009-pcie-roots branch 2 times, most recently from e1c6b26 to ca3923d Compare October 15, 2026 12:14
@bart0sh
bart0sh force-pushed the stacked/bart0sh/DRA/009-pcie-roots branch from ca3923d to 45867e9 Compare October 15, 2026 12:55
@bart0sh
bart0sh requested review from askervin, kad and klihub October 15, 2026 13:45
Base automatically changed from stacked/bart0sh/DRA/008-resmgr-refresh-node-resources to main October 16, 2026 09:05
The kernel reports the CPUs local to a PCIe root from the root's NUMA
node. With sub-NUMA clustering that is one zone of the socket, but the
root is equally close to all zones of the socket. Give each root to
every package its local CPUs are in.

Add a recorded sample of a two-socket machine with sub-NUMA clustering.

Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
List attributes need the DRAListTypeAttributes feature gate, and the
API server rejects a slice using them without it. Probe with a dry run
when the plugin is created and let policies ask for the result.

Slices with list attributes hold at most 64 devices, so always split
the devices into slices of that size.

Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
@klihub
klihub force-pushed the stacked/bart0sh/DRA/009-pcie-roots branch from 45867e9 to f74d9fe Compare October 16, 2026 09:05

@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

@askervin
askervin merged commit 53ac34b into main Oct 16, 2026
14 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.

5 participants