Perf Wiki https://perf.wiki.kernel.org/index.php/Main_Page MediaWiki 1.19.24 first-letter Media Special Talk User User talk Perf Wiki Perf Wiki talk File File talk MediaWiki MediaWiki talk Template Template talk Help Help talk Category Category talk Main Page 0 1 rkkykuoy04avy7olnuh67m2i8rq0nja 4300 2024-01-23T17:33:47Z Ian Rogers 42500 /* perf: Linux profiling with performance counters */ add Google summer of code section == <tt>perf:</tt> Linux profiling with performance counters == ''...More than just counters...'' === Introduction === This is the wiki page for the Linux <tt>perf</tt> command, also called perf_events. <tt>perf</tt> is powerful: it can instrument CPU performance counters, tracepoints, kprobes, and uprobes (dynamic tracing). It is capable of lightweight profiling. It is also included in the Linux kernel, under tools/perf, and is frequently updated and enhanced. <tt>perf</tt> began as a tool for using the performance counters subsystem in Linux, and has had various enhancements to add tracing capabilities. Performance counters are CPU hardware registers that count hardware events such as instructions executed, cache-misses suffered, or branches mispredicted. They form a basis for profiling applications to trace dynamic control flow and identify hotspots. <tt>perf</tt> provides rich generalized abstractions over hardware specific capabilities. Among others, it provides per task, per CPU and per-workload counters, sampling on top of these and source code event annotation. Tracepoints are instrumentation points placed at logical locations in code, such as for system calls, TCP/IP events, file system operations, etc. These have negligible overhead when not in use, and can be enabled by the <tt>perf</tt> command to collect information including timestamps and stack traces. <tt>perf</tt> can also dynamically create tracepoints using the kprobes and uprobes frameworks, for kernel and userspace dynamic tracing. The possibilities with these are endless. The userspace <tt>perf</tt> command present a simple to use interface with commands like: * <tt>[[Tutorial#Counting_with_perf_stat| perf stat</tt>]]: obtain event counts * <tt>[[Tutorial#Sampling_with_perf_record | perf record</tt>]]: record events for later reporting * <tt>[[Tutorial#Sample_analysis_with_perf_report | perf report</tt>]]: break down events by process, function, etc. * <tt>[[Tutorial#Source_level_analysis_with_perf_annotate | perf annotate</tt>]]: annotate assembly or source code with event counts * <tt>[[Tutorial#Live_analysis_with_perf_top | perf top</tt>]]: see live event count * <tt>[[Tutorial#Benchmarking_with_perf_bench | perf bench</tt>]]: run different kernel microbenchmarks To learn more, see the examples in the [[Tutorial]] or how to do a [[Top-Down Analysis]]. To ask questions, report bugs/issues mail the [https://lore.kernel.org/linux-perf-users/ mailing list] or use [https://bugzilla.kernel.org/buglist.cgi?bug_status=__open__&order=changeddate%20DESC%2Cpriority%2Cbug_severity&product=Tracing%2FProfiling&query_format=advanced bugzilla]. === Wiki Contents === * [[Tutorial]] * [[Top-Down Analysis]] * [[Todo]] * [[HardwareReference]] * [[perf_events kernel ABI]] * [[perf tools support for Intel&reg; Processor Trace]] * [[Useful Links]]: How perf tools work, examples of usage to solve real problems, observability articles, hardware manuals * [[Glossary]] * [[Latest Manual Pages]] * [[Development]] === Google Summer of Code === As part of the [https://www.linuxfoundation.org/ Linux Foundation] the perf tool has participated in the [https://summerofcode.withgoogle.com/ Google Summer-of-Code] since 2021. [https://wiki.linuxfoundation.org/gsoc/2024-gsoc-perf Check out the 2024 process].