Find out the C-state of a Processor

Find out the C-state of a Processor

Is there a way in Linux to know exactly which state a core or a processor is residing in ?? I saw some pointers to Mointor/MWAIT Instructions.

Is there some documentation on these instructions related to power management particularly.

May be someone can point to C code where these instructions are used

4 posts / novo 0
Último post
Para obter mais informações sobre otimizações de compiladores, consulte Aviso sobre otimizações.

Hello Aajizattari,

I don't know whether linux provides the mechanism to notify the application when the processor enters an actualcore C state. If it exists, please let me know and I also have interests on it.However, you should be able toaccesshardware counter MSRs to get C state residency information.

Please refer to

Intel 64 and IA-32 Architectures Software Developers Manual,page 96 on theMSR_PKG_C3_RESIDENCY for Nehelam processors.

You should be able to utilize the msr driver embedded in linux to read theMSRs if you would like to include the code into your applicaiton. Please refe to the msr-tools published here.

Also keep in mind. The MSR address might differ from processors to processors. Please refer to the manual carefully.

Another better solution for you is, if you only need to getthe C state residency data, please utilize Intel tools like PowerTop, Vtune etc. in linux. These tools already can provide the C/P state residency information for many Intel processors.

Hope it helps.


Thanks for the reply.I can figure out the residency now. Though, it is not equivalent to what state I am in right now, still it helps a lot.However, I am much confused about how to use Monitor/WAIT Instructions. I have tried to read the relevant manuals but to no avail, so far.I am getting illegal instuction error.I can't figure out what is meant by privilege level 0 ... and how to change that.Then I am not sure what address to use with Monitor Instruction. what addresses correspond to Write-Back Cache ?? etc. etc.Can someone hint at a piece of code in C or C++ that works ??

Hi,to monitor C state residencies you can use the suggested by Sushuutilities for Linux. On Windows you can use the standard Windows perfmon to monitor C1, C2 and C3 state residencies. I can also point you to the Intel Performance Counter Monitor (V2.0) that can monitor the core C0/C3/C6/C7 and internal CPU package C2/C3/C6/C7 residencies both on Linux and Windows.Regarding MWAIT & MONITOR instructions:Those instructions are usually priviledged: in almost all environments only the operating system kernel (level 0) is allowed to execute them. In user-level applications (level 3) it generates illegal instruction error. You can have a look how Linux kernel uses MWAIT instruction in its CPU idle loop implementation.--Roman

Deixar um comentário

Faça login para adicionar um comentário. Não é membro? Inscreva-se hoje mesmo!