Hi,
well, since i never did soemthing like that before, i would like to know
how i can query performance data from the (intel) cpu internals. I would
like to do something similar like this application:
http://www.cpuid.com/perfmonitor.php
AFAIK it uses a kernel driver, so this seems to be only
available in kernel mode. Well, i know how to write a
Windows Kernel Driver and IOCTL Data from ring0 to
ring3 and vice versa, but what do i have to do, to get
those data in kernel mode? Amazing would be some example,
either in Assembler or if it can be done (i dont think so)
in C,...
Can i Query this Data from Usermode maybe, maybe by using
some undocumented calls? I am mainly using NT based OS like
Windows 2000 up to Windows 7 (32 bit), no need for 64 bit yet,..
Thanks in Advance,...
Regards
Kerem
Query CPU Performance Data,...
Re: Query CPU Performance Data,...
This is all about perfmons (hardware performance monitor counters).keremg wrote:Hi,
well, since i never did soemthing like that before, i would like to know
how i can query performance data from the (intel) cpu internals. I would
like to do something similar like this application:
http://www.cpuid.com/perfmonitor.php
AFAIK it uses a kernel driver, so this seems to be only
available in kernel mode. Well, i know how to write a
Windows Kernel Driver and IOCTL Data from ring0 to
ring3 and vice versa, but what do i have to do, to get
those data in kernel mode? Amazing would be some example,
either in Assembler or if it can be done (i dont think so)
in C,...
Can i Query this Data from Usermode maybe, maybe by using
some undocumented calls? I am mainly using NT based OS like
Windows 2000 up to Windows 7 (32 bit), no need for 64 bit yet,..
Thanks in Advance,...
Regards
Kerem
Intel® 64 and IA-32 Architectures
Software Developer’s Manual
Volume 3B:System Programming Guide, Part 2
18.13 ARCHITECTURAL PERFORMANCE MONITORING
Stanislav
Re: Query CPU Performance Data,...
Hi Stanislav,stlw wrote: This is all about perfmons (hardware performance monitor counters).
Intel® 64 and IA-32 Architectures
Software Developer’s Manual
Volume 3B:System Programming Guide, Part 2
18.13 ARCHITECTURAL PERFORMANCE MONITORING
Stanislav
thanks for your reply. I must honestly confess that i really dont know
what and where i have to start. Can you provide some lines of assembly,
maybe a example to query the Number of memory data reads/writes as
it is provided on Pentium processor performance monitoring events
(manual Page 529/A.9 (Appendix A on Sheet)? This would be really great!
Thanks in advance,...
Regards
Kerem
Re: Query CPU Performance Data,...
This is the blind leading the blind, but I too have been looking into performance monitoring and may have some help that I can provide.
From what I understand (and I hope someone will correct/elaborate when necessary), you need to set one of the IA32_PERFEVTSELx MSRs with appropirate values (OS/USR mode, the desired bit mask [UnHalted instructions, etc...]. Then when one of the events happens (UnHalted instruction is executed) the cooresponding IA32_PMCx MSR will reflect the current count. It can also be set so that the APIC will generate an interrupt when the counter overflows. I'd assume the IA32_PMCx MSR must be manually read in order to query its counter state.
From what I understand (and I hope someone will correct/elaborate when necessary), you need to set one of the IA32_PERFEVTSELx MSRs with appropirate values (OS/USR mode, the desired bit mask [UnHalted instructions, etc...]. Then when one of the events happens (UnHalted instruction is executed) the cooresponding IA32_PMCx MSR will reflect the current count. It can also be set so that the APIC will generate an interrupt when the counter overflows. I'd assume the IA32_PMCx MSR must be manually read in order to query its counter state.
Website: https://joscor.com
Re: Query CPU Performance Data,...
I just tried some performance monitoring in BOCHS, QEMU, and VirtualBox-OSE and it seems that none of them properly support it. BOCHS doesn't support it at all, QEMU gives a valid version but supports no events (in CPUID.0x0A.EBX, or an > 0 count in EAX), and VirtualBox gives all valid results except for CPUID.0x0A.EBX being null (no supported counters). The counters all return 0 when read.
Website: https://joscor.com
Re: Query CPU Performance Data,...
Hi,
Cheers,
Brendan
If an emulator tried to support performance monitoring, then it'd need to do a series of checks for every instruction emulated, and it would probably make the emulator about 50 times slower. Performance monitoring is also CPU specific, which makes it a lot of work to implement, and it's something that's rarely used (e.g. only used by specialized profiling tools). Basically it's not something I'd expect any emulator will ever support.01000101 wrote:I just tried some performance monitoring in BOCHS, QEMU, and VirtualBox-OSE and it seems that none of them properly support it. BOCHS doesn't support it at all, QEMU gives a valid version but supports no events (in CPUID.0x0A.EBX, or an > 0 count in EAX), and VirtualBox gives all valid results except for CPUID.0x0A.EBX being null (no supported counters). The counters all return 0 when read.
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Re: Query CPU Performance Data,...
Hey, I'm trying! I expect (hope for) my version of bochs to have one CPU model that supports it. It'll be really slow, as you say -- but if I put in all that memory-fetch-time modeling that you want, that model will be really super slow anyway.
Re: Query CPU Performance Data,...
Hi,
does someone have some example code for me?
TIA
Regards
Kerem
does someone have some example code for me?
TIA
Regards
Kerem
Re: Query CPU Performance Data,...
stop looking for a free handout, and read the intel manuals. All the info about reading performance counters are there, you just need to look. Program the select MSR and read from the counter MSR, it's fairly simple.keremg wrote: does someone have some example code for me?
Website: https://joscor.com