Skip to content

Commit b2311a9

Browse files
committed
Fix some hyperthreading errors.
1.When there are multiple NUMA nodes and hyper-threading causes adjacent logical cores to share a physical core (e.g., common -> avail[i] = 0x5555555555555555UL), the numa_mapping function should not use a bitmask for filtering, as this would lead to redundant masking with the subsequent local_cpu_map function. 2.In the scenario described above, the final_num_procs parameter cannot accurately represent the actual number of valid CPU cores. The num_procs parameter can be used as a replacement, so the final_num_procs parameter has been removed.
1 parent fe220a0 commit b2311a9

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

driver/others/init.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,15 @@ static void numa_mapping(void) {
391391
core = 0;
392392
for (cpu = 0; cpu < common -> num_procs; cpu ++) {
393393
bitmask_idx = CPUELT(cpu);
394+
/*
395+
* When common->avail[i] = 0x5555555555555555UL (indicating that adjacent logical cores share a physical core),
396+
* using it as a mask may overlap with the local_cpu_map function's role, leading to only half of the real physical cores being detected.
397+
*/
398+
#ifdef ARCH_LOONGARCH64
399+
if (common -> node_info[node][bitmask_idx]) {
400+
#else
394401
if (common -> node_info[node][bitmask_idx] & common -> avail[bitmask_idx] & CPUMASK(cpu)) {
402+
#endif
395403
common -> cpu_info[count] = WRITE_CORE(core) | WRITE_NODE(node) | WRITE_CPU(cpu);
396404
count ++;
397405
core ++;
@@ -930,8 +938,12 @@ void gotoblas_affinity_init(void) {
930938

931939
if (common -> num_nodes > 1) numa_mapping();
932940

941+
#ifdef ARCH_LOONGARCH64
942+
common -> final_num_procs = common -> num_procs;
943+
#else
933944
common -> final_num_procs = 0;
934945
for(i = 0; i < common -> avail_count; i++) common -> final_num_procs += rcount(common -> avail[i]) + 1; //Make the max cpu number.
946+
#endif
935947

936948
for (cpu = 0; cpu < common -> final_num_procs; cpu ++) common -> cpu_use[cpu] = 0;
937949

0 commit comments

Comments
 (0)