Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only process memory cell/block subdirs in sysfs #343

Merged
merged 2 commits into from
May 8, 2023
Merged

only process memory cell/block subdirs in sysfs #343

merged 2 commits into from
May 8, 2023

Conversation

jaypipes
Copy link
Owner

@jaypipes jaypipes commented May 6, 2023

The /sys/devices/system/memory and /sys/devices/system/node/nodeX subdirectories contains one or more subdirectories that begin with the word "memory" and end in a 0-based cell/block index for that memory. e.g. /sys/devices/system/node/node0/memory63 is a directory containing information files about the 64th memory block in NUMA node 0.

Previously, code that gathered total physical memory by looking at these subdirectories was using a simple glob on memory* to determine those memory block subdirectories. However, in some recent Linux kernels a /sys/devices/system/memory/memory_failure file causes that simple glob to backfire. This patch replaces the simple glob with a read of the /sys/devices/system/memory or /sys/devices/system/node/nodeX directory and regex matches on memory\d$ to determine if the subdirectory is a memory block one.

Fixes Issue #341

The `/sys/devices/system/memory` and `/sys/devices/system/node/nodeX`
subdirectories contains one or more subdirectories that begin with the
word "memory" and end in a 0-based cell/block index for that memory.
e.g. `/sys/devices/system/node/node0/memory63` is a directory containing
information files about the 64th memory block in NUMA node 0.

Previously, code that gathered total physical memory by looking at these
subdirectories was using a simple glob on `memory*` to determine those
memory block subdirectories. However, in some recent Linux kernels a
`/sys/devices/system/memory/memory_failure` file causes that simple glob
to backfire. This patch replaces the simple glob with a read of the
`/sys/devices/system/memory` or `/sys/devices/system/node/nodeX`
directory and regex matches on `memory\d$` to determine if the
subdirectory is a memory block one.

Fixes Issue #341

Signed-off-by: Jay Pipes <[email protected]>
@ffromani
Copy link
Collaborator

ffromani commented May 8, 2023

LGTM

waiting for the missing CI lane (macos-1015) to complete/rerun before to merge

Copy link
Collaborator

@ffromani ffromani left a comment

Choose a reason for hiding this comment

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

LGTM

(still!)

@ffromani ffromani merged commit 29cf834 into main May 8, 2023
@jaypipes jaypipes deleted the fix-341 branch September 21, 2024 15:51
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