@@ -2400,7 +2400,8 @@ struct cpu_topology {
24002400 int logical_cpu_id ;
24012401 int physical_node_id ;
24022402 int logical_node_id ; /* 0-based count within the package */
2403- int thread_id ;
2403+ int ht_id ; /* unique within a core */
2404+ int ht_sibling_cpu_id ;
24042405 int type ;
24052406 cpu_set_t * put_ids ; /* Processing Unit/Thread IDs */
24062407} * cpus ;
@@ -6179,8 +6180,8 @@ int get_thread_siblings(struct cpu_topology *thiscpu)
61796180 int thread_id = 0 ;
61806181
61816182 thiscpu -> put_ids = CPU_ALLOC ((topo .max_cpu_num + 1 ));
6182- if (thiscpu -> thread_id < 0 )
6183- thiscpu -> thread_id = thread_id ++ ;
6183+ if (thiscpu -> ht_id < 0 )
6184+ thiscpu -> ht_id = thread_id ++ ;
61846185 if (!thiscpu -> put_ids )
61856186 return -1 ;
61866187
@@ -6204,8 +6205,10 @@ int get_thread_siblings(struct cpu_topology *thiscpu)
62046205 sib_core = get_core_id (so );
62056206 if (sib_core == thiscpu -> core_id ) {
62066207 CPU_SET_S (so , size , thiscpu -> put_ids );
6207- if ((so != cpu ) && (cpus [so ].thread_id < 0 ))
6208- cpus [so ].thread_id = thread_id ++ ;
6208+ if ((so != cpu ) && (cpus [so ].ht_id < 0 )) {
6209+ cpus [so ].ht_id = thread_id ++ ;
6210+ cpus [cpu ].ht_sibling_cpu_id = so ;
6211+ }
62096212 }
62106213 }
62116214 }
@@ -6388,9 +6391,10 @@ int mark_cpu_present(int cpu)
63886391 return 0 ;
63896392}
63906393
6391- int init_thread_id (int cpu )
6394+ int init_ht_id (int cpu )
63926395{
6393- cpus [cpu ].thread_id = -1 ;
6396+ cpus [cpu ].ht_id = -1 ;
6397+ cpus [cpu ].ht_sibling_cpu_id = -1 ;
63946398 return 0 ;
63956399}
63966400
@@ -9575,13 +9579,13 @@ void topology_probe(bool startup)
95759579 cpu_affinity_setsize = CPU_ALLOC_SIZE ((topo .max_cpu_num + 1 ));
95769580 CPU_ZERO_S (cpu_affinity_setsize , cpu_affinity_set );
95779581
9578- for_all_proc_cpus (init_thread_id );
9582+ for_all_proc_cpus (init_ht_id );
95799583
95809584 for_all_proc_cpus (set_cpu_hybrid_type );
95819585
95829586 /*
95839587 * For online cpus
9584- * find max_core_id, max_package_id
9588+ * find max_core_id, max_package_id, num_cores (per system)
95859589 */
95869590 for (i = 0 ; i <= topo .max_cpu_num ; ++ i ) {
95879591 int siblings ;
@@ -9623,11 +9627,12 @@ void topology_probe(bool startup)
96239627 siblings = get_thread_siblings (& cpus [i ]);
96249628 if (siblings > max_siblings )
96259629 max_siblings = siblings ;
9626- if (cpus [i ].thread_id == 0 )
9630+ if (cpus [i ].ht_id == 0 )
96279631 topo .num_cores ++ ;
96289632 }
9629- topo .max_core_id = max_core_id ;
9633+ topo .max_core_id = max_core_id ; /* within a package */
96309634 topo .max_package_id = max_package_id ;
9635+ topo .num_cores = (max_core_id + 1 ) * topo .num_packages ; /* per system */
96319636
96329637 topo .cores_per_node = max_core_id + 1 ;
96339638 if (debug > 1 )
@@ -9669,7 +9674,7 @@ void topology_probe(bool startup)
96699674 fprintf (outf ,
96709675 "cpu %d pkg %d die %d l3 %d node %d lnode %d core %d thread %d\n" ,
96719676 i , cpus [i ].package_id , cpus [i ].die_id , cpus [i ].l3_id ,
9672- cpus [i ].physical_node_id , cpus [i ].logical_node_id , cpus [i ].core_id , cpus [i ].thread_id );
9677+ cpus [i ].physical_node_id , cpus [i ].logical_node_id , cpus [i ].core_id , cpus [i ].ht_id );
96739678 }
96749679
96759680}
@@ -9727,14 +9732,13 @@ void allocate_counters(struct counters *counters)
97279732/*
97289733 * init_counter()
97299734 *
9730- * set FIRST_THREAD_IN_CORE and FIRST_CORE_IN_PACKAGE
9735+ * set t->cpu_id, FIRST_THREAD_IN_CORE and FIRST_CORE_IN_PACKAGE
97319736 */
97329737void init_counter (struct thread_data * thread_base , struct core_data * core_base , struct pkg_data * pkg_base , int cpu_id )
97339738{
97349739 int pkg_id = cpus [cpu_id ].package_id ;
97359740 int node_id = cpus [cpu_id ].logical_node_id ;
97369741 int core_id = cpus [cpu_id ].core_id ;
9737- int thread_id = cpus [cpu_id ].thread_id ;
97389742 struct thread_data * t ;
97399743 struct core_data * c ;
97409744
@@ -9744,7 +9748,7 @@ void init_counter(struct thread_data *thread_base, struct core_data *core_base,
97449748 if (node_id < 0 )
97459749 node_id = 0 ;
97469750
9747- t = GET_THREAD (thread_base , thread_id , core_id , node_id , pkg_id );
9751+ t = GET_THREAD (thread_base , cpus [ cpu_id ]. ht_id , core_id , node_id , pkg_id );
97489752 c = GET_CORE (core_base , core_id , node_id , pkg_id );
97499753
97509754 t -> cpu_id = cpu_id ;
0 commit comments