X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Fturbostat.c;h=85f7d87f62f977de6b49a5031928e557adae0f4b;hp=48ef1b223be066984af2bf59d7d000ccc5ceeb35;hb=a9e50e9e30ecde17e167e271060c8183bfcbf407;hpb=cba183dbc6030501446c2a7134200f5f3739152b diff --git a/src/turbostat.c b/src/turbostat.c index 48ef1b22..85f7d87f 100644 --- a/src/turbostat.c +++ b/src/turbostat.c @@ -266,7 +266,7 @@ open_msr(unsigned int cpu, _Bool multiple_read) { } } - ssnprintf(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); @@ -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); - ssnprintf(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); @@ -567,9 +567,9 @@ static int submit_counters(struct thread_data *t, struct core_data *c, 1.0 / 1000000 * t->aperf / interval_float); if ((!aperf_mperf_unstable) || (!(t->aperf > t->tsc || t->mperf > t->tsc))) - turbostat_submit(name, "frequency", "busy", 1.0 * t->tsc / 1000000 * - t->aperf / t->mperf / - interval_float); + turbostat_submit(name, "frequency", "busy", + 1.0 * t->tsc / 1000000 * t->aperf / t->mperf / + interval_float); /* Sanity check (should stay stable) */ turbostat_submit(name, "gauge", "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) { - 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)) @@ -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; - ssnprintf(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); @@ -974,6 +978,7 @@ static int __attribute__((warn_unused_result)) probe_cpu(void) { case 0x45: /* HSW */ case 0x46: /* HSW */ case 0x3D: /* BDW */ + case 0x5E: /* SKL */ 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; - ssnprintf(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); @@ -1118,7 +1123,7 @@ for_all_proc_cpus(int(func)(unsigned int)) { retval = func(cpu_num); if (retval) { fclose(fp); - return (retval); + return retval; } } fclose(fp);