Skip to content

Conversation

@sideeffect42
Copy link
Member

explorer/{cpu_cores,cpu_sockets}:

Assume that multiple processors are cores instead of sockets.
For most architectures sockets are not reported using "physical id" in /proc/cpuinfo, making this explorer report all cores as separate sockets.
This does not make much sense. For most systems assuming one socket and N cores seems to be more correct to me.

On NetBSD /proc/cpuinfo is only implemented for a few architectures.
For all the others /proc/cpuinfo is an empty file (which makes grep -c exit 1).

On NetBSD also currently no architecture reports "physical id", so socket detection using /proc/cpuinfo will never work.
It is thus disabled on NetBSD until somebody finds another way.

NetBSD also has hw.ncpuonline like OpenBSD (in fact, OpenBSD imported the code for it from NetBSD).
So it makes more sense to merge the code for NetBSD and OpenBSD instead of NetBSD and FreeBSD.

explorer/memory:

OpenBSD exports HW_PHYSMEM64 as hw.physmem.
NetBSD exports HW_PHYSMEM as hw.physmem and HW_PHYSMEM64 as hw.physmem64 (since NetBSD 2.0).

NetBSD < 2.0 is not supported by this code. For these versions hw.physmem could be used as a fall back, but I haven't implemented it because there are numerous other problems with its outdated /bin/sh (switching to /bin/ksh would fix those, though).

In the unlikely (or impossible?) case that there are no online memory blocks, fall back to /proc/meminfo. (grep -c problem cf. above).

…ault and fix for empty /proc/cpuinfo

Assume that multiple processors are cores instead of sockets.
For most architectures sockets are not reported using "physical id" in
/proc/cpuinfo, making this explorer report all cores as separate sockets.
This does not make much sense. For most systems assuming one socket and
N cores is more correct.

On NetBSD /proc/cpuinfo is only implemented for a few architectures.
For all the others /proc/cpuinfo is an empty file (which makes grep -c
exit 1).

On NetBSD also currently no architecture reports "physical id", so
socket detection using /proc/cpuinfo will never work.
It is thus disabled on NetBSD until somebody finds another way.
…enBSD

NetBSD also has hw.ncpuonline like OpenBSD (in fact, OpenBSD imported
the code for it from NetBSD).

Let's merge the code for NetBSD and OpenBSD instead of FreeBSD.

On OpenBSD sysctl(8) never returns a non-zero exit status, so `grep .' is
used to detect success and fall back to hw.ncpu.

https://marc.info/?l=openbsd-cvs&m=153135863131342&w=2
OpenBSD exports HW_PHYSMEM64 as hw.physmem.

NetBSD exports HW_PHYSMEM as hw.physmem and
HW_PHYSMEM64 as hw.physmem64 (since NetBSD 2.0).
@sideeffect42 sideeffect42 requested a review from 4nd3r August 31, 2025 19:51
In the unlikely (or impossible?) case that there are no online
memory blocks, fall back to /proc/meminfo.
@sideeffect42 sideeffect42 force-pushed the fix/explorer/cpu_cores/empty-cpuinfo branch from 7f7ad16 to 57ab6e7 Compare August 31, 2025 19:53
@4nd3r 4nd3r merged commit a19c202 into skonfig:main Sep 1, 2025
1 check passed
@sideeffect42 sideeffect42 deleted the fix/explorer/cpu_cores/empty-cpuinfo branch September 1, 2025 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants