Skip to content

snapshot: read /sys/class from the root, not the working directory - #480

Merged
jaypipes merged 1 commit into
jaypipes:mainfrom
rucoder:fix/snapshot-sys-class-path
Nov 6, 2026
Merged

jaypipes merged 1 commit into
jaypipes:mainfrom
rucoder:fix/snapshot-sys-class-path

Conversation

@rucoder

@rucoder rucoder commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

cloneContentByClass looks for sys/class/<class> relative to the working directory, not /sys/class/<class>. A snapshot taken anywhere but / therefore silently leaves out every network interface and every GPU (net and drm go through it). I hit this running ghwc snapshot from a scratch directory on a machine with two physical NICs: the snapshot had no /sys/class/net at all.

Every other path the snapshot clones is absolute; this makes this one absolute too.

TestExpectedCloneContentByClassFromAnyDir collects the network and GPU paths once from / and once from a temporary directory, and requires the same result. On main it fails on any host with a physical NIC or a GPU (here: [] against [sys/class/net/eth0 …]), and it is skipped on hosts with neither. With the fix, ghwc snapshot run from a scratch directory includes /sys/class/net/eth0.

cloneContentByClass looked for sys/class/<class> relative to the working
directory, so a snapshot taken anywhere but / silently left out every
network interface and GPU: ghwc snapshot run from a scratch directory on
a host with physical NICs produced a snapshot without /sys/class/net.
Every other path the snapshot clones is absolute; this one is now too.

Signed-off-by: Mikhail Malyshev <mike.malyshev@gmail.com>
rucoder added a commit to zededa/ghw that referenced this pull request Oct 27, 2026
No snapshot had several cache instances at one level without kernel
IDs, or a cpu_capacity file: the s390x one has caches without IDs, but
its only shared level spans every CPU, so merging distinct instances
would go unnoticed, and the x86 ones come from kernels that report no
capacity there.

linux-arm64-nvidia-jetson-agx-orin is a Jetson AGX Orin on NVIDIA's 5.15
kernel. It reports each cluster of four Cortex-A78AE cores as a package,
so core IDs repeat across packages but not within one and are kept;
every CPU has capacity 1024, a homogeneous part; and no cache has a
kernel ID, so the three L3s, one per cluster, are told apart by the CPUs
sharing them. It is a full capture, taken from / in EVE's debug
container with this branch's ghwc plus the snapshot fixes of
jaypipes#480 and jaypipes#481, so it holds the board's network interfaces
and the DeviceTree properties ghw reads (the CPU model comes from
compatible). The NVMe namespace's IDs and two app UUIDs in
/proc/self/mounts are replaced by fake ones; ghwc reads the same
information from it as from the unscrubbed capture, and the same CPU
information as from the board.

TestARMClusterPackagesSnapshot checks the packages, CPU model, cores,
core type, frequency and caches on it.

Signed-off-by: Mikhail Malyshev <mike.malyshev@gmail.com>
rucoder added a commit to zededa/ghw that referenced this pull request Oct 27, 2026
cloneContentByClass looked for sys/class/<class> relative to the working
directory, so a snapshot taken anywhere but / silently left out every
network interface and GPU: ghwc snapshot run from a scratch directory on
a host with physical NICs produced a snapshot without /sys/class/net.
Every other path the snapshot clones is absolute; this one is now too.

Signed-off-by: Mikhail Malyshev <mike.malyshev@gmail.com>
(cherry picked from commit 965ad27, jaypipes#480)
rucoder added a commit to zededa/ghw that referenced this pull request Oct 27, 2026
No snapshot had several cache instances at one level without kernel
IDs, or a cpu_capacity file: the s390x one has caches without IDs, but
its only shared level spans every CPU, so merging distinct instances
would go unnoticed, and the x86 ones come from kernels that report no
capacity there.

linux-arm64-nvidia-jetson-agx-orin is a Jetson AGX Orin on NVIDIA's 5.15
kernel. It reports each cluster of four Cortex-A78AE cores as a package,
so core IDs repeat across packages but not within one and are kept;
every CPU has capacity 1024, a homogeneous part; and no cache has a
kernel ID, so the three L3s, one per cluster, are told apart by the CPUs
sharing them. It is a full capture, taken from / in EVE's debug
container with this branch's ghwc plus the snapshot fixes of
jaypipes#480 and jaypipes#481, so it holds the board's network interfaces
and the DeviceTree properties ghw reads (the CPU model comes from
compatible). The NVMe namespace's IDs and two app UUIDs in
/proc/self/mounts are replaced by fake ones; ghwc reads the same
information from it as from the unscrubbed capture, and the same CPU
information as from the board.

TestARMClusterPackagesSnapshot checks the packages, CPU model, cores,
core type, frequency and caches on it.

Signed-off-by: Mikhail Malyshev <mike.malyshev@gmail.com>
rucoder added a commit to zededa/ghw that referenced this pull request Oct 27, 2026
No snapshot had several cache instances at one level without kernel
IDs, or a cpu_capacity file: the s390x one has caches without IDs, but
its only shared level spans every CPU, so merging distinct instances
would go unnoticed, and the x86 ones come from kernels that report no
capacity there.

linux-arm64-nvidia-jetson-agx-orin is a Jetson AGX Orin on NVIDIA's 5.15
kernel. It reports each cluster of four Cortex-A78AE cores as a package,
so core IDs repeat across packages but not within one and are kept;
every CPU has capacity 1024, a homogeneous part; and no cache has a
kernel ID, so the three L3s, one per cluster, are told apart by the CPUs
sharing them. It is a full capture, taken from / in EVE's debug
container with this branch's ghwc plus the snapshot fixes of
jaypipes#480 and jaypipes#481, so it holds the board's network interfaces
and the DeviceTree properties ghw reads (the CPU model comes from
compatible). The NVMe namespace's IDs and two app UUIDs in
/proc/self/mounts are replaced by fake ones; ghwc reads the same
information from it as from the unscrubbed capture, and the same CPU
information as from the board.

TestARMClusterPackagesSnapshot checks the packages, CPU model, cores,
core type, frequency and caches on it.

Signed-off-by: Mikhail Malyshev <mike.malyshev@gmail.com>
@jaypipes

Copy link
Copy Markdown
Owner

@rucoder thanks very much for these two PRs! I'm currently OOO at a small offsite. Will review as soon as I have some free time, but may be Thursday.

@rucoder

rucoder commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

@rucoder thanks very much for these two PRs! I'm currently OOO at a small offsite. Will review as soon as I have some free time, but may be Thursday.

@jaypipes have a great time! More PRs are coming soon . You can have the idea by looking at https://github.com/zededa/ghw/ fork and Prs merged into it.

@rucoder

rucoder commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

@jaypipes hi! can we merge these 2 and I can submit CPU cache and core discovery PRs?

@jaypipes jaypipes left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks @rucoder and sorry for the delay in reviewing! Honestly, I can't believe this bug has been latent for a long time! Thank you for fixing it :)

@jaypipes
jaypipes merged commit e3c6b0b into jaypipes:main Nov 6, 2026
15 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.

2 participants