NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/57816: Add sysctl support for physical cores



On 1/4/24 10:05, Michael van Elst wrote:
The following reply was made to PR kern/57816; it has been noted by GNATS.

From: mlelstv%serpens.de@localhost (Michael van Elst)
To: gnats-bugs%netbsd.org@localhost
Cc:
Subject: Re: kern/57816: Add sysctl support for physical cores
Date: Thu, 4 Jan 2024 16:03:54 -0000 (UTC)

  jtocino%gmx.com@localhost writes:

  >Darwin reports actual cores as hw.physicalcpu, and FreeBSD as kern.smp.cores.  Both report hyperthreads for hw.ncpy, compatible with NetBSD.


  That information is currently available using the cpuctl identify command,
  but it's machine specific and probably delivers the information directly
  only for x86.

  For testing I had added sysctls to dump the cpu information in a machine
  independent way, e.g.:

  % sysctl kern.cpu
  kern.cpu.cpu0.package = 0
  kern.cpu.cpu0.core = 0
  kern.cpu.cpu0.smt = 0
  kern.cpu.cpu1.package = 0
  kern.cpu.cpu1.core = 0
  kern.cpu.cpu1.smt = 1
  kern.cpu.cpu2.package = 0
  kern.cpu.cpu2.core = 1
  kern.cpu.cpu2.smt = 0
  kern.cpu.cpu3.package = 0
  kern.cpu.cpu3.core = 1
  kern.cpu.cpu3.smt = 1


  But that's not very useful on machines with many CPUs, it also
  misses newer information about the topology (caches, numa, big.little, ...).


I think it would be useful to have another variable for the number of
physical cores.  It could produce the same value as hw.ncpu on most
architectures, which don't have hyperthreading.

Or, if there were a boolean to indicate whether hyperthreading is active
(which would always be 0 on most architectures), it would be simple
enough to divide hw.ncpu by 2.

Or, a threads_per_core variable, which would always be 1 on most archs,
and 2 where hyperthreading is available and active.



Home | Main Index | Thread Index | Old Index