User Tools

Site Tools


realtime:documentation:howto:tools:hwlat

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
realtime:documentation:howto:tools:hwlat [2018/08/22 16:05]
ebugden [Configuring the kernel] Improve phrasing
realtime:documentation:howto:tools:hwlat [2018/08/24 09:48] (current)
ebugden [Ftrace - hwlat tracer] Remove ftrace highlight on kernel doc link
Line 1: Line 1:
 ====== Ftrace - hwlat tracer ====== ====== Ftrace - hwlat tracer ======
  
-hwlat is an Ftrace tracer designed to detect latencies caused by a system'​s firmware or hardware. The tracer was originally intended for [[realtime:​documentation:​howto:​debugging:​smi-latency:​start|detecting SMIs]], but it can detect other low level latencies as well. More details about this tracer can be found in the kernel documentation for Ftrace and in the kernel documentation for the hardware latency detector.+hwlat is an Ftrace tracer designed to detect latencies caused by a system'​s firmware or hardware. The tracer was originally intended for [[realtime:​documentation:​howto:​debugging:​smi-latency:​start|detecting SMIs]], but it can detect other low level latencies as well
 + 
 +This article is brief because it is dedicated to a specific Ftrace tracer. More complete information about how to use Ftrace can be found [[realtime:​documentation:​howto:​tools:​ftrace|here]]. More details about this tracer can be found in the kernel documentation for [[https://​www.kernel.org/​doc/​html/​latest/​trace/​ftrace.html#​hardware-latency-detector|Ftrace]] and in the kernel documentation for the [[https://​www.kernel.org/​doc/​html/​latest/​trace/​hwlat_detector.html|Hardware Latency Detector]].
  
 ---- ----
Line 7: Line 9:
 ===== Setup ===== ===== Setup =====
  
-==== Configuring ​the kernel ====+Before any Ftrace tracers can be used, the tracefs file system must be mounted.
  
 If the kernel is already configured correctly and the hwlat tracer is available, hwlat will be listed in the available_tracers file in tracefs (after mounting tracefs). Otherwise, the hwlat tracer can be included in the kernel by enabling the CONFIG_HWLAT_TRACER option. If the kernel is already configured correctly and the hwlat tracer is available, hwlat will be listed in the available_tracers file in tracefs (after mounting tracefs). Otherwise, the hwlat tracer can be included in the kernel by enabling the CONFIG_HWLAT_TRACER option.
- 
-==== Mounting tracefs ==== 
- 
-Before any Ftrace tracers can be used, the tracefs file system must be mounted. If the file system is already mounted, then the mount location can be displayed using the following command: 
- 
-<code bash> 
-$ mount | grep tracefs 
-</​code>​ 
- 
-The tracefs file system is usually mounted at /​sys/​kernel/​tracing,​ but this is not necessarily the case for all systems. If tracefs is not mounted and the previous command did not display anything, then the file system will need to be manually mounted with this command: 
- 
-<code bash> 
-$ mount -t tracefs nodev /​sys/​kernel/​tracing 
-</​code>​ 
  
 ===== Tracing ===== ===== Tracing =====
  
-If the tracer is available, hwlat can be activated manually ​via tracefs in the same way as any other Ftrace tracer. The '​[tracing]'​ before the following commands is to indicate that they are being run from the root of tracefs (the tracing folder). The '#'​ symbol is used to indicate that the commands must be run as root or with sudo. Here is an example of how to select the hwlat tracer: +If the tracer is available, hwlat can be used via tracefs in the same way as any other Ftrace tracer.
- +
-<​code>​ +
-[tracing]# echo hwlat > current_tracer +
-</​code>​ +
- +
-By default, tracing is already enabled when the system starts. So, if the user has not disabled tracing since booting they just need to select a tracer (other than "​nop"​) to start collecting data. Tracing can also be enabled by writing 1 to the tracing_on file or disabled by writing a 0 to the tracing_on file. The files current_tracer and tracing_on can be read to verify that the tracer was selected correctly and that tracing is enabled.+
  
 Before consulting the trace results for analysis, make sure that only one instance of hwlat is running. The program //top// can be used for this. If more than one instance is running, restart the system, and trace the latencies again with only one instance of hwlat. Before consulting the trace results for analysis, make sure that only one instance of hwlat is running. The program //top// can be used for this. If more than one instance is running, restart the system, and trace the latencies again with only one instance of hwlat.
Line 41: Line 23:
 </​WRAP>​ </​WRAP>​
  
-Because of a bug, an additional instance of hwlat is started every time 1 is written to tracing_on regardless of whether or not tracing with hwlat is already enabled. When tracing is disabled, only one instance of hwlat will be stopped and the only way to stop the additional instances is to restart the system. Running multiple instances of hwlat can quickly cripple a system so it is best to avoid this.    +Because of a bug, an additional instance of hwlat is started every time 1 is written to tracing_on regardless of whether or not tracing with hwlat is already enabled. When tracing is disabled, only one instance of hwlat will be stopped and the only way to stop the additional instances is to restart the system. Running multiple instances of hwlat can quickly cripple a system so it is best to avoid this.
  
-===== Results ===== +<WRAP center round todo 60%
- +Remove the bug warning when Steven'​s fix is merged ​into mainline 
-After the situation that was to be traced has occurred, tracing can be disabled, and the trace results can be viewed in the trace file: +</WRAP
- +   ​
-<code+
-[tracing]# cat trace +
-</​code>​ +
- +
-If another trace is to be taken, the previous results can be cleared by writing ​into the trace file: +
- +
-<code+
-[tracing]# echo > trace +
-</​code> ​+
  
 ===== Analysis ===== ===== Analysis =====
realtime/documentation/howto/tools/hwlat.1534953959.txt.gz · Last modified: 2018/08/22 16:05 by ebugden