Repository navigation
Conversation
askervin
force-pushed
the
stacked/askervin/cxl/03-cxl-kernel
branch
from
November 25, 2026 14:12
e9ed30d to
b5fe67e
Compare
askervin
force-pushed
the
stacked/askervin/cxl/03-cxl-kernel
branch
from
November 25, 2026 20:59
b5fe67e to
b5e9660
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Critical mount-scanning and DAX-validation gaps can allow device changes beneath live filesystems or read-write access to unintended devices, risking write failures and data loss.
5 open issues
Reject DAX paths when the sysfs identity lookup fails · New Verify the opened DAX device with Fstat · New Propagate mount scan errors before changing device read-only state · New Match region paths without affecting similarly prefixed regions · New Determine CPU nodes independently of region nodes · New
What changed in this PR
This PR adds pkg/cxl/kernel as the node-level interface for observing and managing CXL memory, devices, and related filesystems.
Changes:
- Adds CXL topology snapshots, device operations, state transitions, and a fake kernel for tests.
- Adds
cxl-dump, shared JSON helpers, and a VM topology test. - Allows multiple udev readers per process and expands CI test coverage.
Testing: The PR reports passing race tests, lint, arm64 vet, and the DRA VM suite. The new n4-cxl VM test has not been run.
| File | Description |
|---|---|
test/e2e/memory.test-suite/memory-policy/n4-cxl/test01-pkg-cxl/code.var.sh |
Tests CXL hotplug, interleaving, and memory states. |
test/e2e/memory.test-suite/e2e_json.py |
Evaluates JSON assertions for VM tests. |
test/e2e/memory.test-suite/cxl.source.sh |
Adds CXL dump, polling, and assertion helpers. |
scripts/cxl-dump/cxl-dump.go |
Prints the observed topology as JSON. |
pkg/udev/reader.go |
Uses kernel-assigned netlink port IDs. |
pkg/udev/reader_test.go |
Tests two readers in one process. |
pkg/cxl/kernel/wait.go |
Adds context-aware polling and waits. |
pkg/cxl/kernel/transitions.go |
Supports state names and transition documentation. |
pkg/cxl/kernel/sysfs.go |
Adds sysfs parsing and path helpers. |
pkg/cxl/kernel/sys_linux.go |
Implements Linux mount, device, and memory operations. |
pkg/cxl/kernel/region_test.go |
Tests region creation, removal, and safety checks. |
pkg/cxl/kernel/probe.go |
Adds address-aliasing probes and DAX zeroing. |
pkg/cxl/kernel/probe_test.go |
Tests temporary device-node cleanup. |
pkg/cxl/kernel/probe_other.go |
Defines unsupported cache-flush behavior. |
pkg/cxl/kernel/probe_amd64.s |
Implements cache flush and memory fence instructions. |
pkg/cxl/kernel/probe_amd64.go |
Declares amd64 probe primitives. |
pkg/cxl/kernel/port.go |
Observes decoder stacks and release-order blockers. |
pkg/cxl/kernel/port_test.go |
Tests decoder holes and ordered region removal. |
pkg/cxl/kernel/pmem_test.go |
Tests persistent-memory namespace lifecycles. |
pkg/cxl/kernel/observe.go |
Builds topology snapshots and lookup indexes. |
pkg/cxl/kernel/mount.go |
Inspects mounts and guards read-only device changes. |
pkg/cxl/kernel/memdev.go |
Observes and controls CXL memory devices. |
pkg/cxl/kernel/memdev_test.go |
Tests device discovery, states, and capacity. |
pkg/cxl/kernel/loop.go |
Identifies and configures loop devices. |
pkg/cxl/kernel/kernel.go |
Defines configuration and system-call interfaces. |
pkg/cxl/kernel/helpers_test.go |
Provides shared fixtures and assertions. |
pkg/cxl/kernel/fs.go |
Detects filesystem signatures and properties. |
pkg/cxl/kernel/fake/pmem.go |
Simulates persistent-memory probing and namespaces. |
pkg/cxl/kernel/fake/fake_test.go |
Tests fake hooks, reboot behavior, and kernel rules. |
pkg/cxl/kernel/events.go |
Broadcasts device changes and debounced notifications. |
pkg/cxl/kernel/errors.go |
Defines typed operation errors. |
pkg/cxl/kernel/doc.go |
Documents package scope and synchronization rules. |
pkg/cxl/kernel/devnode.go |
Opens device nodes with DAX identity checks. |
pkg/cxl/kernel/devnode_test.go |
Tests device opening and delayed node appearance. |
pkg/cxl/kernel/blocks.go |
Observes and controls memory blocks and NUMA nodes. |
pkg/cxl/kernel/blocks_test.go |
Tests ranges, block states, and online-memory checks. |
.github/workflows/verify.yaml |
Adds udev and cxl-dump to race-test coverage. |
Review effort: Balanced
askervin
force-pushed
the
stacked/askervin/cxl/03-cxl-kernel
branch
from
November 27, 2026 17:23
b5e9660 to
16a6515
Compare
A reader bound its netlink socket with the process id, so a second reader in the same process failed to bind. With pid 0 the kernel assigns the port id, so several readers can run in one process. A new test runs two readers at once. Signed-off-by: Antti Kervinen <antti.kervinen@intel.com>
Code that manages CXL memory needs to read and change many kernel objects: memdevs, regions, dax devices, memory blocks, and the persistent memory chain with its mounts. Package kernel gives that code one place that observes them and one definition of each derived fact, for example when a region counts as enabled or as having online memory. It also holds the one lock that orders the dax bus operations that the kernel could deadlock on. Package fake is the kernel's side of the same objects, so unit tests run without CXL hardware. It does not model the dax bus locks, so it cannot show a deadlock there. Signed-off-by: Antti Kervinen <antti.kervinen@intel.com>
cxl-dump prints what pkg/cxl/kernel observes of a node as JSON: memdevs, ports, regions, dax devices, memory blocks and NUMA nodes. Signed-off-by: Antti Kervinen <antti.kervinen@intel.com>
test01-pkg-cxl hot-plugs CXL memory devices in a VM and checks what cxl-dump reports of their regions: interleaving, disabled and partly online memory, and two host bridges. cxl.source.sh and e2e_json.py give e2e tests the cxl-dump view and JSON assertions. Signed-off-by: Antti Kervinen <antti.kervinen@intel.com>
Signed-off-by: Antti Kervinen <antti.kervinen@intel.com>
askervin
force-pushed
the
stacked/askervin/cxl/03-cxl-kernel
branch
from
November 30, 2026 13:58
16a6515 to
2cbaaf0
Compare
This branch has not been deployed
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.


This PR adds
pkg/cxl/kernel, the package that observes and changes the CXL kernel objects of a node. Code that manages CXL memory gets one place that reads sysfs and runscxlandndctl, so it does not repeat that work or define the derived facts (such as when a region is enabled) in several places. A fake kernel lets the unit tests run without CXL hardware, and a VM test checks the package against real devices.pkg/cxl/kernelcovers memdevs and the decoders of their ports, regions, dax regions and dax devices with their drivers, memory blocks and NUMA nodes, the persistent memory chain (nd region, namespaces, block devices), and the superblocks, mounts, binds and loop devices on it. It has a transition table for each object that has a state, and one lock that orders the dax bus operations. The package comment indoc.golists the derived facts and the naming rules, and each object file starts with a comment about that object.pkg/cxl/kernel/fakeis the kernel's side of those objects for tests. It keeps a sysfs tree, a procfs and a/devin temporary directories, and it implements thecxlandndctlcommands and the system calls of the package. Its package comment lists the kernel rules that it models and the ones that it leaves out.scripts/cxl-dumpprints what the package observes of a node as JSON.memory-policy/n4-cxl/test01-pkg-cxlhot-plugs CXL memory devices in a VM and checks whatcxl-dumpreports for them.cxl.source.shande2e_json.pygive e2e tests thecxl-dumpview and the JSON assertions.pkg/udev: a reader now binds its netlink socket with pid 0, so several readers can run in one process. A new test runs two readers at once.pkg/udevandcxl-dump.Start with
pkg/cxl/kernel/doc.go, then readkernel.gofor theKerneltype and itsSysinterface, and then the object files such asregion.goanddax.go.Testing
go test -short -race ./pkg/cxl/... ./pkg/udev/... ./scripts/cxl-dump/...passes, two udev readers in one process included.golangci-lint runreports nothing.GOOS=linux GOARCH=arm64 go vet ./pkg/cxl/... ./pkg/udev/...passes.cxl-dumpruns in the VMs ofmemory.test-suite/dra-driver-cxl, whose tests read its JSON. The suite passes.memory-policy/n4-cxl/test01-pkg-cxl, which needs the n4-cxl VM.