MINOR: cpu-topo: add NUMA node identification to CPUs on FreeBSD
With this patch we're also NUMA node IDs to each CPU when the info is found. The code is highly inspired from the one in commit f5d48f8b3 ("MEDIUM: cfgparse: numa detect topology on FreeBSD."), the difference being that we're just setting the value in ha_cpu_topo[].
This commit is contained in:
parent
f6154c079e
commit
3a7cc676fa
@ -417,7 +417,37 @@ int cpu_detect_topology(void)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else // __linux__
|
#elif defined(__FreeBSD__)
|
||||||
|
|
||||||
|
int cpu_detect_topology(void)
|
||||||
|
{
|
||||||
|
struct hap_cpuset node_cpu_set;
|
||||||
|
int ndomains, domain, cpu;
|
||||||
|
size_t len = sizeof(ndomains);
|
||||||
|
|
||||||
|
/* Try to detect NUMA nodes */
|
||||||
|
if (sysctlbyname("vm.ndomains", &ndomains, &len, NULL, 0) == 0) {
|
||||||
|
BUG_ON(ndomains > MAXMEMDOM);
|
||||||
|
|
||||||
|
/* For each domain we'll reference the domain ID in the belonging
|
||||||
|
* CPUs.
|
||||||
|
*/
|
||||||
|
for (domain = 0; domain < ndomains; domain++) {
|
||||||
|
ha_cpuset_zero(&node_cpu_set);
|
||||||
|
|
||||||
|
if (cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_DOMAIN, domain,
|
||||||
|
sizeof(node_cpu_set.cpuset), &node_cpu_set.cpuset) == -1)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
for (cpu = 0; cpu < cpu_topo_maxcpus; cpu++)
|
||||||
|
if (ha_cpuset_isset(&node_cpu_set, cpu))
|
||||||
|
ha_cpu_topo[cpu].no_id = domain;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else // !__linux__, !__FreeBSD__
|
||||||
|
|
||||||
int cpu_detect_topology(void)
|
int cpu_detect_topology(void)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user