Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 298048
b: refs/heads/master
c: e23da03
h: refs/heads/master
v: v3
  • Loading branch information
Len Brown committed Mar 29, 2012
1 parent 1093d32 commit 66de95a
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 107 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2815ab92ba3ab27556212cc306288dc95692824b
refs/heads/master: e23da0370f80834e971142e50253f5b79be83631
45 changes: 8 additions & 37 deletions trunk/drivers/acpi/processor_thermal.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,27 +57,6 @@ ACPI_MODULE_NAME("processor_thermal");
static DEFINE_PER_CPU(unsigned int, cpufreq_thermal_reduction_pctg);
static unsigned int acpi_thermal_cpufreq_is_init = 0;

#define reduction_pctg(cpu) \
per_cpu(cpufreq_thermal_reduction_pctg, phys_package_first_cpu(cpu))

/*
* Emulate "per package data" using per cpu data (which should really be
* provided elsewhere)
*
* Note we can lose a CPU on cpu hotunplug, in this case we forget the state
* temporarily. Fortunately that's not a big issue here (I hope)
*/
static int phys_package_first_cpu(int cpu)
{
int i;
int id = topology_physical_package_id(cpu);

for_each_online_cpu(i)
if (topology_physical_package_id(i) == id)
return i;
return 0;
}

static int cpu_has_cpufreq(unsigned int cpu)
{
struct cpufreq_policy policy;
Expand All @@ -97,7 +76,7 @@ static int acpi_thermal_cpufreq_notifier(struct notifier_block *nb,

max_freq = (
policy->cpuinfo.max_freq *
(100 - reduction_pctg(policy->cpu) * 20)
(100 - per_cpu(cpufreq_thermal_reduction_pctg, policy->cpu) * 20)
) / 100;

cpufreq_verify_within_limits(policy, 0, max_freq);
Expand All @@ -123,35 +102,27 @@ static int cpufreq_get_cur_state(unsigned int cpu)
if (!cpu_has_cpufreq(cpu))
return 0;

return reduction_pctg(cpu);
return per_cpu(cpufreq_thermal_reduction_pctg, cpu);
}

static int cpufreq_set_cur_state(unsigned int cpu, int state)
{
int i;

if (!cpu_has_cpufreq(cpu))
return 0;

reduction_pctg(cpu) = state;

/*
* Update all the CPUs in the same package because they all
* contribute to the temperature and often share the same
* frequency.
*/
for_each_online_cpu(i) {
if (topology_physical_package_id(i) ==
topology_physical_package_id(cpu))
cpufreq_update_policy(i);
}
per_cpu(cpufreq_thermal_reduction_pctg, cpu) = state;
cpufreq_update_policy(cpu);
return 0;
}

void acpi_thermal_cpufreq_init(void)
{
int i;

for (i = 0; i < nr_cpu_ids; i++)
if (cpu_present(i))
per_cpu(cpufreq_thermal_reduction_pctg, i) = 0;

i = cpufreq_register_notifier(&acpi_thermal_cpufreq_notifier_block,
CPUFREQ_POLICY_NOTIFIER);
if (!i)
Expand Down
99 changes: 58 additions & 41 deletions trunk/tools/power/x86/turbostat/turbostat.8
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ turbostat \- Report processor frequency and idle statistics
.SH SYNOPSIS
.ft B
.B turbostat
.RB [ "\-s" ]
.RB [ "\-v" ]
.RB [ "\-M MSR#" ]
.RB command
.br
.B turbostat
.RB [ "\-s" ]
.RB [ "\-v" ]
.RB [ "\-M MSR#" ]
.RB [ "\-i interval_sec" ]
Expand All @@ -25,6 +27,8 @@ supports an "invariant" TSC, plus the APERF and MPERF MSRs.
on processors that additionally support C-state residency counters.

.SS Options
The \fB-s\fP option prints only a 1-line summary for each sample interval.
.PP
The \fB-v\fP option increases verbosity.
.PP
The \fB-M MSR#\fP option dumps the specified MSR,
Expand All @@ -39,39 +43,52 @@ displays the statistics gathered since it was forked.
.SH FIELD DESCRIPTIONS
.nf
\fBpk\fP processor package number.
\fBcr\fP processor core number.
\fBcor\fP processor core number.
\fBCPU\fP Linux CPU (logical processor) number.
Note that multiple CPUs per core indicate support for Intel(R) Hyper-Threading Technology.
\fB%c0\fP percent of the interval that the CPU retired instructions.
\fBGHz\fP average clock rate while the CPU was in c0 state.
\fBTSC\fP average GHz that the TSC ran during the entire interval.
\fB%c1, %c3, %c6\fP show the percentage residency in hardware core idle states.
\fB%pc3, %pc6\fP percentage residency in hardware package idle states.
\fB%c1, %c3, %c6, %c7\fP show the percentage residency in hardware core idle states.
\fB%pc2, %pc3, %pc6, %pc7\fP percentage residency in hardware package idle states.
.fi
.PP
.SH EXAMPLE
Without any parameters, turbostat prints out counters ever 5 seconds.
(override interval with "-i sec" option, or specify a command
for turbostat to fork).

The first row of statistics reflect the average for the entire system.
The first row of statistics is a summary for the entire system.
Note that the summary is a weighted average.
Subsequent rows show per-CPU statistics.

.nf
[root@x980]# ./turbostat
cr CPU %c0 GHz TSC %c1 %c3 %c6 %pc3 %pc6
0.04 1.62 3.38 0.11 0.00 99.85 0.00 95.07
0 0 0.04 1.62 3.38 0.06 0.00 99.90 0.00 95.07
0 6 0.02 1.62 3.38 0.08 0.00 99.90 0.00 95.07
1 2 0.10 1.62 3.38 0.29 0.00 99.61 0.00 95.07
1 8 0.11 1.62 3.38 0.28 0.00 99.61 0.00 95.07
2 4 0.01 1.62 3.38 0.01 0.00 99.98 0.00 95.07
2 10 0.01 1.61 3.38 0.02 0.00 99.98 0.00 95.07
8 1 0.07 1.62 3.38 0.15 0.00 99.78 0.00 95.07
8 7 0.03 1.62 3.38 0.19 0.00 99.78 0.00 95.07
9 3 0.01 1.62 3.38 0.02 0.00 99.98 0.00 95.07
9 9 0.01 1.62 3.38 0.02 0.00 99.98 0.00 95.07
10 5 0.01 1.62 3.38 0.13 0.00 99.86 0.00 95.07
10 11 0.08 1.62 3.38 0.05 0.00 99.86 0.00 95.07
cor CPU %c0 GHz TSC %c1 %c3 %c6 %pc3 %pc6
0.60 1.63 3.38 2.91 0.00 96.49 0.00 76.64
0 0 0.59 1.62 3.38 4.51 0.00 94.90 0.00 76.64
0 6 1.13 1.64 3.38 3.97 0.00 94.90 0.00 76.64
1 2 0.08 1.62 3.38 0.07 0.00 99.85 0.00 76.64
1 8 0.03 1.62 3.38 0.12 0.00 99.85 0.00 76.64
2 4 0.01 1.62 3.38 0.06 0.00 99.93 0.00 76.64
2 10 0.04 1.62 3.38 0.02 0.00 99.93 0.00 76.64
8 1 2.85 1.62 3.38 11.71 0.00 85.44 0.00 76.64
8 7 1.98 1.62 3.38 12.58 0.00 85.44 0.00 76.64
9 3 0.36 1.62 3.38 0.71 0.00 98.93 0.00 76.64
9 9 0.09 1.62 3.38 0.98 0.00 98.93 0.00 76.64
10 5 0.03 1.62 3.38 0.09 0.00 99.87 0.00 76.64
10 11 0.07 1.62 3.38 0.06 0.00 99.87 0.00 76.64
.fi
.SH SUMMARY EXAMPLE
The "-s" option prints the column headers just once,
and then the one line system summary for each sample interval.

.nf
[root@x980]# ./turbostat -s
%c0 GHz TSC %c1 %c3 %c6 %pc3 %pc6
0.61 1.89 3.38 5.95 0.00 93.44 0.00 66.33
0.52 1.62 3.38 6.83 0.00 92.65 0.00 61.11
0.62 1.92 3.38 5.47 0.00 93.91 0.00 67.31
.fi
.SH VERBOSE EXAMPLE
The "-v" option adds verbosity to the output:
Expand Down Expand Up @@ -101,33 +118,33 @@ until ^C while the other CPUs are mostly idle:

.nf
[root@x980 lenb]# ./turbostat cat /dev/zero > /dev/null

^Ccr CPU %c0 GHz TSC %c1 %c3 %c6 %pc3 %pc6
8.49 3.63 3.38 16.23 0.66 74.63 0.00 0.00
0 0 1.22 3.62 3.38 32.18 0.00 66.60 0.00 0.00
0 6 0.40 3.61 3.38 33.00 0.00 66.60 0.00 0.00
1 2 0.11 3.14 3.38 0.19 3.95 95.75 0.00 0.00
1 8 0.05 2.88 3.38 0.25 3.95 95.75 0.00 0.00
2 4 0.00 3.13 3.38 0.02 0.00 99.98 0.00 0.00
2 10 0.00 3.09 3.38 0.02 0.00 99.98 0.00 0.00
8 1 0.04 3.50 3.38 14.43 0.00 85.54 0.00 0.00
8 7 0.03 2.98 3.38 14.43 0.00 85.54 0.00 0.00
9 3 0.00 3.16 3.38 100.00 0.00 0.00 0.00 0.00
9 9 99.93 3.63 3.38 0.06 0.00 0.00 0.00 0.00
10 5 0.01 2.82 3.38 0.08 0.00 99.91 0.00 0.00
10 11 0.02 3.36 3.38 0.06 0.00 99.91 0.00 0.00
6.950866 sec
^C
cor CPU %c0 GHz TSC %c1 %c3 %c6 %pc3 %pc6
8.63 3.64 3.38 14.46 0.49 76.42 0.00 0.00
0 0 0.34 3.36 3.38 99.66 0.00 0.00 0.00 0.00
0 6 99.96 3.64 3.38 0.04 0.00 0.00 0.00 0.00
1 2 0.14 3.50 3.38 1.75 2.04 96.07 0.00 0.00
1 8 0.38 3.57 3.38 1.51 2.04 96.07 0.00 0.00
2 4 0.01 2.65 3.38 0.06 0.00 99.93 0.00 0.00
2 10 0.03 2.12 3.38 0.04 0.00 99.93 0.00 0.00
8 1 0.91 3.59 3.38 35.27 0.92 62.90 0.00 0.00
8 7 1.61 3.63 3.38 34.57 0.92 62.90 0.00 0.00
9 3 0.04 3.38 3.38 0.20 0.00 99.76 0.00 0.00
9 9 0.04 3.29 3.38 0.20 0.00 99.76 0.00 0.00
10 5 0.03 3.08 3.38 0.12 0.00 99.85 0.00 0.00
10 11 0.05 3.07 3.38 0.10 0.00 99.85 0.00 0.00
4.907015 sec

.fi
Above the cycle soaker drives cpu9 up 3.6 Ghz turbo limit
Above the cycle soaker drives cpu6 up 3.6 Ghz turbo limit
while the other processors are generally in various states of idle.

Note that cpu3 is an HT sibling sharing core9
with cpu9, and thus it is unable to get to an idle state
deeper than c1 while cpu9 is busy.
Note that cpu0 is an HT sibling sharing core0
with cpu6, and thus it is unable to get to an idle state
deeper than c1 while cpu6 is busy.

Note that turbostat reports average GHz of 3.61, while
the arithmetic average of the GHz column above is 3.24.
Note that turbostat reports average GHz of 3.64, while
the arithmetic average of the GHz column above is lower.
This is a weighted average, where the weight is %c0. ie. it is the total number of
un-halted cycles elapsed per time divided by the number of CPUs.
.SH NOTES
Expand Down Expand Up @@ -167,6 +184,6 @@ http://www.intel.com/products/processor/manuals/
.SH "SEE ALSO"
msr(4), vmstat(8)
.PP
.SH AUTHORS
.SH AUTHOR
.nf
Written by Len Brown <len.brown@intel.com>
Loading

0 comments on commit 66de95a

Please sign in to comment.