@@ -3669,18 +3669,25 @@ void free_fd_percpu(void)
3669
3669
{
3670
3670
int i ;
3671
3671
3672
+ if (!fd_percpu )
3673
+ return ;
3674
+
3672
3675
for (i = 0 ; i < topo .max_cpu_num + 1 ; ++ i ) {
3673
3676
if (fd_percpu [i ] != 0 )
3674
3677
close (fd_percpu [i ]);
3675
3678
}
3676
3679
3677
3680
free (fd_percpu );
3681
+ fd_percpu = NULL ;
3678
3682
}
3679
3683
3680
3684
void free_fd_amperf_percpu (void )
3681
3685
{
3682
3686
int i ;
3683
3687
3688
+ if (!fd_amperf_percpu )
3689
+ return ;
3690
+
3684
3691
for (i = 0 ; i < topo .max_cpu_num + 1 ; ++ i ) {
3685
3692
if (fd_amperf_percpu [i ].mperf != 0 )
3686
3693
close (fd_amperf_percpu [i ].mperf );
@@ -3690,6 +3697,21 @@ void free_fd_amperf_percpu(void)
3690
3697
}
3691
3698
3692
3699
free (fd_amperf_percpu );
3700
+ fd_amperf_percpu = NULL ;
3701
+ }
3702
+
3703
+ void free_fd_instr_count_percpu (void )
3704
+ {
3705
+ if (!fd_instr_count_percpu )
3706
+ return ;
3707
+
3708
+ for (int i = 0 ; i < topo .max_cpu_num + 1 ; ++ i ) {
3709
+ if (fd_instr_count_percpu [i ] != 0 )
3710
+ close (fd_instr_count_percpu [i ]);
3711
+ }
3712
+
3713
+ free (fd_instr_count_percpu );
3714
+ fd_instr_count_percpu = NULL ;
3693
3715
}
3694
3716
3695
3717
void free_all_buffers (void )
@@ -3733,6 +3755,7 @@ void free_all_buffers(void)
3733
3755
outp = NULL ;
3734
3756
3735
3757
free_fd_percpu ();
3758
+ free_fd_instr_count_percpu ();
3736
3759
free_fd_amperf_percpu ();
3737
3760
3738
3761
free (irq_column_2_cpu );
@@ -4067,10 +4090,13 @@ static void update_effective_set(bool startup)
4067
4090
err (1 , "%s: cpu str malformat %s\n" , PATH_EFFECTIVE_CPUS , cpu_effective_str );
4068
4091
}
4069
4092
4093
+ void linux_perf_init (void );
4094
+
4070
4095
void re_initialize (void )
4071
4096
{
4072
4097
free_all_buffers ();
4073
4098
setup_all_buffers (false);
4099
+ linux_perf_init ();
4074
4100
fprintf (outf , "turbostat: re-initialized with num_cpus %d, allowed_cpus %d\n" , topo .num_cpus ,
4075
4101
topo .allowed_cpus );
4076
4102
}
0 commit comments