Re: Determining the number of CPU cores and hyperthreads from userspace

2021-09-19 Thread Abel Abraham Camarillo Ojeda
is this useful?:

$ cat sysconf.c
#include 
#include 

int
main()
{
printf("nproc configured %ld\n", sysconf(_SC_NPROCESSORS_CONF));
printf("nproc online %ld\n", sysconf(_SC_NPROCESSORS_ONLN));
return 0;
}
$ cc -o sysconf sysconf.c
$ ./sysconf
nproc configured 4
nproc online 2

On Sun, Sep 19, 2021 at 1:18 PM Chris Bennett <
cpb_m...@bennettconstruction.us> wrote:

> On Sun, Sep 19, 2021 at 01:37:05PM -0400, Daniel Wilkins wrote:
> > Hyperthreads are easy: they've been disabled for years (unless they got
> flipped on and I didn't notice.)
> >
>
> Does the setting in the BIOS need to be turned off also?
> Or is it irrelevant? I had a server for a while where the company
> insisted that it be left on in the BIOS.
>
> Thanks,
> Chris
>
>


Re: Determining the number of CPU cores and hyperthreads from userspace

2021-09-19 Thread Chris Bennett
On Sun, Sep 19, 2021 at 01:37:05PM -0400, Daniel Wilkins wrote:
> Hyperthreads are easy: they've been disabled for years (unless they got 
> flipped on and I didn't notice.)
> 

Does the setting in the BIOS need to be turned off also?
Or is it irrelevant? I had a server for a while where the company
insisted that it be left on in the BIOS.

Thanks,
Chris



Re: Determining the number of CPU cores and hyperthreads from userspace

2021-09-19 Thread Daniel Wilkins
Hyperthreads are easy: they've been disabled for years (unless they got flipped 
on and I didn't notice.)



Determining the number of CPU cores and hyperthreads from userspace

2021-09-19 Thread Baptiste Jonglez
Hello,

In the interest of fetching this information from Ansible for the GCC
compile farm [1], I would like to determine the number of cores
vs. hyper-threads on a system.

With OpenBSD 6.9, this is what I get with "sysctl hw" on a dual 6-core Xeon
system:

hw.model=Intel(R) Xeon(R) CPU E5-2640 0 @ 2.50GHz
hw.ncpu=24
hw.ncpufound=24
hw.smt=0
hw.ncpuonline=12

Because SMT is disabled, I can guess that there are 12 cores (ncpuonline)
and 24 threads (ncpu), which is good.

However, if SMT is enabled, this "guess" no longer works:

hw.ncpu=24
hw.ncpufound=24
hw.smt=1
hw.ncpuonline=24

Is there another method that always works?

I could parse the output of dmesg, it would work on this system:

# dmesg | grep smt
cpu0: smt 0, core 0, package 0
...
cpu12: smt 1, core 0, package 0
...

However, parsing dmesg was removed from Ansible in 2016 because it was not
considered reliable enough:

  
https://github.com/ansible/ansible/commit/c17dad0def2fa86733c07610189e94486e056203

In addition, this method would only work on amd64/i386 (according to the
comment added in this commit).

Thanks,
Baptiste

[1] https://cfarm.tetaneutral.net


signature.asc
Description: PGP signature