Commit 6ff7cb37 authored by Len Brown's avatar Len Brown

tools/power turbostat: adjust for temperature offset

cpu1: MSR_IA32_TEMPERATURE_TARGET: 0x05640000 (95 C) (100 default - 5 offset)

Account for the new "offset" field in MSR_TEMPERATURE_TARGET.
While this field is usually zero, ignoring it results in over-stating
the current temperature, both per-core and per-package.
Signed-off-by: default avatarLen Brown <len.brown@intel.com>
parent 4be61e6b
...@@ -4785,12 +4785,33 @@ double discover_bclk(unsigned int family, unsigned int model) ...@@ -4785,12 +4785,33 @@ double discover_bclk(unsigned int family, unsigned int model)
* below this value, including the Digital Thermal Sensor (DTS), * below this value, including the Digital Thermal Sensor (DTS),
* Package Thermal Management Sensor (PTM), and thermal event thresholds. * Package Thermal Management Sensor (PTM), and thermal event thresholds.
*/ */
int set_temperature_target(struct thread_data *t, struct core_data *c, struct pkg_data *p) int read_tcc_activation_temp()
{ {
unsigned long long msr; unsigned long long msr;
unsigned int target_c_local; unsigned int tcc, target_c, offset_c;
int cpu;
/* Temperature Target MSR is Nehalem and newer only */
if (!do_nhm_platform_info)
return 0;
if (get_msr(base_cpu, MSR_IA32_TEMPERATURE_TARGET, &msr))
return 0;
target_c = (msr >> 16) & 0xFF;
offset_c = (msr >> 24) & 0xF;
tcc = target_c - offset_c;
if (!quiet)
fprintf(outf, "cpu%d: MSR_IA32_TEMPERATURE_TARGET: 0x%08llx (%d C) (%d default - %d offset)\n",
base_cpu, msr, tcc, target_c, offset_c);
return tcc;
}
int set_temperature_target(struct thread_data *t, struct core_data *c, struct pkg_data *p)
{
/* tcc_activation_temp is used only for dts or ptm */ /* tcc_activation_temp is used only for dts or ptm */
if (!(do_dts || do_ptm)) if (!(do_dts || do_ptm))
return 0; return 0;
...@@ -4799,43 +4820,18 @@ int set_temperature_target(struct thread_data *t, struct core_data *c, struct pk ...@@ -4799,43 +4820,18 @@ int set_temperature_target(struct thread_data *t, struct core_data *c, struct pk
if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE) || !(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE) || !(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE))
return 0; return 0;
cpu = t->cpu_id;
if (cpu_migrate(cpu)) {
fprintf(outf, "Could not migrate to CPU %d\n", cpu);
return -1;
}
if (tcc_activation_temp_override != 0) { if (tcc_activation_temp_override != 0) {
tcc_activation_temp = tcc_activation_temp_override; tcc_activation_temp = tcc_activation_temp_override;
fprintf(outf, "cpu%d: Using cmdline TCC Target (%d C)\n", fprintf(outf, "Using cmdline TCC Target (%d C)\n", tcc_activation_temp);
cpu, tcc_activation_temp);
return 0; return 0;
} }
/* Temperature Target MSR is Nehalem and newer only */ tcc_activation_temp = read_tcc_activation_temp();
if (!do_nhm_platform_info) if (tcc_activation_temp)
goto guess;
if (get_msr(base_cpu, MSR_IA32_TEMPERATURE_TARGET, &msr))
goto guess;
target_c_local = (msr >> 16) & 0xFF;
if (!quiet)
fprintf(outf, "cpu%d: MSR_IA32_TEMPERATURE_TARGET: 0x%08llx (%d C)\n",
cpu, msr, target_c_local);
if (!target_c_local)
goto guess;
tcc_activation_temp = target_c_local;
return 0; return 0;
guess:
tcc_activation_temp = TJMAX_DEFAULT; tcc_activation_temp = TJMAX_DEFAULT;
fprintf(outf, "cpu%d: Guessing tjMax %d C, Please use -T to specify\n", fprintf(outf, "Guessing tjMax %d C, Please use -T to specify\n", tcc_activation_temp);
cpu, tcc_activation_temp);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment