@@ -1198,6 +1198,30 @@ int for_all_cpus(int (func) (struct thread_data *, struct core_data *, struct pk
1198
1198
return 0 ;
1199
1199
}
1200
1200
1201
+ int is_cpu_first_thread_in_core (struct thread_data * t , struct core_data * c , struct pkg_data * p )
1202
+ {
1203
+ UNUSED (c );
1204
+ UNUSED (p );
1205
+
1206
+ return (t -> flags & CPU_IS_FIRST_THREAD_IN_CORE );
1207
+ }
1208
+
1209
+ int is_cpu_first_core_in_package (struct thread_data * t , struct core_data * c , struct pkg_data * p )
1210
+ {
1211
+ UNUSED (c );
1212
+ UNUSED (p );
1213
+
1214
+ return (t -> flags & CPU_IS_FIRST_CORE_IN_PACKAGE );
1215
+ }
1216
+
1217
+ int is_cpu_first_thread_in_package (struct thread_data * t , struct core_data * c , struct pkg_data * p )
1218
+ {
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 );
1223
+ }
1224
+
1201
1225
int cpu_migrate (int cpu )
1202
1226
{
1203
1227
CPU_ZERO_S (cpu_affinity_setsize , cpu_affinity_set );
@@ -1682,11 +1706,11 @@ int format_counters(struct thread_data *t, struct core_data *c, struct pkg_data
1682
1706
int printed = 0 ;
1683
1707
1684
1708
/* if showing only 1st thread in core and this isn't one, bail out */
1685
- if (show_core_only && !( t -> flags & CPU_IS_FIRST_THREAD_IN_CORE ))
1709
+ if (show_core_only && !is_cpu_first_thread_in_core ( t , c , p ))
1686
1710
return 0 ;
1687
1711
1688
1712
/* if showing only 1st thread in pkg and this isn't one, bail out */
1689
- if (show_pkg_only && !( t -> flags & CPU_IS_FIRST_CORE_IN_PACKAGE ))
1713
+ if (show_pkg_only && !is_cpu_first_core_in_package ( t , c , p ))
1690
1714
return 0 ;
1691
1715
1692
1716
/*if not summary line and --cpu is used */
@@ -1820,7 +1844,7 @@ int format_counters(struct thread_data *t, struct core_data *c, struct pkg_data
1820
1844
outp += sprintf (outp , "%s%.2f" , (printed ++ ? delim : "" ), 100.0 * t -> c1 / tsc );
1821
1845
1822
1846
/* print per-core data only for 1st thread in core */
1823
- if (!( t -> flags & CPU_IS_FIRST_THREAD_IN_CORE ))
1847
+ if (!is_cpu_first_thread_in_core ( t , c , p ))
1824
1848
goto done ;
1825
1849
1826
1850
if (DO_BIC (BIC_CPU_c3 ))
@@ -1867,7 +1891,7 @@ int format_counters(struct thread_data *t, struct core_data *c, struct pkg_data
1867
1891
outp += sprintf (outp , fmt8 , (printed ++ ? delim : "" ), c -> core_energy * rapl_energy_units );
1868
1892
1869
1893
/* print per-package data only for 1st core in package */
1870
- if (!( t -> flags & CPU_IS_FIRST_CORE_IN_PACKAGE ))
1894
+ if (!is_cpu_first_core_in_package ( t , c , p ))
1871
1895
goto done ;
1872
1896
1873
1897
/* PkgTmp */
@@ -2202,7 +2226,7 @@ int delta_cpu(struct thread_data *t, struct core_data *c,
2202
2226
int retval = 0 ;
2203
2227
2204
2228
/* calculate core delta only for 1st thread in core */
2205
- if (t -> flags & CPU_IS_FIRST_THREAD_IN_CORE )
2229
+ if (is_cpu_first_thread_in_core ( t , c , p ) )
2206
2230
delta_core (c , c2 );
2207
2231
2208
2232
/* always calculate thread delta */
@@ -2211,7 +2235,7 @@ int delta_cpu(struct thread_data *t, struct core_data *c,
2211
2235
return retval ;
2212
2236
2213
2237
/* calculate package delta only for 1st core in package */
2214
- if (t -> flags & CPU_IS_FIRST_CORE_IN_PACKAGE )
2238
+ if (is_cpu_first_core_in_package ( t , c , p ) )
2215
2239
retval = delta_package (p , p2 );
2216
2240
2217
2241
return retval ;
@@ -2325,7 +2349,7 @@ int sum_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p)
2325
2349
}
2326
2350
2327
2351
/* sum per-core values only for 1st thread in core */
2328
- if (!( t -> flags & CPU_IS_FIRST_THREAD_IN_CORE ))
2352
+ if (!is_cpu_first_thread_in_core ( t , c , p ))
2329
2353
return 0 ;
2330
2354
2331
2355
average .cores .c3 += c -> c3 ;
@@ -2345,7 +2369,7 @@ int sum_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p)
2345
2369
}
2346
2370
2347
2371
/* sum per-pkg values only for 1st core in pkg */
2348
- if (!( t -> flags & CPU_IS_FIRST_CORE_IN_PACKAGE ))
2372
+ if (!is_cpu_first_core_in_package ( t , c , p ))
2349
2373
return 0 ;
2350
2374
2351
2375
if (DO_BIC (BIC_Totl_c0 ))
@@ -2745,7 +2769,7 @@ int get_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p)
2745
2769
}
2746
2770
2747
2771
/* collect core counters only for 1st thread in core */
2748
- if (!( t -> flags & CPU_IS_FIRST_THREAD_IN_CORE ))
2772
+ if (!is_cpu_first_thread_in_core ( t , c , p ))
2749
2773
goto done ;
2750
2774
2751
2775
if (DO_BIC (BIC_CPU_c3 ) || soft_c1_residency_display (BIC_CPU_c3 )) {
@@ -2800,7 +2824,7 @@ int get_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p)
2800
2824
}
2801
2825
2802
2826
/* collect package counters only for 1st core in package */
2803
- if (!( t -> flags & CPU_IS_FIRST_CORE_IN_PACKAGE ))
2827
+ if (!is_cpu_first_core_in_package ( t , c , p ))
2804
2828
goto done ;
2805
2829
2806
2830
if (DO_BIC (BIC_Totl_c0 )) {
@@ -4581,7 +4605,7 @@ int print_epb(struct thread_data *t, struct core_data *c, struct pkg_data *p)
4581
4605
cpu = t -> cpu_id ;
4582
4606
4583
4607
/* EPB is per-package */
4584
- if (!( t -> flags & CPU_IS_FIRST_THREAD_IN_CORE ) || !( t -> flags & CPU_IS_FIRST_CORE_IN_PACKAGE ))
4608
+ if (!is_cpu_first_thread_in_package ( t , c , p ))
4585
4609
return 0 ;
4586
4610
4587
4611
if (cpu_migrate (cpu )) {
@@ -4630,7 +4654,7 @@ int print_hwp(struct thread_data *t, struct core_data *c, struct pkg_data *p)
4630
4654
cpu = t -> cpu_id ;
4631
4655
4632
4656
/* MSR_HWP_CAPABILITIES is per-package */
4633
- if (!( t -> flags & CPU_IS_FIRST_THREAD_IN_CORE ) || !( t -> flags & CPU_IS_FIRST_CORE_IN_PACKAGE ))
4657
+ if (!is_cpu_first_thread_in_package ( t , c , p ))
4634
4658
return 0 ;
4635
4659
4636
4660
if (cpu_migrate (cpu )) {
@@ -4713,7 +4737,7 @@ int print_perf_limit(struct thread_data *t, struct core_data *c, struct pkg_data
4713
4737
cpu = t -> cpu_id ;
4714
4738
4715
4739
/* per-package */
4716
- if (!( t -> flags & CPU_IS_FIRST_THREAD_IN_CORE ) || !( t -> flags & CPU_IS_FIRST_CORE_IN_PACKAGE ))
4740
+ if (!is_cpu_first_thread_in_package ( t , c , p ))
4717
4741
return 0 ;
4718
4742
4719
4743
if (cpu_migrate (cpu )) {
@@ -4930,7 +4954,7 @@ int print_rapl(struct thread_data *t, struct core_data *c, struct pkg_data *p)
4930
4954
return 0 ;
4931
4955
4932
4956
/* RAPL counters are per package, so print only for 1st thread/package */
4933
- if (!( t -> flags & CPU_IS_FIRST_THREAD_IN_CORE ) || !( t -> flags & CPU_IS_FIRST_CORE_IN_PACKAGE ))
4957
+ if (!is_cpu_first_thread_in_package ( t , c , p ))
4934
4958
return 0 ;
4935
4959
4936
4960
cpu = t -> cpu_id ;
@@ -5083,7 +5107,7 @@ int set_temperature_target(struct thread_data *t, struct core_data *c, struct pk
5083
5107
return 0 ;
5084
5108
5085
5109
/* this is a per-package concept */
5086
- if (!( t -> flags & CPU_IS_FIRST_THREAD_IN_CORE ) || !( t -> flags & CPU_IS_FIRST_CORE_IN_PACKAGE ))
5110
+ if (!is_cpu_first_thread_in_package ( t , c , p ))
5087
5111
return 0 ;
5088
5112
5089
5113
cpu = t -> cpu_id ;
@@ -5152,15 +5176,15 @@ int print_thermal(struct thread_data *t, struct core_data *c, struct pkg_data *p
5152
5176
cpu = t -> cpu_id ;
5153
5177
5154
5178
/* DTS is per-core, no need to print for each thread */
5155
- if (!( t -> flags & CPU_IS_FIRST_THREAD_IN_CORE ))
5179
+ if (!is_cpu_first_thread_in_core ( t , c , p ))
5156
5180
return 0 ;
5157
5181
5158
5182
if (cpu_migrate (cpu )) {
5159
5183
fprintf (outf , "print_thermal: Could not migrate to CPU %d\n" , cpu );
5160
5184
return -1 ;
5161
5185
}
5162
5186
5163
- if (do_ptm && ( t -> flags & CPU_IS_FIRST_CORE_IN_PACKAGE )) {
5187
+ if (do_ptm && is_cpu_first_core_in_package ( t , c , p )) {
5164
5188
if (get_msr (cpu , MSR_IA32_PACKAGE_THERM_STATUS , & msr ))
5165
5189
return 0 ;
5166
5190
0 commit comments