Linux Foundation Wiki

project collaboration site

User Tools

Site Tools


realtime:documentation:howto:tools:perf-smi-cost

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
realtime:documentation:howto:tools:perf-smi-cost [2018/07/13 10:50]
ebugden Move perf SMI cost tool description to tools
realtime:documentation:howto:tools:perf-smi-cost [2018/07/16 11:54] (current)
ebugden Remove inaccurate setup section
Line 1: Line 1:
 ====== Perf stat - SMI cost ====== ====== Perf stat - SMI cost ======
  
-Perf's stat tool has an option that can measure the cost of SMIs (--smi-cost) if the necessary MSRs exist on the CPU. This option calculates the percentage of cycles spent handling SMIs. If the --no-metric-only option is also used, the tool can be used to determine the average number of cycles taken to handle an SMI during the measurement period. These Perf options are available as of the 4.13 linux kernel and will only work on Intel x86 processors from after around 2008 (as of the Nehalem microarchitecture).+Perf's stat tool has an option that can measure the cost of [[realtime:​documentation:​howto:​debugging:​smi-latency:​start|SMI]]s ​(--smi-cost) if the necessary MSRs exist on the CPU. This option calculates the percentage of cycles spent handling SMIs. If the --no-metric-only option is also used, the tool can be used to determine the average number of cycles taken to handle an SMI during the measurement period. These Perf options are available as of the 4.13 linux kernel and will only work on Intel x86 processors from after around 2008 (as of the Nehalem microarchitecture).
  
 ===== Installation ===== ===== Installation =====
Line 10: Line 10:
 Add instructions (or link to instructions) for building perf from source? Add instructions (or link to instructions) for building perf from source?
 </​WRAP>​ </​WRAP>​
- 
- 
-===== Setup ===== 
- 
-Because of how the average SMI duration is calculated, it is important to make sure that the CPUs never go idle while Perf is taking measurements,​ otherwise the results will be invalid. Before starting the measurements,​ the tool configures the core counters in the CPUs to stop counting cycles when an SMI is being handled. At the end of the test, the number of cycles spent handling SMIs is determined by calculating the difference between the /msr/aperf/ register (which never stops counting cycles) and the number of unhalted core cycles provided by the core counters (which stop counting during SMIs). However, a CPU's core counter also stop counting if the CPU goes idle. So, if CPUs are allowed to go idle, the calculated number of cycles spent handling SMIs will be larger than what it was in reality because it will include the time during which the CPUs were idle. 
- 
-That being said, even if the CPUs never go idle and never have to handle an SMI (which means, in theory, that the total cycles and the unhalted cycles should be the same), it is alright if the value of /msr/aperf/ is a few thousand cycles higher than the count of unhalted core cycles. This is because the values of these counters cannot be updated atomically, so it is normal if the values are a little different. 
- 
-Some simple ways of keeping the CPUs busy are described [[realtime:​documentation:​howto:​debugging:​no-cpu-idle|here]]. 
  
 ===== Test ===== ===== Test =====
Line 57: Line 48:
  
 <WRAP center round todo 60%> <WRAP center round todo 60%>
-Give an example of results and explain how to read them because the perf documentation is so confusing?+Give an example of results and explain how to read them because the perf documentation is confusing?
 </​WRAP>​ </​WRAP>​
  
realtime/documentation/howto/tools/perf-smi-cost.1531479059.txt.gz ยท Last modified: 2018/07/13 10:50 by ebugden