@@ -1198,6 +1198,30 @@ int for_all_cpus(int (func) (struct thread_data *, struct core_data *, struct pk
11981198 return 0 ;
11991199}
12001200
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+
12011225int cpu_migrate (int cpu )
12021226{
12031227 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
16821706 int printed = 0 ;
16831707
16841708 /* 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 ))
16861710 return 0 ;
16871711
16881712 /* 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 ))
16901714 return 0 ;
16911715
16921716 /*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
18201844 outp += sprintf (outp , "%s%.2f" , (printed ++ ? delim : "" ), 100.0 * t -> c1 / tsc );
18211845
18221846 /* 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 ))
18241848 goto done ;
18251849
18261850 if (DO_BIC (BIC_CPU_c3 ))
@@ -1867,7 +1891,7 @@ int format_counters(struct thread_data *t, struct core_data *c, struct pkg_data
18671891 outp += sprintf (outp , fmt8 , (printed ++ ? delim : "" ), c -> core_energy * rapl_energy_units );
18681892
18691893 /* 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 ))
18711895 goto done ;
18721896
18731897 /* PkgTmp */
@@ -2202,7 +2226,7 @@ int delta_cpu(struct thread_data *t, struct core_data *c,
22022226 int retval = 0 ;
22032227
22042228 /* 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 ) )
22062230 delta_core (c , c2 );
22072231
22082232 /* always calculate thread delta */
@@ -2211,7 +2235,7 @@ int delta_cpu(struct thread_data *t, struct core_data *c,
22112235 return retval ;
22122236
22132237 /* 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 ) )
22152239 retval = delta_package (p , p2 );
22162240
22172241 return retval ;
@@ -2325,7 +2349,7 @@ int sum_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p)
23252349 }
23262350
23272351 /* 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 ))
23292353 return 0 ;
23302354
23312355 average .cores .c3 += c -> c3 ;
@@ -2345,7 +2369,7 @@ int sum_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p)
23452369 }
23462370
23472371 /* 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 ))
23492373 return 0 ;
23502374
23512375 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)
27452769 }
27462770
27472771 /* 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 ))
27492773 goto done ;
27502774
27512775 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)
28002824 }
28012825
28022826 /* 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 ))
28042828 goto done ;
28052829
28062830 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)
45814605 cpu = t -> cpu_id ;
45824606
45834607 /* 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 ))
45854609 return 0 ;
45864610
45874611 if (cpu_migrate (cpu )) {
@@ -4630,7 +4654,7 @@ int print_hwp(struct thread_data *t, struct core_data *c, struct pkg_data *p)
46304654 cpu = t -> cpu_id ;
46314655
46324656 /* 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 ))
46344658 return 0 ;
46354659
46364660 if (cpu_migrate (cpu )) {
@@ -4713,7 +4737,7 @@ int print_perf_limit(struct thread_data *t, struct core_data *c, struct pkg_data
47134737 cpu = t -> cpu_id ;
47144738
47154739 /* 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 ))
47174741 return 0 ;
47184742
47194743 if (cpu_migrate (cpu )) {
@@ -4930,7 +4954,7 @@ int print_rapl(struct thread_data *t, struct core_data *c, struct pkg_data *p)
49304954 return 0 ;
49314955
49324956 /* 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 ))
49344958 return 0 ;
49354959
49364960 cpu = t -> cpu_id ;
@@ -5083,7 +5107,7 @@ int set_temperature_target(struct thread_data *t, struct core_data *c, struct pk
50835107 return 0 ;
50845108
50855109 /* 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 ))
50875111 return 0 ;
50885112
50895113 cpu = t -> cpu_id ;
@@ -5152,15 +5176,15 @@ int print_thermal(struct thread_data *t, struct core_data *c, struct pkg_data *p
51525176 cpu = t -> cpu_id ;
51535177
51545178 /* 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 ))
51565180 return 0 ;
51575181
51585182 if (cpu_migrate (cpu )) {
51595183 fprintf (outf , "print_thermal: Could not migrate to CPU %d\n" , cpu );
51605184 return -1 ;
51615185 }
51625186
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 )) {
51645188 if (get_msr (cpu , MSR_IA32_PACKAGE_THERM_STATUS , & msr ))
51655189 return 0 ;
51665190
0 commit comments