@@ -2230,6 +2230,9 @@ int add_msr_counter(int cpu, off_t offset)
2230
2230
if (no_msr )
2231
2231
return -1 ;
2232
2232
2233
+ if (!offset )
2234
+ return -1 ;
2235
+
2233
2236
retval = pread (get_msr_fd (cpu ), & value , sizeof (value ), offset );
2234
2237
2235
2238
/* if the read failed, the probe fails */
@@ -7875,6 +7878,9 @@ int add_rapl_perf_counter(int cpu, struct rapl_counter_info_t *rci, const struct
7875
7878
if (no_perf )
7876
7879
return -1 ;
7877
7880
7881
+ if (!cai -> perf_name )
7882
+ return -1 ;
7883
+
7878
7884
const double scale = read_perf_scale (cai -> perf_subsys , cai -> perf_name );
7879
7885
7880
7886
if (scale == 0.0 )
@@ -7986,15 +7992,14 @@ void rapl_perf_init(void)
7986
7992
if (platform -> rapl_msrs & cai -> feature_mask ) {
7987
7993
7988
7994
/* Use perf API for this counter */
7989
- if (!no_perf && cai -> perf_name
7990
- && add_rapl_perf_counter (cpu , rci , cai , & scale , & unit ) != -1 ) {
7995
+ if (add_rapl_perf_counter (cpu , rci , cai , & scale , & unit ) != -1 ) {
7991
7996
rci -> source [cai -> rci_index ] = COUNTER_SOURCE_PERF ;
7992
7997
rci -> scale [cai -> rci_index ] = scale * cai -> compat_scale ;
7993
7998
rci -> unit [cai -> rci_index ] = unit ;
7994
7999
rci -> flags [cai -> rci_index ] = cai -> flags ;
7995
8000
7996
8001
/* Use MSR for this counter */
7997
- } else if (! no_msr && cai -> msr && add_rapl_msr_counter (cpu , cai -> msr , cai -> rci_index ) >= 0 ) {
8002
+ } else if (add_rapl_msr_counter (cpu , cai -> msr , cai -> rci_index ) >= 0 ) {
7998
8003
rci -> source [cai -> rci_index ] = COUNTER_SOURCE_MSR ;
7999
8004
rci -> msr [cai -> rci_index ] = cai -> msr ;
8000
8005
rci -> msr_mask [cai -> rci_index ] = cai -> msr_mask ;
@@ -8042,6 +8047,9 @@ int add_cstate_perf_counter(int cpu, struct cstate_counter_info_t *cci, const st
8042
8047
if (no_perf )
8043
8048
return -1 ;
8044
8049
8050
+ if (!cai -> perf_name )
8051
+ return -1 ;
8052
+
8045
8053
int * pfd_group = get_cstate_perf_group_fd (cci , cai -> perf_subsys );
8046
8054
8047
8055
if (pfd_group == NULL )
@@ -8073,6 +8081,9 @@ int add_msr_perf_counter(int cpu, struct msr_counter_info_t *cci, const struct m
8073
8081
if (no_perf )
8074
8082
return -1 ;
8075
8083
8084
+ if (!cai -> perf_name )
8085
+ return -1 ;
8086
+
8076
8087
const unsigned int type = read_perf_type (cai -> perf_subsys );
8077
8088
const unsigned int config = read_perf_config (cai -> perf_subsys , cai -> perf_name );
8078
8089
@@ -8119,12 +8130,12 @@ void msr_perf_init_(void)
8119
8130
8120
8131
if (cai -> needed ) {
8121
8132
/* Use perf API for this counter */
8122
- if (! no_perf && cai -> perf_name && add_msr_perf_counter (cpu , cci , cai ) != -1 ) {
8133
+ if (add_msr_perf_counter (cpu , cci , cai ) != -1 ) {
8123
8134
cci -> source [cai -> rci_index ] = COUNTER_SOURCE_PERF ;
8124
8135
cai -> present = true;
8125
8136
8126
8137
/* User MSR for this counter */
8127
- } else if (! no_msr && cai -> msr && add_msr_counter (cpu , cai -> msr ) >= 0 ) {
8138
+ } else if (add_msr_counter (cpu , cai -> msr ) >= 0 ) {
8128
8139
cci -> source [cai -> rci_index ] = COUNTER_SOURCE_MSR ;
8129
8140
cci -> msr [cai -> rci_index ] = cai -> msr ;
8130
8141
cci -> msr_mask [cai -> rci_index ] = cai -> msr_mask ;
@@ -8232,12 +8243,12 @@ void cstate_perf_init_(bool soft_c1)
8232
8243
8233
8244
if (counter_needed && counter_supported ) {
8234
8245
/* Use perf API for this counter */
8235
- if (! no_perf && cai -> perf_name && add_cstate_perf_counter (cpu , cci , cai ) != -1 ) {
8246
+ if (add_cstate_perf_counter (cpu , cci , cai ) != -1 ) {
8236
8247
8237
8248
cci -> source [cai -> rci_index ] = COUNTER_SOURCE_PERF ;
8238
8249
8239
8250
/* User MSR for this counter */
8240
- } else if (! no_msr && cai -> msr && pkg_cstate_limit >= cai -> pkg_cstate_limit
8251
+ } else if (pkg_cstate_limit >= cai -> pkg_cstate_limit
8241
8252
&& add_msr_counter (cpu , cai -> msr ) >= 0 ) {
8242
8253
cci -> source [cai -> rci_index ] = COUNTER_SOURCE_MSR ;
8243
8254
cci -> msr [cai -> rci_index ] = cai -> msr ;
0 commit comments