projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
No need to initialize static bools to false
[collectd.git]
/
src
/
turbostat.c
diff --git
a/src/turbostat.c
b/src/turbostat.c
index
568fb1e
..
89bf3cb
100644
(file)
--- a/
src/turbostat.c
+++ b/
src/turbostat.c
@@
-65,12
+65,12
@@
*
* This value is automatically set if mperf or aperf go backward
*/
*
* This value is automatically set if mperf or aperf go backward
*/
-static
_B
ool aperf_mperf_unstable;
+static
b
ool aperf_mperf_unstable;
/*
* If set, use kernel logical core numbering for all "per core" metrics.
*/
/*
* If set, use kernel logical core numbering for all "per core" metrics.
*/
-static
_B
ool config_lcn;
+static
b
ool config_lcn;
/*
* Bitmask of the list of core C states supported by the processor.
/*
* Bitmask of the list of core C states supported by the processor.
@@
-78,7
+78,7
@@
static _Bool config_lcn;
*/
static unsigned int do_core_cstate;
static unsigned int config_core_cstate;
*/
static unsigned int do_core_cstate;
static unsigned int config_core_cstate;
-static
_B
ool apply_config_core_cstate;
+static
b
ool apply_config_core_cstate;
/*
* Bitmask of the list of pacages C states supported by the processor.
/*
* Bitmask of the list of pacages C states supported by the processor.
@@
-86,15
+86,15
@@
static _Bool apply_config_core_cstate;
*/
static unsigned int do_pkg_cstate;
static unsigned int config_pkg_cstate;
*/
static unsigned int do_pkg_cstate;
static unsigned int config_pkg_cstate;
-static
_B
ool apply_config_pkg_cstate;
+static
b
ool apply_config_pkg_cstate;
/*
* Boolean indicating if the processor supports 'I/O System-Management Interrupt
* counter'
*/
/*
* Boolean indicating if the processor supports 'I/O System-Management Interrupt
* counter'
*/
-static
_B
ool do_smi;
-static
_B
ool config_smi;
-static
_B
ool apply_config_smi;
+static
b
ool do_smi;
+static
b
ool config_smi;
+static
b
ool apply_config_smi;
/*
* Boolean indicating if the processor supports 'Digital temperature sensor'
/*
* Boolean indicating if the processor supports 'Digital temperature sensor'
@@
-105,9
+105,9
@@
static _Bool apply_config_smi;
* might be wrong
* - Temperatures above the tcc_activation_temp are not recorded
*/
* might be wrong
* - Temperatures above the tcc_activation_temp are not recorded
*/
-static
_B
ool do_dts;
-static
_B
ool config_dts;
-static
_B
ool apply_config_dts;
+static
b
ool do_dts;
+static
b
ool config_dts;
+static
b
ool apply_config_dts;
/*
* Boolean indicating if the processor supports 'Package thermal management'
/*
* Boolean indicating if the processor supports 'Package thermal management'
@@
-118,9
+118,9
@@
static _Bool apply_config_dts;
* might be wrong
* - Temperatures above the tcc_activation_temp are not recorded
*/
* might be wrong
* - Temperatures above the tcc_activation_temp are not recorded
*/
-static
_B
ool do_ptm;
-static
_B
ool config_ptm;
-static
_B
ool apply_config_ptm;
+static
b
ool do_ptm;
+static
b
ool config_ptm;
+static
b
ool apply_config_ptm;
/*
* Thermal Control Circuit Activation Temperature as configured by the user.
/*
* Thermal Control Circuit Activation Temperature as configured by the user.
@@
-131,7
+131,7
@@
static unsigned int tcc_activation_temp;
static unsigned int do_rapl;
static unsigned int config_rapl;
static unsigned int do_rapl;
static unsigned int config_rapl;
-static
_B
ool apply_config_rapl;
+static
b
ool apply_config_rapl;
static double rapl_energy_units;
#define RAPL_PKG (1 << 0)
static double rapl_energy_units;
#define RAPL_PKG (1 << 0)
@@
-195,10
+195,10
@@
static struct pkg_data {
#define DELTA_COUNTERS thread_delta, core_delta, package_delta
#define ODD_COUNTERS thread_odd, core_odd, package_odd
#define EVEN_COUNTERS thread_even, core_even, package_even
#define DELTA_COUNTERS thread_delta, core_delta, package_delta
#define ODD_COUNTERS thread_odd, core_odd, package_odd
#define EVEN_COUNTERS thread_even, core_even, package_even
-static
_B
ool is_even = 1;
+static
b
ool is_even = 1;
-static
_Bool allocated = 0
;
-static
_Bool initialized = 0
;
+static
bool allocated
;
+static
bool initialized
;
#define GET_THREAD(thread_base, thread_no, core_no, pkg_no) \
(thread_base + (pkg_no)*topology.num_cores * topology.num_threads + \
#define GET_THREAD(thread_base, thread_no, core_no, pkg_no) \
(thread_base + (pkg_no)*topology.num_cores * topology.num_threads + \
@@
-210,8
+210,8
@@
static _Bool initialized = 0;
struct cpu_topology {
unsigned int package_id;
unsigned int core_id;
struct cpu_topology {
unsigned int package_id;
unsigned int core_id;
-
_B
ool first_core_in_package;
-
_B
ool first_thread_in_core;
+
b
ool first_core_in_package;
+
b
ool first_thread_in_core;
};
static struct topology {
};
static struct topology {
@@
-246,7
+246,7
@@
static const int config_keys_num = STATIC_ARRAY_SIZE(config_keys);
* 1
*/
static int __attribute__((warn_unused_result))
* 1
*/
static int __attribute__((warn_unused_result))
-open_msr(unsigned int cpu,
_B
ool multiple_read) {
+open_msr(unsigned int cpu,
b
ool multiple_read) {
char pathname[32];
int fd;
char pathname[32];
int fd;
@@
-266,7
+266,7
@@
open_msr(unsigned int cpu, _Bool multiple_read) {
}
}
}
}
- s
s
nprintf(pathname, sizeof(pathname), "/dev/cpu/%d/msr", cpu);
+ snprintf(pathname, sizeof(pathname), "/dev/cpu/%d/msr", cpu);
fd = open(pathname, O_RDONLY);
if (fd < 0) {
ERROR("turbostat plugin: failed to open %s", pathname);
fd = open(pathname, O_RDONLY);
if (fd < 0) {
ERROR("turbostat plugin: failed to open %s", pathname);
@@
-556,7
+556,7
@@
static int submit_counters(struct thread_data *t, struct core_data *c,
DEBUG("turbostat plugin: submit stats for cpu: %d, core: %d, pkg: %d",
t->cpu_id, c->core_id, p->package_id);
DEBUG("turbostat plugin: submit stats for cpu: %d, core: %d, pkg: %d",
t->cpu_id, c->core_id, p->package_id);
- s
s
nprintf(name, sizeof(name), "cpu%02d", t->cpu_id);
+ snprintf(name, sizeof(name), "cpu%02d", t->cpu_id);
if (!aperf_mperf_unstable)
turbostat_submit(name, "percent", "c0", 100.0 * t->mperf / t->tsc);
if (!aperf_mperf_unstable)
turbostat_submit(name, "percent", "c0", 100.0 * t->mperf / t->tsc);
@@
-585,7
+585,11
@@
static int submit_counters(struct thread_data *t, struct core_data *c,
/* If not using logical core numbering, set core id */
if (!config_lcn) {
/* If not using logical core numbering, set core id */
if (!config_lcn) {
- ssnprintf(name, sizeof(name), "core%02d", c->core_id);
+ if (topology.num_packages > 1)
+ snprintf(name, sizeof(name), "pkg%02d-core%02d", p->package_id,
+ c->core_id);
+ else
+ snprintf(name, sizeof(name), "core%02d", c->core_id);
}
if (do_core_cstate & (1 << 3))
}
if (do_core_cstate & (1 << 3))
@@
-602,7
+606,7
@@
static int submit_counters(struct thread_data *t, struct core_data *c,
if (!(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE))
goto done;
if (!(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE))
goto done;
- s
s
nprintf(name, sizeof(name), "pkg%02d", p->package_id);
+ snprintf(name, sizeof(name), "pkg%02d", p->package_id);
if (do_ptm)
turbostat_submit(name, "temperature", NULL, p->pkg_temp_c);
if (do_ptm)
turbostat_submit(name, "temperature", NULL, p->pkg_temp_c);
@@
-974,6
+978,7
@@
static int __attribute__((warn_unused_result)) probe_cpu(void) {
case 0x45: /* HSW */
case 0x46: /* HSW */
case 0x3D: /* BDW */
case 0x45: /* HSW */
case 0x46: /* HSW */
case 0x3D: /* BDW */
+ case 0x5E: /* SKL */
do_rapl = RAPL_PKG | RAPL_CORES | RAPL_GFX;
break;
case 0x3F: /* HSX */
do_rapl = RAPL_PKG | RAPL_CORES | RAPL_GFX;
break;
case 0x3F: /* HSX */
@@
-1064,8
+1069,8
@@
static int get_threads_on_core(unsigned int cpu) {
int matches;
char character;
int matches;
char character;
- s
s
nprintf(path, sizeof(path),
-
"/sys/devices/system/cpu/cpu%d/topology/thread_siblings_list", cpu);
+ snprintf(path, sizeof(path),
+ "/sys/devices/system/cpu/cpu%d/topology/thread_siblings_list", cpu);
filep = fopen(path, "r");
if (!filep) {
ERROR("turbostat plugin: Failed to open '%s'", path);
filep = fopen(path, "r");
if (!filep) {
ERROR("turbostat plugin: Failed to open '%s'", path);
@@
-1118,7
+1123,7
@@
for_all_proc_cpus(int(func)(unsigned int)) {
retval = func(cpu_num);
if (retval) {
fclose(fp);
retval = func(cpu_num);
if (retval) {
fclose(fp);
- return
(retval)
;
+ return
retval
;
}
}
fclose(fp);
}
}
fclose(fp);