summaryrefslogtreecommitdiffstats
path: root/doc/SystemTap_Beginners_Guide
diff options
context:
space:
mode:
authorddomingo <ddomingo@redhat.com>2008-10-13 09:36:52 +1000
committerddomingo <ddomingo@redhat.com>2008-10-13 09:36:52 +1000
commit30eb88b11b2a1438a400f0c2b1118d600010df27 (patch)
tree53bbae5deeb11a010b0d1f99f9de56559401ae5b /doc/SystemTap_Beginners_Guide
parente2607b19ce56830d64affed6a8ab169697bf2ccf (diff)
downloadsystemtap-steved-30eb88b11b2a1438a400f0c2b1118d600010df27.tar.gz
systemtap-steved-30eb88b11b2a1438a400f0c2b1118d600010df27.tar.xz
systemtap-steved-30eb88b11b2a1438a400f0c2b1118d600010df27.zip
added Useful_Scripts-kernelprofiling.xml
Diffstat (limited to 'doc/SystemTap_Beginners_Guide')
-rw-r--r--doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-functioncalls.xml2
-rw-r--r--doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-kernelprofiling.xml111
-rw-r--r--doc/SystemTap_Beginners_Guide/en-US/Useful_SystemTap_Scripts.xml1
3 files changed, 113 insertions, 1 deletions
diff --git a/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-functioncalls.xml b/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-functioncalls.xml
index 76a2fad9..4ebfa6fa 100644
--- a/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-functioncalls.xml
+++ b/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-functioncalls.xml
@@ -22,7 +22,7 @@ no script in examples
<title>countcalls.stp</title>
<para>
<programlisting>
-probe kernel.function(@1) { # probe every function in any C file under mm/
+probe kernel.function(@1) { # probe function passed as argument from stdin
called[probefunc()] &lt;&lt;&lt; 1 # add a count efficiently
}
global called
diff --git a/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-kernelprofiling.xml b/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-kernelprofiling.xml
new file mode 100644
index 00000000..0fd172dd
--- /dev/null
+++ b/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-kernelprofiling.xml
@@ -0,0 +1,111 @@
+<?xml version='1.0'?>
+<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+]>
+
+
+ <section id="kernelprofsect">
+ <title>Kernel Profiling</title>
+
+
+<remark>
+ WAR STORY: Kernel Profiling http://sourceware.org/systemtap/wiki/WSKernelProfile?highlight=((WarStories))
+</remark>
+
+<remark>
+ http://sourceware.org/systemtap/examples/process/pf2.stp
+</remark>
+
+
+<para>In <xref linkend="countcallssect"/>, you can revise the wildcards used in the probe to target <emphasis>all</emphasis> kernel functions. This can be useful if you are interested in indentifying what the kernel is performing over a specific time period.</para>
+
+<para>However, doing so can cause considerable stress on the machine. In addition, this does not provide any indication of whether a specific function is being called too often during small time increments.</para>
+
+<para>This section describes how to profile the kernel properly. <xref linkend="kernelprof"/> does this by providing a list of the top ten kernel functions called within a specific time period, and how many times each function was called during that time.</para>
+
+
+<formalpara id="kernelprof">
+ <title>kernelprof.stp</title>
+<para>
+<programlisting>
+#! /usr/bin/env stap
+
+global profile, pcount
+probe timer.profile {
+pcount &lt;&lt;&lt; 1
+ fn = probefunc ()
+ if (fn != "") profile[fn] &lt;&lt;&lt; 1
+}
+probe timer.ms(5000) {
+ printf ("\n--- %d samples recorded:\n", @count(pcount))
+ foreach (f in profile- limit 10) {
+ printf ("%-30s\t%6d\n", f, @count(profile[f]))
+ }
+ delete profile
+ delete pcount
+}
+
+</programlisting>
+</para>
+</formalpara>
+
+<para><xref linkend="kernelprof"/> records and outputs kernel functions called every 5 seconds. You can change this setting by editing <command>probe timer.ms(5000)</command> accordingly. <xref linkend="kernelprofoutput"/> contains an excerpt of the output over a 20-second period:</para>
+
+<example id="kernelprofoutput">
+ <title><xref linkend="kernelprof"/> Sample Output</title>
+<screen>
+[...]
+--- 10002 samples recorded:
+sys_recvfrom 1
+memmove 1
+__copy_from_user_ll 17
+__copy_to_user_ll 15
+mwait_idle 5868
+link_path_walk 1
+kfree 1
+fget_light 1
+audit_syscall_exit 1
+__d_lookup 1
+
+--- 10002 samples recorded:
+sysfs_read_file 1
+free_poll_entry 1
+syscall_exit_work 1
+profile_hit 1
+do_page_fault 2
+_read_lock 3
+kmap_atomic 4
+strncpy_from_user 1
+find_vma_prepare 1
+__copy_from_user_ll 12
+
+--- 10000 samples recorded:
+system_call 4
+unix_stream_sendmsg 1
+__d_path 1
+do_page_fault 2
+kmap_atomic 1
+find_vma 1
+__copy_to_user_ll 16
+__copy_from_user_ll 10
+mwait_idle 5759
+memcpy_fromiovec 1
+
+--- 10004 samples recorded:
+syscall_exit 1
+__d_path 1
+fput 2
+do_page_fault 4
+strncpy_from_user 1
+may_open 1
+ide_outb 1
+ide_outsw 1
+__copy_to_user_ll 11
+__copy_from_user_ll 14
+[...]
+</screen>
+</example>
+
+<para><xref linkend="kernelprof"/> allows you to identify interesting kernel-specific performance facts about the system, such as kernel-intensive workloads and idle times (in this case, <command>mwait_idle</command>. Note that <xref linkend="kernelprof"/> does not count user-space functions, although it counts all kernel functions as part of the sample (even if the script cannot identify from which specific kernel function a call originated.</para>
+
+ </section>
+
diff --git a/doc/SystemTap_Beginners_Guide/en-US/Useful_SystemTap_Scripts.xml b/doc/SystemTap_Beginners_Guide/en-US/Useful_SystemTap_Scripts.xml
index fb2dba54..03cb6b40 100644
--- a/doc/SystemTap_Beginners_Guide/en-US/Useful_SystemTap_Scripts.xml
+++ b/doc/SystemTap_Beginners_Guide/en-US/Useful_SystemTap_Scripts.xml
@@ -29,6 +29,7 @@
<xi:include href="Useful_Scripts-inodewatch.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="Useful_Scripts-inodewatch2.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="Useful_Scripts-functioncalls.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="Useful_Scripts-kernelprofiling.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="Useful_Scripts-futexes.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<!-- <xi:include href="Useful_Scripts-Network.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="Useful_Scripts-Signals.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />