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



The following reply was made to PR kern/57816; it has been noted by GNATS.

From: Jason Bacon <jtocino%gmx.com@localhost>
To: gnats-bugs%netbsd.org@localhost, kern-bug-people%netbsd.org@localhost,
 gnats-admin%netbsd.org@localhost, netbsd-bugs%netbsd.org@localhost
Cc: 
Subject: Re: kern/57816: Add sysctl support for physical cores
Date: Thu, 4 Jan 2024 13:33:58 -0600

 On 1/4/24 10:05, Michael van Elst wrote:
 > The following reply was made to PR kern/57816; it has been noted by GNAT=
 S.
 >
 > 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.sm=
 p.cores.  Both report hyperthreads for hw.ncpy, compatible with NetBSD.
 >
 >
 >   That information is currently available using the cpuctl identify comm=
 and,
 >   but it's machine specific and probably delivers the information direct=
 ly
 >   only for x86.
 >
 >   For testing I had added sysctls to dump the cpu information in a machi=
 ne
 >   independent way, e.g.:
 >
 >   % sysctl kern.cpu
 >   kern.cpu.cpu0.package =3D 0
 >   kern.cpu.cpu0.core =3D 0
 >   kern.cpu.cpu0.smt =3D 0
 >   kern.cpu.cpu1.package =3D 0
 >   kern.cpu.cpu1.core =3D 0
 >   kern.cpu.cpu1.smt =3D 1
 >   kern.cpu.cpu2.package =3D 0
 >   kern.cpu.cpu2.core =3D 1
 >   kern.cpu.cpu2.smt =3D 0
 >   kern.cpu.cpu3.package =3D 0
 >   kern.cpu.cpu3.core =3D 1
 >   kern.cpu.cpu3.smt =3D 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