Skip to content

Commit 6ff7cb3

Browse files
committed
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: Len Brown <len.brown@intel.com>
1 parent 4be61e6 commit 6ff7cb3

1 file changed

Lines changed: 29 additions & 33 deletions

File tree

tools/power/x86/turbostat/turbostat.c

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4785,12 +4785,33 @@ double discover_bclk(unsigned int family, unsigned int model)
47854785
* below this value, including the Digital Thermal Sensor (DTS),
47864786
* Package Thermal Management Sensor (PTM), and thermal event thresholds.
47874787
*/
4788-
int set_temperature_target(struct thread_data *t, struct core_data *c, struct pkg_data *p)
4788+
int read_tcc_activation_temp()
47894789
{
47904790
unsigned long long msr;
4791-
unsigned int target_c_local;
4792-
int cpu;
4791+
unsigned int tcc, target_c, offset_c;
4792+
4793+
/* Temperature Target MSR is Nehalem and newer only */
4794+
if (!do_nhm_platform_info)
4795+
return 0;
4796+
4797+
if (get_msr(base_cpu, MSR_IA32_TEMPERATURE_TARGET, &msr))
4798+
return 0;
47934799

4800+
target_c = (msr >> 16) & 0xFF;
4801+
4802+
offset_c = (msr >> 24) & 0xF;
4803+
4804+
tcc = target_c - offset_c;
4805+
4806+
if (!quiet)
4807+
fprintf(outf, "cpu%d: MSR_IA32_TEMPERATURE_TARGET: 0x%08llx (%d C) (%d default - %d offset)\n",
4808+
base_cpu, msr, tcc, target_c, offset_c);
4809+
4810+
return tcc;
4811+
}
4812+
4813+
int set_temperature_target(struct thread_data *t, struct core_data *c, struct pkg_data *p)
4814+
{
47944815
/* tcc_activation_temp is used only for dts or ptm */
47954816
if (!(do_dts || do_ptm))
47964817
return 0;
@@ -4799,43 +4820,18 @@ int set_temperature_target(struct thread_data *t, struct core_data *c, struct pk
47994820
if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE) || !(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE))
48004821
return 0;
48014822

4802-
cpu = t->cpu_id;
4803-
if (cpu_migrate(cpu)) {
4804-
fprintf(outf, "Could not migrate to CPU %d\n", cpu);
4805-
return -1;
4806-
}
4807-
48084823
if (tcc_activation_temp_override != 0) {
48094824
tcc_activation_temp = tcc_activation_temp_override;
4810-
fprintf(outf, "cpu%d: Using cmdline TCC Target (%d C)\n",
4811-
cpu, tcc_activation_temp);
4825+
fprintf(outf, "Using cmdline TCC Target (%d C)\n", tcc_activation_temp);
48124826
return 0;
48134827
}
48144828

4815-
/* Temperature Target MSR is Nehalem and newer only */
4816-
if (!do_nhm_platform_info)
4817-
goto guess;
4818-
4819-
if (get_msr(base_cpu, MSR_IA32_TEMPERATURE_TARGET, &msr))
4820-
goto guess;
4821-
4822-
target_c_local = (msr >> 16) & 0xFF;
4823-
4824-
if (!quiet)
4825-
fprintf(outf, "cpu%d: MSR_IA32_TEMPERATURE_TARGET: 0x%08llx (%d C)\n",
4826-
cpu, msr, target_c_local);
4827-
4828-
if (!target_c_local)
4829-
goto guess;
4830-
4831-
tcc_activation_temp = target_c_local;
4832-
4833-
return 0;
4829+
tcc_activation_temp = read_tcc_activation_temp();
4830+
if (tcc_activation_temp)
4831+
return 0;
48344832

4835-
guess:
48364833
tcc_activation_temp = TJMAX_DEFAULT;
4837-
fprintf(outf, "cpu%d: Guessing tjMax %d C, Please use -T to specify\n",
4838-
cpu, tcc_activation_temp);
4834+
fprintf(outf, "Guessing tjMax %d C, Please use -T to specify\n", tcc_activation_temp);
48394835

48404836
return 0;
48414837
}

0 commit comments

Comments
 (0)