turbostat.c (52b3541b351389d16f028f007add4097b4d9ccaa) | turbostat.c (8a91872a547aab96554ec8785b5cd6f1b86952e0) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * turbostat -- show CPU frequency and C-state residency 4 * on modern Intel and AMD processors. 5 * 6 * Copyright (c) 2023 Intel Corporation. 7 * Len Brown <len.brown@intel.com> 8 */ --- 5504 unchanged lines hidden (view full) --- 5513 BIC_PRESENT(BIC_IPC); 5514} 5515 5516void process_cpuid() 5517{ 5518 unsigned int eax, ebx, ecx, edx; 5519 unsigned int fms, family, model, stepping, ecx_flags, edx_flags; 5520 unsigned long long ucode_patch = 0; | 1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * turbostat -- show CPU frequency and C-state residency 4 * on modern Intel and AMD processors. 5 * 6 * Copyright (c) 2023 Intel Corporation. 7 * Len Brown <len.brown@intel.com> 8 */ --- 5504 unchanged lines hidden (view full) --- 5513 BIC_PRESENT(BIC_IPC); 5514} 5515 5516void process_cpuid() 5517{ 5518 unsigned int eax, ebx, ecx, edx; 5519 unsigned int fms, family, model, stepping, ecx_flags, edx_flags; 5520 unsigned long long ucode_patch = 0; |
5521 bool ucode_patch_valid = false; |
|
5521 5522 eax = ebx = ecx = edx = 0; 5523 5524 __cpuid(0, max_level, ebx, ecx, edx); 5525 5526 if (ebx == 0x756e6547 && ecx == 0x6c65746e && edx == 0x49656e69) 5527 genuine_intel = 1; 5528 else if (ebx == 0x68747541 && ecx == 0x444d4163 && edx == 0x69746e65) --- 13 unchanged lines hidden (view full) --- 5542 family += (fms >> 20) & 0xff; 5543 if (family >= 6) 5544 model += ((fms >> 16) & 0xf) << 4; 5545 ecx_flags = ecx; 5546 edx_flags = edx; 5547 5548 if (get_msr(sched_getcpu(), MSR_IA32_UCODE_REV, &ucode_patch)) 5549 warnx("get_msr(UCODE)"); | 5522 5523 eax = ebx = ecx = edx = 0; 5524 5525 __cpuid(0, max_level, ebx, ecx, edx); 5526 5527 if (ebx == 0x756e6547 && ecx == 0x6c65746e && edx == 0x49656e69) 5528 genuine_intel = 1; 5529 else if (ebx == 0x68747541 && ecx == 0x444d4163 && edx == 0x69746e65) --- 13 unchanged lines hidden (view full) --- 5543 family += (fms >> 20) & 0xff; 5544 if (family >= 6) 5545 model += ((fms >> 16) & 0xf) << 4; 5546 ecx_flags = ecx; 5547 edx_flags = edx; 5548 5549 if (get_msr(sched_getcpu(), MSR_IA32_UCODE_REV, &ucode_patch)) 5550 warnx("get_msr(UCODE)"); |
5551 else 5552 ucode_patch_valid = true; |
|
5550 5551 /* 5552 * check max extended function levels of CPUID. 5553 * This is needed to check for invariant TSC. 5554 * This check is valid for both Intel and AMD. 5555 */ 5556 ebx = ecx = edx = 0; 5557 __cpuid(0x80000000, max_extended_level, ebx, ecx, edx); 5558 5559 if (!quiet) { | 5553 5554 /* 5555 * check max extended function levels of CPUID. 5556 * This is needed to check for invariant TSC. 5557 * This check is valid for both Intel and AMD. 5558 */ 5559 ebx = ecx = edx = 0; 5560 __cpuid(0x80000000, max_extended_level, ebx, ecx, edx); 5561 5562 if (!quiet) { |
5560 fprintf(outf, "CPUID(1): family:model:stepping 0x%x:%x:%x (%d:%d:%d) microcode 0x%x\n", 5561 family, model, stepping, family, model, stepping, 5562 (unsigned int)((ucode_patch >> 32) & 0xFFFFFFFF)); | 5563 fprintf(outf, "CPUID(1): family:model:stepping 0x%x:%x:%x (%d:%d:%d)", 5564 family, model, stepping, family, model, stepping); 5565 if (ucode_patch_valid) 5566 fprintf(outf, " microcode 0x%x", (unsigned int)((ucode_patch >> 32) & 0xFFFFFFFF)); 5567 fputc('\n', outf); 5568 |
5563 fprintf(outf, "CPUID(0x80000000): max_extended_levels: 0x%x\n", max_extended_level); 5564 fprintf(outf, "CPUID(1): %s %s %s %s %s %s %s %s %s %s\n", 5565 ecx_flags & (1 << 0) ? "SSE3" : "-", 5566 ecx_flags & (1 << 3) ? "MONITOR" : "-", 5567 ecx_flags & (1 << 6) ? "SMX" : "-", 5568 ecx_flags & (1 << 7) ? "EIST" : "-", 5569 ecx_flags & (1 << 8) ? "TM2" : "-", 5570 edx_flags & (1 << 4) ? "TSC" : "-", --- 1209 unchanged lines hidden --- | 5569 fprintf(outf, "CPUID(0x80000000): max_extended_levels: 0x%x\n", max_extended_level); 5570 fprintf(outf, "CPUID(1): %s %s %s %s %s %s %s %s %s %s\n", 5571 ecx_flags & (1 << 0) ? "SSE3" : "-", 5572 ecx_flags & (1 << 3) ? "MONITOR" : "-", 5573 ecx_flags & (1 << 6) ? "SMX" : "-", 5574 ecx_flags & (1 << 7) ? "EIST" : "-", 5575 ecx_flags & (1 << 8) ? "TM2" : "-", 5576 edx_flags & (1 << 4) ? "TSC" : "-", --- 1209 unchanged lines hidden --- |