explorer/{cpu_cores,cpu_sockets,memory}: Misc. fixes for NetBSD #155
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.
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/cpuinfois only implemented for a few architectures.For all the others
/proc/cpuinfois an empty file (which makesgrep -cexit 1).On NetBSD also currently no architecture reports "physical id", so socket detection using
/proc/cpuinfowill never work.It is thus disabled on NetBSD until somebody finds another way.
NetBSD also has
hw.ncpuonlinelike 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_PHYSMEM64ashw.physmem.NetBSD exports
HW_PHYSMEMashw.physmemandHW_PHYSMEM64ashw.physmem64(since NetBSD 2.0).NetBSD < 2.0 is not supported by this code. For these versions
hw.physmemcould 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/kshwould fix those, though).In the unlikely (or impossible?) case that there are no online memory blocks, fall back to
/proc/meminfo. (grep -cproblem cf. above).