@@ -1149,7 +1149,7 @@ struct timeval tv_even, tv_odd, tv_delta;
1149
1149
int * irq_column_2_cpu ; /* /proc/interrupts column numbers */
1150
1150
int * irqs_per_cpu ; /* indexed by cpu_num */
1151
1151
1152
- void setup_all_buffers (void );
1152
+ void setup_all_buffers (bool startup );
1153
1153
1154
1154
char * sys_lpi_file ;
1155
1155
char * sys_lpi_file_sysfs = "/sys/devices/system/cpu/cpuidle/low_power_idle_system_residency_us" ;
@@ -3691,7 +3691,7 @@ int for_all_proc_cpus(int (func) (int))
3691
3691
void re_initialize (void )
3692
3692
{
3693
3693
free_all_buffers ();
3694
- setup_all_buffers ();
3694
+ setup_all_buffers (false );
3695
3695
fprintf (outf , "turbostat: re-initialized with num_cpus %d, allowed_cpus %d\n" , topo .num_cpus , topo .allowed_cpus );
3696
3696
}
3697
3697
@@ -5692,7 +5692,7 @@ int dir_filter(const struct dirent *dirp)
5692
5692
return 0 ;
5693
5693
}
5694
5694
5695
- void topology_probe ()
5695
+ void topology_probe (bool startup )
5696
5696
{
5697
5697
int i ;
5698
5698
int max_core_id = 0 ;
@@ -5734,7 +5734,12 @@ void topology_probe()
5734
5734
CPU_ZERO_S (cpu_allowed_setsize , cpu_allowed_set );
5735
5735
5736
5736
/*
5737
- * Validate that all cpus in cpu_subset are also in cpu_present_set
5737
+ * Validate cpu_subset and update cpu_allowed_set.
5738
+ *
5739
+ * Make sure all cpus in cpu_subset are also in cpu_present_set during startup,
5740
+ * and give a warning when cpus in cpu_subset become unavailable at runtime.
5741
+ *
5742
+ * cpu_allowed_set is the intersection of cpu_present_set and cpu_subset.
5738
5743
*/
5739
5744
for (i = 0 ; i < CPU_SUBSET_MAXCPUS ; ++ i ) {
5740
5745
if (!cpu_subset ) {
@@ -5743,9 +5748,15 @@ void topology_probe()
5743
5748
continue ;
5744
5749
}
5745
5750
if (CPU_ISSET_S (i , cpu_subset_size , cpu_subset )) {
5746
- if (!CPU_ISSET_S (i , cpu_present_setsize , cpu_present_set ))
5747
- err (1 , "cpu%d not present" , i );
5748
- CPU_SET_S (i , cpu_allowed_setsize , cpu_allowed_set );
5751
+ if (!CPU_ISSET_S (i , cpu_present_setsize , cpu_present_set )) {
5752
+ /* all cpus in cpu_subset must be in cpu_present_set during startup */
5753
+ if (startup )
5754
+ err (1 , "cpu%d not present" , i );
5755
+ else
5756
+ fprintf (stderr , "cpu%d not present\n" , i );
5757
+ } else {
5758
+ CPU_SET_S (i , cpu_allowed_setsize , cpu_allowed_set );
5759
+ }
5749
5760
}
5750
5761
}
5751
5762
@@ -5973,9 +5984,9 @@ void topology_update(void)
5973
5984
topo .allowed_packages = 0 ;
5974
5985
for_all_cpus (update_topo , ODD_COUNTERS );
5975
5986
}
5976
- void setup_all_buffers (void )
5987
+ void setup_all_buffers (bool startup )
5977
5988
{
5978
- topology_probe ();
5989
+ topology_probe (startup );
5979
5990
allocate_irq_buffers ();
5980
5991
allocate_fd_percpu ();
5981
5992
allocate_counters (& thread_even , & core_even , & package_even );
@@ -6002,7 +6013,7 @@ void set_base_cpu(void)
6002
6013
6003
6014
void turbostat_init ()
6004
6015
{
6005
- setup_all_buffers ();
6016
+ setup_all_buffers (true );
6006
6017
set_base_cpu ();
6007
6018
check_dev_msr ();
6008
6019
check_permissions ();
0 commit comments