Message ID | 20180725085206.132156-1-dedekind1@gmail.com (mailing list archive) |
---|---|
State | Accepted, archived |
Delegated to: | Len Brown |
Headers | show |
Series | turbostat: fix bogus summary values | expand |
Applied, Thanks! On Wed, Jul 25, 2018 at 4:52 AM Artem Bityutskiy <dedekind1@gmail.com> wrote: > > From: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> > > This patch fixes a regression introduced in > > 8cb48b32a5de tools/power turbostat: track thread ID in cpu_topology > > Turbostat uses incorrect cores number ('topo.num_cores') - its value is count > of logical CPUs, instead of count of physical cores. So it is twice as large as > it should be on a typical Intel system. For example, on a 6 core Xeon system > 'topo.num_cores' is 12, and on a 52 core Xeon system 'topo.num_cores' is 104. > > And interestingly, on a 68-core Knights Landing Intel system 'topo.num_cores' > is 272, because this system has 4 logical CPUs per core. > > As a result, some of the turbostat calculations are incorrect. For example, > on idle 52-core Xeon system when all cores are ~99% in Core C6 (CPU%c6), the > summary (very first) line shows ~48% Core C6, while it should be ~99%. > > This patch fixes the problem by fixing 'topo.num_cores' calculation. > > Was: > > 1. Init 'thread_id' for all CPUs to -1 > 2. Run 'get_thread_siblings()' which sets it to 0 or 1 > 3. Increment 'topo.num_cores' when thread_id != -1 (bug!) > > Now: > > 1. Init 'thread_id' for all CPUs to -1 > 2. Run 'get_thread_siblings()' which sets it to 0 or 1 > 3. Increment 'topo.num_cores' when thread_id is not 0 > > I did not have a chance to test this on an AMD machine, and only tested on a > couple of Intel Xeons (6 and 52 cores). > > Reported-by: Vladislav Govtva <vladislav.govtva@intel.com> > Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> > --- > tools/power/x86/turbostat/turbostat.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c > index 4d14bbbf9b63..99782fd80091 100644 > --- a/tools/power/x86/turbostat/turbostat.c > +++ b/tools/power/x86/turbostat/turbostat.c > @@ -4840,7 +4840,7 @@ void topology_probe() > siblings = get_thread_siblings(&cpus[i]); > if (siblings > max_siblings) > max_siblings = siblings; > - if (cpus[i].thread_id != -1) > + if (cpus[i].thread_id == 0) > topo.num_cores++; > > if (debug > 1) > -- > 2.14.4 >
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c index 4d14bbbf9b63..99782fd80091 100644 --- a/tools/power/x86/turbostat/turbostat.c +++ b/tools/power/x86/turbostat/turbostat.c @@ -4840,7 +4840,7 @@ void topology_probe() siblings = get_thread_siblings(&cpus[i]); if (siblings > max_siblings) max_siblings = siblings; - if (cpus[i].thread_id != -1) + if (cpus[i].thread_id == 0) topo.num_cores++; if (debug > 1)