Skip to content

Commit

Permalink
powercap: test counter read permissions
Browse files Browse the repository at this point in the history
Check that the files inside /sys/class/powercap/intel-rapl:<n>
directories not only exist, but are readable.  On recent Linux kernels,
"energy_uj" is by default readable by root only, which is something that
PAPI fails to detect, resulting in 0 being returned for that counter
without any indication of a problem.
  • Loading branch information
iskra-anl committed Jul 26, 2023
1 parent ca89fb0 commit 24a1e64
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/components/powercap/linux-powercap.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ static int _powercap_init_component( int cidx )
if (strErr > sizeof(event_path)) HANDLE_STRING_ERROR;
// not a valid pkg event path so continue

if (access(event_path, F_OK) == -1) { continue; }
if (access(event_path, R_OK) == -1) { continue; }

strErr=snprintf(powercap_ntv_events[num_events].name, sizeof(powercap_ntv_events[num_events].name), "%s:ZONE%d", pkg_event_names[e], s);
powercap_ntv_events[num_events].name[sizeof(powercap_ntv_events[num_events].name)-1]=0;
Expand Down Expand Up @@ -286,7 +286,7 @@ static int _powercap_init_component( int cidx )
if (strErr > sizeof(event_path)) HANDLE_STRING_ERROR;

// not a valid pkg event path so continue
if (access(event_path, F_OK) == -1) { continue; }
if (access(event_path, R_OK) == -1) { continue; }

strErr=snprintf(powercap_ntv_events[num_events].name, sizeof(powercap_ntv_events[num_events].name), "%s:ZONE%d_SUBZONE%d", component_event_names[e], s, c);
powercap_ntv_events[num_events].name[sizeof(powercap_ntv_events[num_events].name)-1]=0;
Expand Down

0 comments on commit 24a1e64

Please sign in to comment.