@@ -926,12 +926,11 @@ struct thread_data {
926
926
unsigned int x2apic_id ;
927
927
unsigned int flags ;
928
928
bool is_atom ;
929
- #define CPU_IS_FIRST_THREAD_IN_CORE 0x2
930
- #define CPU_IS_FIRST_CORE_IN_PACKAGE 0x4
931
929
unsigned long long counter [MAX_ADDED_THREAD_COUNTERS ];
932
930
} * thread_even , * thread_odd ;
933
931
934
932
struct core_data {
933
+ int base_cpu ;
935
934
unsigned long long c3 ;
936
935
unsigned long long c6 ;
937
936
unsigned long long c7 ;
@@ -944,6 +943,7 @@ struct core_data {
944
943
} * core_even , * core_odd ;
945
944
946
945
struct pkg_data {
946
+ int base_cpu ;
947
947
unsigned long long pc2 ;
948
948
unsigned long long pc3 ;
949
949
unsigned long long pc6 ;
@@ -1200,26 +1200,21 @@ int for_all_cpus(int (func) (struct thread_data *, struct core_data *, struct pk
1200
1200
1201
1201
int is_cpu_first_thread_in_core (struct thread_data * t , struct core_data * c , struct pkg_data * p )
1202
1202
{
1203
- UNUSED (c );
1204
1203
UNUSED (p );
1205
1204
1206
- return (t -> flags & CPU_IS_FIRST_THREAD_IN_CORE );
1205
+ return (( int ) t -> cpu_id == c -> base_cpu || c -> base_cpu < 0 );
1207
1206
}
1208
1207
1209
1208
int is_cpu_first_core_in_package (struct thread_data * t , struct core_data * c , struct pkg_data * p )
1210
1209
{
1211
1210
UNUSED (c );
1212
- UNUSED (p );
1213
1211
1214
- return (t -> flags & CPU_IS_FIRST_CORE_IN_PACKAGE );
1212
+ return (( int ) t -> cpu_id == p -> base_cpu || p -> base_cpu < 0 );
1215
1213
}
1216
1214
1217
1215
int is_cpu_first_thread_in_package (struct thread_data * t , struct core_data * c , struct pkg_data * p )
1218
1216
{
1219
- UNUSED (c );
1220
- UNUSED (p );
1221
-
1222
- return (t -> flags & CPU_IS_FIRST_THREAD_IN_CORE ) && (t -> flags & CPU_IS_FIRST_CORE_IN_PACKAGE );
1217
+ return is_cpu_first_thread_in_core (t , c , p ) && is_cpu_first_core_in_package (t , c , p );
1223
1218
}
1224
1219
1225
1220
int cpu_migrate (int cpu )
@@ -2263,9 +2258,6 @@ void clear_counters(struct thread_data *t, struct core_data *c, struct pkg_data
2263
2258
t -> irq_count = 0 ;
2264
2259
t -> smi_count = 0 ;
2265
2260
2266
- /* tells format_counters to dump all fields from this set */
2267
- t -> flags = CPU_IS_FIRST_THREAD_IN_CORE | CPU_IS_FIRST_CORE_IN_PACKAGE ;
2268
-
2269
2261
c -> c3 = 0 ;
2270
2262
c -> c6 = 0 ;
2271
2263
c -> c7 = 0 ;
@@ -5872,15 +5864,19 @@ void allocate_counters(struct thread_data **t, struct core_data **c, struct pkg_
5872
5864
if (* c == NULL )
5873
5865
goto error ;
5874
5866
5875
- for (i = 0 ; i < num_cores ; i ++ )
5867
+ for (i = 0 ; i < num_cores ; i ++ ) {
5876
5868
(* c )[i ].core_id = -1 ;
5869
+ (* c )[i ].base_cpu = -1 ;
5870
+ }
5877
5871
5878
5872
* p = calloc (topo .num_packages , sizeof (struct pkg_data ));
5879
5873
if (* p == NULL )
5880
5874
goto error ;
5881
5875
5882
- for (i = 0 ; i < topo .num_packages ; i ++ )
5876
+ for (i = 0 ; i < topo .num_packages ; i ++ ) {
5883
5877
(* p )[i ].package_id = i ;
5878
+ (* p )[i ].base_cpu = -1 ;
5879
+ }
5884
5880
5885
5881
return ;
5886
5882
error :
@@ -5913,10 +5909,11 @@ void init_counter(struct thread_data *thread_base, struct core_data *core_base,
5913
5909
p = GET_PKG (pkg_base , pkg_id );
5914
5910
5915
5911
t -> cpu_id = cpu_id ;
5916
- if (thread_id == 0 ) {
5917
- t -> flags |= CPU_IS_FIRST_THREAD_IN_CORE ;
5918
- if (cpu_is_first_core_in_package (cpu_id ))
5919
- t -> flags |= CPU_IS_FIRST_CORE_IN_PACKAGE ;
5912
+ if (!cpu_is_not_allowed (cpu_id )) {
5913
+ if (c -> base_cpu < 0 )
5914
+ c -> base_cpu = t -> cpu_id ;
5915
+ if (p -> base_cpu < 0 )
5916
+ p -> base_cpu = t -> cpu_id ;
5920
5917
}
5921
5918
5922
5919
c -> core_id = core_id ;
0 commit comments