Skip to content

Commit c8bca95

Browse files
zhang-ruilenb
authored andcommitted
tools/power turbostat: Remove add_rapl_perf_counter_()
As the only caller of add_rapl_perf_counter_(), add_rapl_perf_counter() just gives extra debug output on top. There is no need to keep both functions. Remove add_rapl_perf_counter_() and move all the logic to add_rapl_perf_counter(). No functional change. Signed-off-by: Zhang Rui <rui.zhang@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
1 parent 57b5378 commit c8bca95

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

tools/power/x86/turbostat/turbostat.c

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7853,44 +7853,39 @@ static int has_instr_count_access(void)
78537853
return has_access;
78547854
}
78557855

7856-
int add_rapl_perf_counter_(int cpu, struct rapl_counter_info_t *rci, const struct rapl_counter_arch_info *cai,
7856+
int add_rapl_perf_counter(int cpu, struct rapl_counter_info_t *rci, const struct rapl_counter_arch_info *cai,
78577857
double *scale_, enum rapl_unit *unit_)
78587858
{
7859+
int ret = -1;
7860+
78597861
if (no_perf)
78607862
return -1;
78617863

78627864
const double scale = read_perf_scale(cai->perf_subsys, cai->perf_name);
78637865

78647866
if (scale == 0.0)
7865-
return -1;
7867+
goto end;
78667868

78677869
const enum rapl_unit unit = read_perf_rapl_unit(cai->perf_subsys, cai->perf_name);
78687870

78697871
if (unit == RAPL_UNIT_INVALID)
7870-
return -1;
7872+
goto end;
78717873

78727874
const unsigned int rapl_type = read_perf_type(cai->perf_subsys);
78737875
const unsigned int rapl_energy_pkg_config = read_perf_config(cai->perf_subsys, cai->perf_name);
78747876

7875-
const int fd_counter =
7876-
open_perf_counter(cpu, rapl_type, rapl_energy_pkg_config, rci->fd_perf, PERF_FORMAT_GROUP);
7877-
if (fd_counter == -1)
7878-
return -1;
7877+
ret = open_perf_counter(cpu, rapl_type, rapl_energy_pkg_config, rci->fd_perf, PERF_FORMAT_GROUP);
7878+
if (ret == -1)
7879+
goto end;
78797880

78807881
/* If it's the first counter opened, make it a group descriptor */
78817882
if (rci->fd_perf == -1)
7882-
rci->fd_perf = fd_counter;
7883+
rci->fd_perf = ret;
78837884

78847885
*scale_ = scale;
78857886
*unit_ = unit;
7886-
return fd_counter;
7887-
}
7888-
7889-
int add_rapl_perf_counter(int cpu, struct rapl_counter_info_t *rci, const struct rapl_counter_arch_info *cai,
7890-
double *scale, enum rapl_unit *unit)
7891-
{
7892-
int ret = add_rapl_perf_counter_(cpu, rci, cai, scale, unit);
78937887

7888+
end:
78947889
if (debug >= 2)
78957890
fprintf(stderr, "%s: %d (cpu: %d)\n", __func__, ret, cpu);
78967891

0 commit comments

Comments
 (0)