From: Vincent Brillault Date: Sat, 18 Apr 2015 08:58:20 +0000 (+0200) Subject: Turbostat: fix thread max number detection X-Git-Tag: collectd-5.5.0~24^2~6 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=70e1e4c4fc031a971d8801903f9d11c3b1dd9bbe;p=collectd.git Turbostat: fix thread max number detection There is no "thread_id" and the value we compute is the direct number. It can only be '1' or '2' and do not start at 0 like other values. --- diff --git a/src/turbostat.c b/src/turbostat.c index 629d7925..5470e6e4 100644 --- a/src/turbostat.c +++ b/src/turbostat.c @@ -1150,8 +1150,8 @@ topology_probe() { unsigned int i; int ret; - unsigned int max_package_id, max_core_id, max_thread_id; - max_package_id = max_core_id = max_thread_id = 0; + unsigned int max_package_id, max_core_id, max_threads; + max_package_id = max_core_id = max_threads = 0; /* Clean topology */ free(topology.cpus); @@ -1220,8 +1220,8 @@ topology_probe() goto err; else num_threads = (unsigned int) ret; - if (num_threads > max_thread_id) - max_thread_id = num_threads; + if (num_threads > max_threads) + max_threads = num_threads; ret = parse_int_file("/sys/devices/system/cpu/cpu%d/topology/thread_siblings_list", i); if (ret < 0) goto err; @@ -1234,7 +1234,7 @@ topology_probe() /* Num is max + 1 (need to count 0) */ topology.num_packages = max_package_id + 1; topology.num_cores = max_core_id + 1; - topology.num_threads = max_thread_id + 1; + topology.num_threads = max_threads; return 0; err: