staticint get_did(union core_pstate pstate)
{ int t;
/* Fam 1Ah onward do not use did */ if (cpupower_cpu_info.family >= 0x1A) return 0;
if (cpupower_cpu_info.caps & CPUPOWER_CAP_AMD_PSTATEDEF)
t = pstate.pstatedef.did; elseif (cpupower_cpu_info.family == 0x12)
t = pstate.val & 0xf; else
t = pstate.pstate.did;
return t;
}
staticint get_cof(union core_pstate pstate)
{ int t; int fid, did, cof = 0;
did = get_did(pstate); if (cpupower_cpu_info.caps & CPUPOWER_CAP_AMD_PSTATEDEF) { if (cpupower_cpu_info.family >= 0x1A) {
fid = pstate.pstatedef2.fid; if (fid > 0x0f)
cof = (fid * 5);
} else {
fid = pstate.pstatedef.fid;
cof = 200 * fid / did;
}
} else {
t = 0x10;
fid = pstate.pstate.fid; if (cpupower_cpu_info.family == 0x11)
t = 0x8;
cof = (100 * (fid + t)) >> did;
} return cof;
}
/* Needs: * cpu -> the cpu that gets evaluated * boost_states -> how much boost states the machines support * * Fills up: * pstates -> a pointer to an array of size MAX_HW_PSTATES * must be initialized with zeros. * All available HW pstates (including boost states) * no -> amount of pstates above array got filled up with * * returns zero on success, -1 on failure
*/ int decode_pstates(unsignedint cpu, int boost_states, unsignedlong *pstates, int *no)
{ int i, psmax; union core_pstate pstate; unsignedlonglong val;
/* Only read out frequencies from HW if HW Pstate is supported, * otherwise frequencies are exported via ACPI tables.
*/ if (!(cpupower_cpu_info.caps & CPUPOWER_CAP_AMD_HW_PSTATE)) return -1;
if (read_msr(cpu, MSR_AMD_PSTATE_LIMIT, &val)) return -1;
psmax = (val >> 4) & 0x7;
psmax += boost_states; for (i = 0; i <= psmax; i++) { if (i >= MAX_HW_PSTATES) {
fprintf(stderr, "HW pstates [%d] exceeding max [%d]\n",
psmax, MAX_HW_PSTATES); return -1;
} if (read_msr(cpu, MSR_AMD_PSTATE + i, &pstate.val)) return -1;
/* The enabled bit (bit 63) is common for all families */ if (!pstate.pstatedef.en) continue;
void amd_pstate_show_perf_and_freq(unsignedint cpu, int no_rounding)
{
printf(_(" amd-pstate limits:\n"));
printf(_(" Highest Performance: %lu. Maximum Frequency: "),
amd_pstate_get_data(cpu, AMD_PSTATE_HIGHEST_PERF)); /* * If boost isn't active, the cpuinfo_max doesn't indicate real max * frequency. So we read it back from amd-pstate sysfs entry.
*/
print_speed(amd_pstate_get_data(cpu, AMD_PSTATE_MAX_FREQ), no_rounding);
printf(".\n");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.