OpenBSD: only get active CPU core count

Newer computers may have some cores offline because of the
Meltdown/Spectre patches from a while ago, making uv_cpu_info
potentially misleading and leading to people attempting to use more
threads than they actually have available. This makes it so only the
cores that are online and doing any work are counted.

PR-URL: https://github.com/libuv/libuv/pull/2326
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
Ben Davies 2019-06-07 01:12:04 -03:00 committed by cjihrig
parent 8ff0cd70c6
commit 64ab7cc740
No known key found for this signature in database
GPG Key ID: 7434390BDBE9B9C5

View File

@ -193,7 +193,7 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
if (sysctl(which, 2, &model, &size, NULL, 0))
return UV__ERR(errno);
which[1] = HW_NCPU;
which[1] = HW_NCPUONLINE;
size = sizeof(numcpus);
if (sysctl(which, 2, &numcpus, &size, NULL, 0))
return UV__ERR(errno);