€•7šŒsphinx.addnodes”Œdocument”“”)”}”(Œ rawsource”Œ”Œchildren”]”(Œ translations”Œ LanguagesNode”“”)”}”(hhh]”(hŒ pending_xref”“”)”}”(hhh]”Œdocutils.nodes”ŒText”“”ŒChinese (Simplified)”…””}”Œparent”hsbaŒ attributes”}”(Œids”]”Œclasses”]”Œnames”]”Œdupnames”]”Œbackrefs”]”Œ refdomain”Œstd”Œreftype”Œdoc”Œ reftarget”Œ-/translations/zh_CN/trace/tracepoint-analysis”Œmodname”NŒ classname”NŒ refexplicit”ˆuŒtagname”hhh ubh)”}”(hhh]”hŒChinese (Traditional)”…””}”hh2sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ-/translations/zh_TW/trace/tracepoint-analysis”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒItalian”…””}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ-/translations/it_IT/trace/tracepoint-analysis”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒJapanese”…””}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ-/translations/ja_JP/trace/tracepoint-analysis”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒKorean”…””}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ-/translations/ko_KR/trace/tracepoint-analysis”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒPortuguese (Brazilian)”…””}”hh‚sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ-/translations/pt_BR/trace/tracepoint-analysis”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒSpanish”…””}”hh–sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ-/translations/sp_SP/trace/tracepoint-analysis”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubeh}”(h]”h ]”h"]”h$]”h&]”Œcurrent_language”ŒEnglish”uh1h hhŒ _document”hŒsource”NŒline”NubhŒsection”“”)”}”(hhh]”(hŒtitle”“”)”}”(hŒ9Notes on Analysing Behaviour Using Events and Tracepoints”h]”hŒ9Notes on Analysing Behaviour Using Events and Tracepoints”…””}”(hh¼h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhh·h²hh³ŒG/var/lib/git/docbuild/linux/Documentation/trace/tracepoint-analysis.rst”h´KubhŒ field_list”“”)”}”(hhh]”hŒfield”“”)”}”(hhh]”(hŒ field_name”“”)”}”(hŒAuthor”h]”hŒAuthor”…””}”(hh×h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÕhhÒh³hÊh´KubhŒ field_body”“”)”}”(hŒEMel Gorman (PCL information heavily based on email from Ingo Molnar) ”h]”hŒ paragraph”“”)”}”(hŒDMel Gorman (PCL information heavily based on email from Ingo Molnar)”h]”hŒDMel Gorman (PCL information heavily based on email from Ingo Molnar)”…””}”(hhíh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´Khhçubah}”(h]”h ]”h"]”h$]”h&]”uh1håhhÒubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÐh³hÊh´KhhÍh²hubah}”(h]”h ]”h"]”h$]”h&]”uh1hËhh·h²hh³hÊh´Kubh¶)”}”(hhh]”(h»)”}”(hŒ1. Introduction”h]”hŒ1. Introduction”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj h²hh³hÊh´Kubhì)”}”(hŒ¬Tracepoints (see Documentation/trace/tracepoints.rst) can be used without creating custom kernel modules to register probe functions using the event tracing infrastructure.”h]”hŒ¬Tracepoints (see Documentation/trace/tracepoints.rst) can be used without creating custom kernel modules to register probe functions using the event tracing infrastructure.”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´K hj h²hubhì)”}”(hXaSimplistically, tracepoints represent important events that can be taken in conjunction with other tracepoints to build a "Big Picture" of what is going on within the system. There are a large number of methods for gathering and interpreting these events. Lacking any current Best Practises, this document describes some of the methods that can be used.”h]”hXeSimplistically, tracepoints represent important events that can be taken in conjunction with other tracepoints to build a “Big Picture†of what is going on within the system. There are a large number of methods for gathering and interpreting these events. Lacking any current Best Practises, this document describes some of the methods that can be used.”…””}”(hj,h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´K hj h²hubhì)”}”(hŒäThis document assumes that debugfs is mounted on /sys/kernel/debug and that the appropriate tracing options have been configured into the kernel. It is assumed that the PCL tool tools/perf has been installed and is in your path.”h]”hŒäThis document assumes that debugfs is mounted on /sys/kernel/debug and that the appropriate tracing options have been configured into the kernel. It is assumed that the PCL tool tools/perf has been installed and is in your path.”…””}”(hj:h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´Khj h²hubeh}”(h]”Œ introduction”ah ]”h"]”Œ1. introduction”ah$]”h&]”uh1hµhh·h²hh³hÊh´Kubh¶)”}”(hhh]”(h»)”}”(hŒ2. Listing Available Events”h]”hŒ2. Listing Available Events”…””}”(hjSh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjPh²hh³hÊh´Kubh¶)”}”(hhh]”(h»)”}”(hŒ2.1 Standard Utilities”h]”hŒ2.1 Standard Utilities”…””}”(hjdh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjah²hh³hÊh´Kubhì)”}”(hŒQAll possible events are visible from /sys/kernel/tracing/events. Simply calling::”h]”hŒPAll possible events are visible from /sys/kernel/tracing/events. Simply calling:”…””}”(hjrh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´Khjah²hubhŒ literal_block”“”)”}”(hŒ)$ find /sys/kernel/tracing/events -type d”h]”hŒ)$ find /sys/kernel/tracing/events -type d”…””}”hj‚sbah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1j€h³hÊh´K hjah²hubhì)”}”(hŒ>will give a fair indication of the number of events available.”h]”hŒ>will give a fair indication of the number of events available.”…””}”(hj’h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´K"hjah²hubeh}”(h]”Œstandard-utilities”ah ]”h"]”Œ2.1 standard utilities”ah$]”h&]”uh1hµhjPh²hh³hÊh´Kubh¶)”}”(hhh]”(h»)”}”(hŒ(2.2 PCL (Performance Counters for Linux)”h]”hŒ(2.2 PCL (Performance Counters for Linux)”…””}”(hj«h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj¨h²hh³hÊh´K%ubhì)”}”(hŒ§Discovery and enumeration of all counters and events, including tracepoints, are available with the perf tool. Getting a list of available events is a simple case of::”h]”hŒ¦Discovery and enumeration of all counters and events, including tracepoints, are available with the perf tool. Getting a list of available events is a simple case of:”…””}”(hj¹h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´K'hj¨h²hubj)”}”(hXu$ perf list 2>&1 | grep Tracepoint ext4:ext4_free_inode [Tracepoint event] ext4:ext4_request_inode [Tracepoint event] ext4:ext4_allocate_inode [Tracepoint event] ext4:ext4_write_begin [Tracepoint event] ext4:ext4_ordered_write_end [Tracepoint event] [ .... remaining output snipped .... ]”h]”hXu$ perf list 2>&1 | grep Tracepoint ext4:ext4_free_inode [Tracepoint event] ext4:ext4_request_inode [Tracepoint event] ext4:ext4_allocate_inode [Tracepoint event] ext4:ext4_write_begin [Tracepoint event] ext4:ext4_ordered_write_end [Tracepoint event] [ .... remaining output snipped .... ]”…””}”hjÇsbah}”(h]”h ]”h"]”h$]”h&]”jj‘uh1j€h³hÊh´K+hj¨h²hubeh}”(h]”Œ"pcl-performance-counters-for-linux”ah ]”h"]”Œ(2.2 pcl (performance counters for linux)”ah$]”h&]”uh1hµhjPh²hh³hÊh´K%ubeh}”(h]”Œlisting-available-events”ah ]”h"]”Œ2. listing available events”ah$]”h&]”uh1hµhh·h²hh³hÊh´Kubh¶)”}”(hhh]”(h»)”}”(hŒ3. Enabling Events”h]”hŒ3. Enabling Events”…””}”(hjèh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjåh²hh³hÊh´K5ubh¶)”}”(hhh]”(h»)”}”(hŒ3.1 System-Wide Event Enabling”h]”hŒ3.1 System-Wide Event Enabling”…””}”(hjùh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjöh²hh³hÊh´K8ubhì)”}”(hŒÃSee Documentation/trace/events.rst for a proper description on how events can be enabled system-wide. A short example of enabling all events related to page allocation would look something like::”h]”hŒÂSee Documentation/trace/events.rst for a proper description on how events can be enabled system-wide. A short example of enabling all events related to page allocation would look something like:”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´K:hjöh²hubj)”}”(hŒ\$ for i in `find /sys/kernel/tracing/events -name "enable" | grep mm_`; do echo 1 > $i; done”h]”hŒ\$ for i in `find /sys/kernel/tracing/events -name "enable" | grep mm_`; do echo 1 > $i; done”…””}”hjsbah}”(h]”h ]”h"]”h$]”h&]”jj‘uh1j€h³hÊh´K>hjöh²hubeh}”(h]”Œsystem-wide-event-enabling”ah ]”h"]”Œ3.1 system-wide event enabling”ah$]”h&]”uh1hµhjåh²hh³hÊh´K8ubh¶)”}”(hhh]”(h»)”}”(hŒ-3.2 System-Wide Event Enabling with SystemTap”h]”hŒ-3.2 System-Wide Event Enabling with SystemTap”…””}”(hj.h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj+h²hh³hÊh´KAubhì)”}”(hŒ¶In SystemTap, tracepoints are accessible using the kernel.trace() function call. The following is an example that reports every 5 seconds what processes were allocating the pages. ::”h]”hŒ³In SystemTap, tracepoints are accessible using the kernel.trace() function call. The following is an example that reports every 5 seconds what processes were allocating the pages.”…””}”(hj<h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´KChj+h²hubj)”}”(hXrglobal page_allocs probe kernel.trace("mm_page_alloc") { page_allocs[execname()]++ } function print_count() { printf ("%-25s %-s\n", "#Pages Allocated", "Process Name") foreach (proc in page_allocs-) printf("%-25d %s\n", page_allocs[proc], proc) printf ("\n") delete page_allocs } probe timer.s(5) { print_count() }”h]”hXrglobal page_allocs probe kernel.trace("mm_page_alloc") { page_allocs[execname()]++ } function print_count() { printf ("%-25s %-s\n", "#Pages Allocated", "Process Name") foreach (proc in page_allocs-) printf("%-25d %s\n", page_allocs[proc], proc) printf ("\n") delete page_allocs } probe timer.s(5) { print_count() }”…””}”hjJsbah}”(h]”h ]”h"]”h$]”h&]”jj‘uh1j€h³hÊh´KHhj+h²hubeh}”(h]”Œ)system-wide-event-enabling-with-systemtap”ah ]”h"]”Œ-3.2 system-wide event enabling with systemtap”ah$]”h&]”uh1hµhjåh²hh³hÊh´KAubh¶)”}”(hhh]”(h»)”}”(hŒ'3.3 System-Wide Event Enabling with PCL”h]”hŒ'3.3 System-Wide Event Enabling with PCL”…””}”(hjch²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj`h²hh³hÊh´K[ubhì)”}”(hŒrBy specifying the -a switch and analysing sleep, the system-wide events for a duration of time can be examined. ::”h]”hŒoBy specifying the -a switch and analysing sleep, the system-wide events for a duration of time can be examined.”…””}”(hjqh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´K]hj`h²hubj)”}”(hX:$ perf stat -a \ -e kmem:mm_page_alloc -e kmem:mm_page_free \ -e kmem:mm_page_free_batched \ sleep 10 Performance counter stats for 'sleep 10': 9630 kmem:mm_page_alloc 2143 kmem:mm_page_free 7424 kmem:mm_page_free_batched 10.002577764 seconds time elapsed”h]”hX:$ perf stat -a \ -e kmem:mm_page_alloc -e kmem:mm_page_free \ -e kmem:mm_page_free_batched \ sleep 10 Performance counter stats for 'sleep 10': 9630 kmem:mm_page_alloc 2143 kmem:mm_page_free 7424 kmem:mm_page_free_batched 10.002577764 seconds time elapsed”…””}”hjsbah}”(h]”h ]”h"]”h$]”h&]”jj‘uh1j€h³hÊh´Kahj`h²hubhì)”}”(hŒZSimilarly, one could execute a shell and exit it as desired to get a report at that point.”h]”hŒZSimilarly, one could execute a shell and exit it as desired to get a report at that point.”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´Kmhj`h²hubeh}”(h]”Œ#system-wide-event-enabling-with-pcl”ah ]”h"]”Œ'3.3 system-wide event enabling with pcl”ah$]”h&]”uh1hµhjåh²hh³hÊh´K[ubh¶)”}”(hhh]”(h»)”}”(hŒ3.4 Local Event Enabling”h]”hŒ3.4 Local Event Enabling”…””}”(hj¦h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj£h²hh³hÊh´Kqubhì)”}”(hŒiDocumentation/trace/ftrace.rst describes how to enable events on a per-thread basis using set_ftrace_pid.”h]”hŒiDocumentation/trace/ftrace.rst describes how to enable events on a per-thread basis using set_ftrace_pid.”…””}”(hj´h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´Kshj£h²hubeh}”(h]”Œlocal-event-enabling”ah ]”h"]”Œ3.4 local event enabling”ah$]”h&]”uh1hµhjåh²hh³hÊh´Kqubh¶)”}”(hhh]”(h»)”}”(hŒ#3.5 Local Event Enablement with PCL”h]”hŒ#3.5 Local Event Enablement with PCL”…””}”(hjÍh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjÊh²hh³hÊh´Kwubhì)”}”(hŒpEvents can be activated and tracked for the duration of a process on a local basis using PCL such as follows. ::”h]”hŒmEvents can be activated and tracked for the duration of a process on a local basis using PCL such as follows.”…””}”(hjÛh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´KyhjÊh²hubj)”}”(hXD$ perf stat -e kmem:mm_page_alloc -e kmem:mm_page_free \ -e kmem:mm_page_free_batched ./hackbench 10 Time: 0.909 Performance counter stats for './hackbench 10': 17803 kmem:mm_page_alloc 12398 kmem:mm_page_free 4827 kmem:mm_page_free_batched 0.973913387 seconds time elapsed”h]”hXD$ perf stat -e kmem:mm_page_alloc -e kmem:mm_page_free \ -e kmem:mm_page_free_batched ./hackbench 10 Time: 0.909 Performance counter stats for './hackbench 10': 17803 kmem:mm_page_alloc 12398 kmem:mm_page_free 4827 kmem:mm_page_free_batched 0.973913387 seconds time elapsed”…””}”hjésbah}”(h]”h ]”h"]”h$]”h&]”jj‘uh1j€h³hÊh´K}hjÊh²hubeh}”(h]”Œlocal-event-enablement-with-pcl”ah ]”h"]”Œ#3.5 local event enablement with pcl”ah$]”h&]”uh1hµhjåh²hh³hÊh´Kwubeh}”(h]”Œenabling-events”ah ]”h"]”Œ3. enabling events”ah$]”h&]”uh1hµhh·h²hh³hÊh´K5ubh¶)”}”(hhh]”(h»)”}”(hŒ4. Event Filtering”h]”hŒ4. Event Filtering”…””}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjh²hh³hÊh´KŠubhì)”}”(hŒ±Documentation/trace/ftrace.rst covers in-depth how to filter events in ftrace. Obviously using grep and awk of trace_pipe is an option as well as any script reading trace_pipe.”h]”hŒ±Documentation/trace/ftrace.rst covers in-depth how to filter events in ftrace. Obviously using grep and awk of trace_pipe is an option as well as any script reading trace_pipe.”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´KŒhjh²hubeh}”(h]”Œevent-filtering”ah ]”h"]”Œ4. event filtering”ah$]”h&]”uh1hµhh·h²hh³hÊh´KŠubh¶)”}”(hhh]”(h»)”}”(hŒ%5. Analysing Event Variances with PCL”h]”hŒ%5. Analysing Event Variances with PCL”…””}”(hj1h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj.h²hh³hÊh´K‘ubhì)”}”(hX)Any workload can exhibit variances between runs and it can be important to know what the standard deviation is. By and large, this is left to the performance analyst to do it by hand. In the event that the discrete event occurrences are useful to the performance analyst, then perf can be used. ::”h]”hX&Any workload can exhibit variances between runs and it can be important to know what the standard deviation is. By and large, this is left to the performance analyst to do it by hand. In the event that the discrete event occurrences are useful to the performance analyst, then perf can be used.”…””}”(hj?h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´K“hj.h²hubj)”}”(hXà$ perf stat --repeat 5 -e kmem:mm_page_alloc -e kmem:mm_page_free -e kmem:mm_page_free_batched ./hackbench 10 Time: 0.890 Time: 0.895 Time: 0.915 Time: 1.001 Time: 0.899 Performance counter stats for './hackbench 10' (5 runs): 16630 kmem:mm_page_alloc ( +- 3.542% ) 11486 kmem:mm_page_free ( +- 4.771% ) 4730 kmem:mm_page_free_batched ( +- 2.325% ) 0.982653002 seconds time elapsed ( +- 1.448% )”h]”hXà$ perf stat --repeat 5 -e kmem:mm_page_alloc -e kmem:mm_page_free -e kmem:mm_page_free_batched ./hackbench 10 Time: 0.890 Time: 0.895 Time: 0.915 Time: 1.001 Time: 0.899 Performance counter stats for './hackbench 10' (5 runs): 16630 kmem:mm_page_alloc ( +- 3.542% ) 11486 kmem:mm_page_free ( +- 4.771% ) 4730 kmem:mm_page_free_batched ( +- 2.325% ) 0.982653002 seconds time elapsed ( +- 1.448% )”…””}”hjMsbah}”(h]”h ]”h"]”h$]”h&]”jj‘uh1j€h³hÊh´K™hj.h²hubhì)”}”(hŒ”In the event that some higher-level event is required that depends on some aggregation of discrete events, then a script would need to be developed.”h]”hŒ”In the event that some higher-level event is required that depends on some aggregation of discrete events, then a script would need to be developed.”…””}”(hj[h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´K©hj.h²hubhì)”}”(hŒ~Using --repeat, it is also possible to view how events are fluctuating over time on a system-wide basis using -a and sleep. ::”h]”hŒ{Using --repeat, it is also possible to view how events are fluctuating over time on a system-wide basis using -a and sleep.”…””}”(hjih²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´K¬hj.h²hubj)”}”(hX³$ perf stat -e kmem:mm_page_alloc -e kmem:mm_page_free \ -e kmem:mm_page_free_batched \ -a --repeat 10 \ sleep 1 Performance counter stats for 'sleep 1' (10 runs): 1066 kmem:mm_page_alloc ( +- 26.148% ) 182 kmem:mm_page_free ( +- 5.464% ) 890 kmem:mm_page_free_batched ( +- 30.079% ) 1.002251757 seconds time elapsed ( +- 0.005% )”h]”hX³$ perf stat -e kmem:mm_page_alloc -e kmem:mm_page_free \ -e kmem:mm_page_free_batched \ -a --repeat 10 \ sleep 1 Performance counter stats for 'sleep 1' (10 runs): 1066 kmem:mm_page_alloc ( +- 26.148% ) 182 kmem:mm_page_free ( +- 5.464% ) 890 kmem:mm_page_free_batched ( +- 30.079% ) 1.002251757 seconds time elapsed ( +- 0.005% )”…””}”hjwsbah}”(h]”h ]”h"]”h$]”h&]”jj‘uh1j€h³hÊh´K°hj.h²hubeh}”(h]”Œ"analysing-event-variances-with-pcl”ah ]”h"]”Œ%5. analysing event variances with pcl”ah$]”h&]”uh1hµhh·h²hh³hÊh´K‘ubh¶)”}”(hhh]”(h»)”}”(hŒ,6. Higher-Level Analysis with Helper Scripts”h]”hŒ,6. Higher-Level Analysis with Helper Scripts”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjh²hh³hÊh´K½ubhì)”}”(hX+When events are enabled the events that are triggering can be read from /sys/kernel/tracing/trace_pipe in human-readable format although binary options exist as well. By post-processing the output, further information can be gathered on-line as appropriate. Examples of post-processing might include”h]”hX+When events are enabled the events that are triggering can be read from /sys/kernel/tracing/trace_pipe in human-readable format although binary options exist as well. By post-processing the output, further information can be gathered on-line as appropriate. Examples of post-processing might include”…””}”(hjžh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´K¿hjh²hubhŒ block_quote”“”)”}”(hŒ¶- Reading information from /proc for the PID that triggered the event - Deriving a higher-level event from a series of lower-level events. - Calculating latencies between two events ”h]”hŒ bullet_list”“”)”}”(hhh]”(hŒ list_item”“”)”}”(hŒCReading information from /proc for the PID that triggered the event”h]”hì)”}”(hj»h]”hŒCReading information from /proc for the PID that triggered the event”…””}”(hj½h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´KÄhj¹ubah}”(h]”h ]”h"]”h$]”h&]”uh1j·hj´ubj¸)”}”(hŒBDeriving a higher-level event from a series of lower-level events.”h]”hì)”}”(hjÒh]”hŒBDeriving a higher-level event from a series of lower-level events.”…””}”(hjÔh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´KÅhjÐubah}”(h]”h ]”h"]”h$]”h&]”uh1j·hj´ubj¸)”}”(hŒ)Calculating latencies between two events ”h]”hì)”}”(hŒ(Calculating latencies between two events”h]”hŒ(Calculating latencies between two events”…””}”(hjëh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´KÆhjçubah}”(h]”h ]”h"]”h$]”h&]”uh1j·hj´ubeh}”(h]”h ]”h"]”h$]”h&]”Œbullet”Œ-”uh1j²h³hÊh´KÄhj®ubah}”(h]”h ]”h"]”h$]”h&]”uh1j¬h³hÊh´KÄhjh²hubhì)”}”(hŒóDocumentation/trace/postprocess/trace-pagealloc-postprocess.pl is an example script that can read trace_pipe from STDIN or a copy of a trace. When used on-line, it can be interrupted once to generate a report without exiting and twice to exit.”h]”hŒóDocumentation/trace/postprocess/trace-pagealloc-postprocess.pl is an example script that can read trace_pipe from STDIN or a copy of a trace. When used on-line, it can be interrupted once to generate a report without exiting and twice to exit.”…””}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´KÈhjh²hubhì)”}”(hŒ`Simplistically, the script just reads STDIN and counts up events but it also can do more such as”h]”hŒ`Simplistically, the script just reads STDIN and counts up events but it also can do more such as”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´KÍhjh²hubj­)”}”(hX•- Derive high-level events from many low-level events. If a number of pages are freed to the main allocator from the per-CPU lists, it recognises that as one per-CPU drain even though there is no specific tracepoint for that event - It can aggregate based on PID or individual process number - In the event memory is getting externally fragmented, it reports on whether the fragmentation event was severe or moderate. - When receiving an event about a PID, it can record who the parent was so that if large numbers of events are coming from very short-lived processes, the parent process responsible for creating all the helpers can be identified ”h]”j³)”}”(hhh]”(j¸)”}”(hŒäDerive high-level events from many low-level events. If a number of pages are freed to the main allocator from the per-CPU lists, it recognises that as one per-CPU drain even though there is no specific tracepoint for that event”h]”hì)”}”(hŒäDerive high-level events from many low-level events. If a number of pages are freed to the main allocator from the per-CPU lists, it recognises that as one per-CPU drain even though there is no specific tracepoint for that event”h]”hŒäDerive high-level events from many low-level events. If a number of pages are freed to the main allocator from the per-CPU lists, it recognises that as one per-CPU drain even though there is no specific tracepoint for that event”…””}”(hj4h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´KÐhj0ubah}”(h]”h ]”h"]”h$]”h&]”uh1j·hj-ubj¸)”}”(hŒ:It can aggregate based on PID or individual process number”h]”hì)”}”(hjJh]”hŒ:It can aggregate based on PID or individual process number”…””}”(hjLh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´KÔhjHubah}”(h]”h ]”h"]”h$]”h&]”uh1j·hj-ubj¸)”}”(hŒ{In the event memory is getting externally fragmented, it reports on whether the fragmentation event was severe or moderate.”h]”hì)”}”(hŒ{In the event memory is getting externally fragmented, it reports on whether the fragmentation event was severe or moderate.”h]”hŒ{In the event memory is getting externally fragmented, it reports on whether the fragmentation event was severe or moderate.”…””}”(hjch²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´KÕhj_ubah}”(h]”h ]”h"]”h$]”h&]”uh1j·hj-ubj¸)”}”(hŒãWhen receiving an event about a PID, it can record who the parent was so that if large numbers of events are coming from very short-lived processes, the parent process responsible for creating all the helpers can be identified ”h]”hì)”}”(hŒâWhen receiving an event about a PID, it can record who the parent was so that if large numbers of events are coming from very short-lived processes, the parent process responsible for creating all the helpers can be identified”h]”hŒâWhen receiving an event about a PID, it can record who the parent was so that if large numbers of events are coming from very short-lived processes, the parent process responsible for creating all the helpers can be identified”…””}”(hj{h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´K×hjwubah}”(h]”h ]”h"]”h$]”h&]”uh1j·hj-ubeh}”(h]”h ]”h"]”h$]”h&]”jjuh1j²h³hÊh´KÐhj)ubah}”(h]”h ]”h"]”h$]”h&]”uh1j¬h³hÊh´KÐhjh²hubeh}”(h]”Œ)higher-level-analysis-with-helper-scripts”ah ]”h"]”Œ,6. higher-level analysis with helper scripts”ah$]”h&]”uh1hµhh·h²hh³hÊh´K½ubh¶)”}”(hhh]”(h»)”}”(hŒ 7. Lower-Level Analysis with PCL”h]”hŒ 7. Lower-Level Analysis with PCL”…””}”(hj¦h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj£h²hh³hÊh´KÝubhì)”}”(hŒßThere may also be a requirement to identify what functions within a program were generating events within the kernel. To begin this sort of analysis, the data must be recorded. At the time of writing, this required root: ::”h]”hŒÜThere may also be a requirement to identify what functions within a program were generating events within the kernel. To begin this sort of analysis, the data must be recorded. At the time of writing, this required root:”…””}”(hj´h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´Kßhj£h²hubj)”}”(hŒÕ$ perf record -c 1 \ -e kmem:mm_page_alloc -e kmem:mm_page_free \ -e kmem:mm_page_free_batched \ ./hackbench 10 Time: 0.894 [ perf record: Captured and wrote 0.733 MB perf.data (~32010 samples) ]”h]”hŒÕ$ perf record -c 1 \ -e kmem:mm_page_alloc -e kmem:mm_page_free \ -e kmem:mm_page_free_batched \ ./hackbench 10 Time: 0.894 [ perf record: Captured and wrote 0.733 MB perf.data (~32010 samples) ]”…””}”hjÂsbah}”(h]”h ]”h"]”h$]”h&]”jj‘uh1j€h³hÊh´Kähj£h²hubhì)”}”(hŒ´Note the use of '-c 1' to set the event period to sample. The default sample period is quite high to minimise overhead but the information collected can be very coarse as a result.”h]”hŒ¸Note the use of ‘-c 1’ to set the event period to sample. The default sample period is quite high to minimise overhead but the information collected can be very coarse as a result.”…””}”(hjÐh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´Këhj£h²hubhì)”}”(hŒYThis record outputted a file called perf.data which can be analysed using perf report. ::”h]”hŒVThis record outputted a file called perf.data which can be analysed using perf report.”…””}”(hjÞh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´Kïhj£h²hubj)”}”(hX`$ perf report # Samples: 30922 # # Overhead Command Shared Object # ........ ......... ................................ # 87.27% hackbench [vdso] 6.85% hackbench /lib/i686/cmov/libc-2.9.so 2.62% hackbench /lib/ld-2.9.so 1.52% perf [vdso] 1.22% hackbench ./hackbench 0.48% hackbench [kernel] 0.02% perf /lib/i686/cmov/libc-2.9.so 0.01% perf /usr/bin/perf 0.01% perf /lib/ld-2.9.so 0.00% hackbench /lib/i686/cmov/libpthread-2.9.so # # (For more details, try: perf report --sort comm,dso,symbol) #”h]”hX`$ perf report # Samples: 30922 # # Overhead Command Shared Object # ........ ......... ................................ # 87.27% hackbench [vdso] 6.85% hackbench /lib/i686/cmov/libc-2.9.so 2.62% hackbench /lib/ld-2.9.so 1.52% perf [vdso] 1.22% hackbench ./hackbench 0.48% hackbench [kernel] 0.02% perf /lib/i686/cmov/libc-2.9.so 0.01% perf /usr/bin/perf 0.01% perf /lib/ld-2.9.so 0.00% hackbench /lib/i686/cmov/libpthread-2.9.so # # (For more details, try: perf report --sort comm,dso,symbol) #”…””}”hjìsbah}”(h]”h ]”h"]”h$]”h&]”jj‘uh1j€h³hÊh´Kóhj£h²hubhì)”}”(hX2According to this, the vast majority of events triggered on events within the VDSO. With simple binaries, this will often be the case so let's take a slightly different example. In the course of writing this, it was noticed that X was generating an insane amount of page allocations so let's look at it: ::”h]”hX3According to this, the vast majority of events triggered on events within the VDSO. With simple binaries, this will often be the case so let’s take a slightly different example. In the course of writing this, it was noticed that X was generating an insane amount of page allocations so let’s look at it:”…””}”(hjúh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´Mhj£h²hubj)”}”(hŒš$ perf record -c 1 -f \ -e kmem:mm_page_alloc -e kmem:mm_page_free \ -e kmem:mm_page_free_batched \ -p `pidof X`”h]”hŒš$ perf record -c 1 -f \ -e kmem:mm_page_alloc -e kmem:mm_page_free \ -e kmem:mm_page_free_batched \ -p `pidof X`”…””}”hjsbah}”(h]”h ]”h"]”h$]”h&]”jj‘uh1j€h³hÊh´Mhj£h²hubhì)”}”(hŒ/This was interrupted after a few seconds and ::”h]”hŒ,This was interrupted after a few seconds and”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´Mhj£h²hubj)”}”(hX…$ perf report # Samples: 27666 # # Overhead Command Shared Object # ........ ....... ....................................... # 51.95% Xorg [vdso] 47.95% Xorg /opt/gfx-test/lib/libpixman-1.so.0.13.1 0.09% Xorg /lib/i686/cmov/libc-2.9.so 0.01% Xorg [kernel] # # (For more details, try: perf report --sort comm,dso,symbol) #”h]”hX…$ perf report # Samples: 27666 # # Overhead Command Shared Object # ........ ....... ....................................... # 51.95% Xorg [vdso] 47.95% Xorg /opt/gfx-test/lib/libpixman-1.so.0.13.1 0.09% Xorg /lib/i686/cmov/libc-2.9.so 0.01% Xorg [kernel] # # (For more details, try: perf report --sort comm,dso,symbol) #”…””}”hj$sbah}”(h]”h ]”h"]”h$]”h&]”jj‘uh1j€h³hÊh´Mhj£h²hubhì)”}”(hŒYSo, almost half of the events are occurring in a library. To get an idea which symbol: ::”h]”hŒVSo, almost half of the events are occurring in a library. To get an idea which symbol:”…””}”(hj2h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´M$hj£h²hubj)”}”(hX$ perf report --sort comm,dso,symbol # Samples: 27666 # # Overhead Command Shared Object Symbol # ........ ....... ....................................... ...... # 51.95% Xorg [vdso] [.] 0x000000ffffe424 47.93% Xorg /opt/gfx-test/lib/libpixman-1.so.0.13.1 [.] pixmanFillsse2 0.09% Xorg /lib/i686/cmov/libc-2.9.so [.] _int_malloc 0.01% Xorg /opt/gfx-test/lib/libpixman-1.so.0.13.1 [.] pixman_region32_copy_f 0.01% Xorg [kernel] [k] read_hpet 0.01% Xorg /opt/gfx-test/lib/libpixman-1.so.0.13.1 [.] get_fast_path 0.00% Xorg [kernel] [k] ftrace_trace_userstack”h]”hX$ perf report --sort comm,dso,symbol # Samples: 27666 # # Overhead Command Shared Object Symbol # ........ ....... ....................................... ...... # 51.95% Xorg [vdso] [.] 0x000000ffffe424 47.93% Xorg /opt/gfx-test/lib/libpixman-1.so.0.13.1 [.] pixmanFillsse2 0.09% Xorg /lib/i686/cmov/libc-2.9.so [.] _int_malloc 0.01% Xorg /opt/gfx-test/lib/libpixman-1.so.0.13.1 [.] pixman_region32_copy_f 0.01% Xorg [kernel] [k] read_hpet 0.01% Xorg /opt/gfx-test/lib/libpixman-1.so.0.13.1 [.] get_fast_path 0.00% Xorg [kernel] [k] ftrace_trace_userstack”…””}”hj@sbah}”(h]”h ]”h"]”h$]”h&]”jj‘uh1j€h³hÊh´M(hj£h²hubhì)”}”(hŒJTo see where within the function pixmanFillsse2 things are going wrong: ::”h]”hŒGTo see where within the function pixmanFillsse2 things are going wrong:”…””}”(hjNh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´M6hj£h²hubj)”}”(hX9$ perf annotate pixmanFillsse2 [ ... ] 0.00 : 34eeb: 0f 18 08 prefetcht0 (%eax) : } : : extern __inline void __attribute__((__gnu_inline__, __always_inline__, _ : _mm_store_si128 (__m128i *__P, __m128i __B) : { : *__P = __B; 12.40 : 34eee: 66 0f 7f 80 40 ff ff movdqa %xmm0,-0xc0(%eax) 0.00 : 34ef5: ff 12.40 : 34ef6: 66 0f 7f 80 50 ff ff movdqa %xmm0,-0xb0(%eax) 0.00 : 34efd: ff 12.39 : 34efe: 66 0f 7f 80 60 ff ff movdqa %xmm0,-0xa0(%eax) 0.00 : 34f05: ff 12.67 : 34f06: 66 0f 7f 80 70 ff ff movdqa %xmm0,-0x90(%eax) 0.00 : 34f0d: ff 12.58 : 34f0e: 66 0f 7f 40 80 movdqa %xmm0,-0x80(%eax) 12.31 : 34f13: 66 0f 7f 40 90 movdqa %xmm0,-0x70(%eax) 12.40 : 34f18: 66 0f 7f 40 a0 movdqa %xmm0,-0x60(%eax) 12.31 : 34f1d: 66 0f 7f 40 b0 movdqa %xmm0,-0x50(%eax)”h]”hX9$ perf annotate pixmanFillsse2 [ ... ] 0.00 : 34eeb: 0f 18 08 prefetcht0 (%eax) : } : : extern __inline void __attribute__((__gnu_inline__, __always_inline__, _ : _mm_store_si128 (__m128i *__P, __m128i __B) : { : *__P = __B; 12.40 : 34eee: 66 0f 7f 80 40 ff ff movdqa %xmm0,-0xc0(%eax) 0.00 : 34ef5: ff 12.40 : 34ef6: 66 0f 7f 80 50 ff ff movdqa %xmm0,-0xb0(%eax) 0.00 : 34efd: ff 12.39 : 34efe: 66 0f 7f 80 60 ff ff movdqa %xmm0,-0xa0(%eax) 0.00 : 34f05: ff 12.67 : 34f06: 66 0f 7f 80 70 ff ff movdqa %xmm0,-0x90(%eax) 0.00 : 34f0d: ff 12.58 : 34f0e: 66 0f 7f 40 80 movdqa %xmm0,-0x80(%eax) 12.31 : 34f13: 66 0f 7f 40 90 movdqa %xmm0,-0x70(%eax) 12.40 : 34f18: 66 0f 7f 40 a0 movdqa %xmm0,-0x60(%eax) 12.31 : 34f1d: 66 0f 7f 40 b0 movdqa %xmm0,-0x50(%eax)”…””}”hj\sbah}”(h]”h ]”h"]”h$]”h&]”jj‘uh1j€h³hÊh´M9hj£h²hubhì)”}”(hXAAt a glance, it looks like the time is being spent copying pixmaps to the card. Further investigation would be needed to determine why pixmaps are being copied around so much but a starting point would be to take an ancient build of libpixmap out of the library path where it was totally forgotten about from months ago!”h]”hXAAt a glance, it looks like the time is being spent copying pixmaps to the card. Further investigation would be needed to determine why pixmaps are being copied around so much but a starting point would be to take an ancient build of libpixmap out of the library path where it was totally forgotten about from months ago!”…””}”(hjjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÊh´MNhj£h²hubeh}”(h]”Œlower-level-analysis-with-pcl”ah ]”h"]”Œ 7. lower-level analysis with pcl”ah$]”h&]”uh1hµhh·h²hh³hÊh´KÝubeh}”(h]”Œ9notes-on-analysing-behaviour-using-events-and-tracepoints”ah ]”h"]”Œ9notes on analysing behaviour using events and tracepoints”ah$]”h&]”uh1hµhhh²hh³hÊh´Kubeh}”(h]”h ]”h"]”h$]”h&]”Œsource”hÊuh1hŒcurrent_source”NŒ current_line”NŒsettings”Œdocutils.frontend”ŒValues”“”)”}”(hºNŒ generator”NŒ datestamp”NŒ source_link”NŒ source_url”NŒ toc_backlinks”Œentry”Œfootnote_backlinks”KŒ sectnum_xform”KŒstrip_comments”NŒstrip_elements_with_classes”NŒ strip_classes”NŒ report_level”KŒ halt_level”KŒexit_status_level”KŒdebug”NŒwarning_stream”NŒ traceback”ˆŒinput_encoding”Œ utf-8-sig”Œinput_encoding_error_handler”Œstrict”Œoutput_encoding”Œutf-8”Œoutput_encoding_error_handler”j«Œerror_encoding”Œutf-8”Œerror_encoding_error_handler”Œbackslashreplace”Œ language_code”Œen”Œrecord_dependencies”NŒconfig”NŒ id_prefix”hŒauto_id_prefix”Œid”Œ dump_settings”NŒdump_internals”NŒdump_transforms”NŒdump_pseudo_xml”NŒexpose_internals”NŒstrict_visitor”NŒ_disable_config”NŒ_source”hÊŒ _destination”NŒ _config_files”]”Œ7/var/lib/git/docbuild/linux/Documentation/docutils.conf”aŒfile_insertion_enabled”ˆŒ raw_enabled”KŒline_length_limit”M'Œpep_references”NŒ pep_base_url”Œhttps://peps.python.org/”Œpep_file_url_template”Œpep-%04d”Œrfc_references”NŒ rfc_base_url”Œ&https://datatracker.ietf.org/doc/html/”Œ tab_width”KŒtrim_footnote_reference_space”‰Œsyntax_highlight”Œlong”Œ smart_quotes”ˆŒsmartquotes_locales”]”Œcharacter_level_inline_markup”‰Œdoctitle_xform”‰Œ docinfo_xform”KŒsectsubtitle_xform”‰Œ image_loading”Œlink”Œembed_stylesheet”‰Œcloak_email_addresses”ˆŒsection_self_link”‰Œenv”NubŒreporter”NŒindirect_targets”]”Œsubstitution_defs”}”Œsubstitution_names”}”Œrefnames”}”Œrefids”}”Œnameids”}”(j…j‚jMjJjâjßj¥j¢jÚj×jjj(j%j]jZj jjÇjÄjüjùj+j(jŠj‡j jj}jzuŒ nametypes”}”(j…‰jM‰jâ‰j¥‰jÚ‰j‰j(‰j]‰j ‰jljjü‰j+‰jЉj ‰j}‰uh}”(j‚h·jJj jßjPj¢jaj×j¨jjåj%jöjZj+jj`jÄj£jùjÊj(jj‡j.jjjzj£uŒ footnote_refs”}”Œ citation_refs”}”Œ autofootnotes”]”Œautofootnote_refs”]”Œsymbol_footnotes”]”Œsymbol_footnote_refs”]”Œ footnotes”]”Œ citations”]”Œautofootnote_start”KŒsymbol_footnote_start”KŒ id_counter”Œ collections”ŒCounter”“”}”…”R”Œparse_messages”]”(hŒsystem_message”“”)”}”(hhh]”hì)”}”(hŒfPossible title underline, too short for the title. Treating it as ordinary text because it's so short.”h]”hŒhPossible title underline, too short for the title. Treating it as ordinary text because it’s so short.”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëhjubah}”(h]”h ]”h"]”h$]”h&]”Œlevel”KŒtype”ŒINFO”Œline”MŒsource”hÊuh1j hj£h²hh³hÊh´Mubj)”}”(hhh]”hì)”}”(hŒfPossible title underline, too short for the title. Treating it as ordinary text because it's so short.”h]”hŒhPossible title underline, too short for the title. Treating it as ordinary text because it’s so short.”…””}”(hj.h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëhj+ubah}”(h]”h ]”h"]”h$]”h&]”Œlevel”KŒtype”j(Œline”M7Œsource”hÊuh1j hj£h²hh³hÊh´M7ubeŒtransform_messages”]”Œ transformer”NŒ include_log”]”Œ decoration”Nh²hub.