Skip to content

Commit

Permalink
Always use all threads in NumaTopology, cpuset respected when selecti…
Browse files Browse the repository at this point in the history
…ng then, e.g. for affinity domains
  • Loading branch information
TomTheBear committed Sep 12, 2024
1 parent b20cf61 commit 35f988b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
13 changes: 10 additions & 3 deletions src/affinity.c
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,8 @@ static int affinity_addMemoryDomain(int nodeId, AffinityDomain* domain, int* hel
{
CpuTopology_t cputopo = get_cpuTopology();
NumaTopology_t numatopo = get_numaTopology();
if (!domain)
int num_hwthreads = 0;
if ((nodeId < 0) || (!domain))
{
return -EINVAL;
}
Expand All @@ -542,9 +543,15 @@ static int affinity_addMemoryDomain(int nodeId, AffinityDomain* domain, int* hel
}
for (int i = 0; i < numatopo->nodes[nodeId].numberOfProcessors; i++)
{
domain->processorList[i] = (int)numatopo->nodes[nodeId].processors[i];
for (int j = 0; j < cputopo->numHWThreads; j++)
{
if (cputopo->threadPool[j].apicId == numatopo->nodes[nodeId].processors[i] && cputopo->threadPool[j].inCpuSet == 1)
{
domain->processorList[num_hwthreads++] = (int)numatopo->nodes[nodeId].processors[i];
}
}
}
domain->numberOfProcessors = numatopo->nodes[nodeId].numberOfProcessors;
domain->numberOfProcessors = num_hwthreads;
domain->numberOfCores = affinity_countSocketCores(domain->numberOfProcessors, domain->processorList, help);
domain->tag = bformat("M%d", nodeId);
DEBUG_PRINT(DEBUGLEV_DEVELOP, Affinity domain M%d: %d HW threads on %d cores, nodeId, domain->numberOfProcessors, domain->numberOfCores);
Expand Down
22 changes: 11 additions & 11 deletions src/numa_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,17 +372,17 @@ int proc_numa_init(void)
numa_info.nodes[i].id = id;
nodeMeminfo(id, &numa_info.nodes[i].totalMemory, &numa_info.nodes[i].freeMemory);
numa_info.nodes[i].numberOfProcessors = nodeProcessorList(id, &numa_info.nodes[i].processors);
int check = 0;
for (int j = 0; j < numa_info.nodes[i].numberOfProcessors; j++)
{
int id = numa_info.nodes[i].processors[j];
if (cpuid_topology.threadPool[id].inCpuSet == 1)
{
check++;
}
}
if (check < numa_info.nodes[i].numberOfProcessors)
numa_info.nodes[i].numberOfProcessors = check;
/* int check = 0;*/
/* for (int j = 0; j < numa_info.nodes[i].numberOfProcessors; j++)*/
/* {*/
/* int id = numa_info.nodes[i].processors[j];*/
/* if (cpuid_topology.threadPool[id].inCpuSet == 1)*/
/* {*/
/* numa_info.nodes[i].processors[check++] = numa_info.nodes[i].processors[j];*/
/* }*/
/* }*/
/* if (check < numa_info.nodes[i].numberOfProcessors)*/
/* numa_info.nodes[i].numberOfProcessors = check;*/
numa_info.nodes[i].numberOfDistances = nodeDistanceList(id, numa_info.numberOfNodes, &numa_info.nodes[i].distances);
if (numa_info.nodes[i].numberOfDistances == 0)
{
Expand Down

0 comments on commit 35f988b

Please sign in to comment.