public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* Add A Sample To Exapmle
@ 2016-11-07  2:26 Bingwu Yang
  2016-11-07 13:46 ` Frank Ch. Eigler
  0 siblings, 1 reply; 2+ messages in thread
From: Bingwu Yang @ 2016-11-07  2:26 UTC (permalink / raw)
  To: systemtap

[-- Attachment #1: Type: text/plain, Size: 137 bytes --]

Hello.
I add a sample systemtap script to source tree. Wish it can be useful:)

Can anybody help me to review this patch?

Many Thanks:)

[-- Attachment #2: tcp_retransmission.patch --]
[-- Type: application/octet-stream, Size: 12943 bytes --]

diff --git a/testsuite/systemtap.examples/index.html b/testsuite/systemtap.examples/index.html
index d9a7d47..5952356 100644
--- a/testsuite/systemtap.examples/index.html
+++ b/testsuite/systemtap.examples/index.html
@@ -60,7 +60,7 @@
 <li><a href="#virtualization/kvm_service_time.stp">virtualization/kvm_service_time.stp - Time Statistics on KVM Exit Reasons</a></li>
 </ul>
 
-<h2>All 158 Examples</h2>
+<h2>All 159 Examples</h2>
 <ul>
 <li><a name="general/alias_suffixes.stp"></a><a href="#general/alias_suffixes.stp">&para;</a> <a href="general/alias_suffixes.stp">general/alias_suffixes.stp</a> - Count I/O Syscalls using Alias Suffixes<br>
 keywords: <a href="keyword-index.html#IO">IO</a> <a href="keyword-index.html#STATISTICS">STATISTICS</a> <br>
@@ -327,6 +327,9 @@ keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-inde
 </li><li><a name="network/tcp_init_cwnd.stp"></a><a href="#network/tcp_init_cwnd.stp">&para;</a> <a href="network/tcp_init_cwnd.stp">network/tcp_init_cwnd.stp</a> - Increase Initial TCP Congestion Window to 10<br>
 keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-index.html#TCP">TCP</a> <a href="keyword-index.html#SOCKET">SOCKET</a> <a href="keyword-index.html#GURU">GURU</a> <br>
 <p>Run the tcp_init_cwnd.stp script in the background to override a kernel&#39;s default tcp cwnd value to 10, which has been found to improve latency for web server type workloads.  The script prints a count of cwnd value changes when it is stopped.</p><p><font size="-2"><pre># stap -g tcp_init_cwnd.stp -T 1</pre></font></p>
+</li><li><a name="network/tcp_retransmission.stp"></a><a href="#network/tcp_retransmission.stp">&para;</a> <a href="network/tcp_retransmission.stp">network/tcp_retransmission.stp</a> - print tcp retransmission packet<br>
+keywords: <a href="keyword-index.html#TCP">TCP</a> <a href="keyword-index.html#RETRANSMISSION">RETRANSMISSION</a> <br>
+<p>The tcp_retransmission.stp prints out a line for each tcp retransmission packet</p><p><font size="-2"><pre># stap tcp_retransmission.stp -T 1</pre></font></p>
 </li><li><a name="network/tcp_trace.stp"></a><a href="#network/tcp_trace.stp">&para;</a> <a href="network/tcp_trace.stp">network/tcp_trace.stp</a> - TCP Connection Tracing Utility<br>
 keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-index.html#TRACE">TRACE</a> <br>
 <p>This scripts traces a given TCP connection based on the filter parameters given by the user. The indexing is done by the 4 tuples local address, remote address, local port, remote port.</p><p><i><a href="network/tcp_trace.txt">sample usage in network/tcp_trace.txt</i></font></p>
diff --git a/testsuite/systemtap.examples/index.txt b/testsuite/systemtap.examples/index.txt
index 7c98de9..29a996d 100644
--- a/testsuite/systemtap.examples/index.txt
+++ b/testsuite/systemtap.examples/index.txt
@@ -974,6 +974,15 @@ keywords: network tcp socket guru
   # stap -g tcp_init_cwnd.stp -T 1
 
 
+network/tcp_retransmission.stp - print tcp retransmission packet
+keywords: tcp retransmission
+
+  The tcp_retransmission.stp prints out a line for each tcp
+  retransmission packet
+
+  # stap tcp_retransmission.stp -T 1
+
+
 network/tcp_trace.stp - TCP Connection Tracing Utility
 keywords: network trace
 
diff --git a/testsuite/systemtap.examples/keyword-index.html b/testsuite/systemtap.examples/keyword-index.html
index 29eb7ef..0251c94 100644
--- a/testsuite/systemtap.examples/keyword-index.html
+++ b/testsuite/systemtap.examples/keyword-index.html
@@ -39,7 +39,7 @@
          	</ul>
 
 <p><em>For systemtap version 3.1.</em></p><h2>Examples by Keyword</h2>
-<p><tt><a href="#_BEST">_BEST(18)</a> <a href="#BACKTRACE">BACKTRACE(8)</a> <a href="#CALLGRAPH">CALLGRAPH(3)</a> <a href="#DIAGRAM">DIAGRAM(1)</a> <a href="#DISK">DISK(5)</a> <a href="#FILE">FILE(2)</a> <a href="#FILESYSTEM">FILESYSTEM(4)</a> <a href="#FORMAT">FORMAT(2)</a> <a href="#FUNCTION">FUNCTION(4)</a> <a href="#FUTEX">FUTEX(2)</a> <a href="#GURU">GURU(17)</a> <a href="#INTERRUPT">INTERRUPT(3)</a> <a href="#IO">IO(29)</a> <a href="#JSON">JSON(2)</a> <a href="#KVM">KVM(3)</a> <a href="#LIMITS">LIMITS(2)</a> <a href="#LOCKING">LOCKING(6)</a> <a href="#MEMORY">MEMORY(14)</a> <a href="#MONITORING">MONITORING(7)</a> <a href="#NANOSLEEP">NANOSLEEP(1)</a> <a href="#NETWORK">NETWORK(21)</a> <a href="#NFS">NFS(4)</a> <a href="#NUMA">NUMA(1)</a> <a href="#PACKETS">PACKETS(1)</a> <a href="#PROCESS">PROCESS(23)</a> <a href="#PROFILING">PROFILING(20)</a> <a href="#QEMU">QEMU(2)</a> <a href="#REGEX">REGEX(1)</a> <a href="#SCHEDULER">SCHEDULER(8)</a> <a href="#SCSI">SCSI(1)</a> <a href="#SECURITY">SECURITY(11)</a> <a href="#SIGNALS">SIGNALS(5)</a> <a href="#SIMPLE">SIMPLE(10)</a> <a href="#SOCKET">SOCKET(7)</a> <a href="#SPECULATION">SPECULATION(1)</a> <a href="#STAPGAMES">STAPGAMES(5)</a> <a href="#STATISTICS">STATISTICS(9)</a> <a href="#SYSCALL">SYSCALL(12)</a> <a href="#TCP">TCP(3)</a> <a href="#THREAD">THREAD(2)</a> <a href="#TIME">TIME(3)</a> <a href="#TRACE">TRACE(6)</a> <a href="#TRACEPOINT">TRACEPOINT(4)</a> <a href="#TRAFFIC">TRAFFIC(8)</a> <a href="#TTY">TTY(1)</a> <a href="#VIRTUALIZATION">VIRTUALIZATION(3)</a> <a href="#WATCHDOG">WATCHDOG(1)</a> <a href="#WATCHPOINT">WATCHPOINT(2)</a> </tt></p>
+<p><tt><a href="#_BEST">_BEST(18)</a> <a href="#BACKTRACE">BACKTRACE(8)</a> <a href="#CALLGRAPH">CALLGRAPH(3)</a> <a href="#DIAGRAM">DIAGRAM(1)</a> <a href="#DISK">DISK(5)</a> <a href="#FILE">FILE(2)</a> <a href="#FILESYSTEM">FILESYSTEM(4)</a> <a href="#FORMAT">FORMAT(2)</a> <a href="#FUNCTION">FUNCTION(4)</a> <a href="#FUTEX">FUTEX(2)</a> <a href="#GURU">GURU(17)</a> <a href="#INTERRUPT">INTERRUPT(3)</a> <a href="#IO">IO(29)</a> <a href="#JSON">JSON(2)</a> <a href="#KVM">KVM(3)</a> <a href="#LIMITS">LIMITS(2)</a> <a href="#LOCKING">LOCKING(6)</a> <a href="#MEMORY">MEMORY(14)</a> <a href="#MONITORING">MONITORING(7)</a> <a href="#NANOSLEEP">NANOSLEEP(1)</a> <a href="#NETWORK">NETWORK(21)</a> <a href="#NFS">NFS(4)</a> <a href="#NUMA">NUMA(1)</a> <a href="#PACKETS">PACKETS(1)</a> <a href="#PROCESS">PROCESS(23)</a> <a href="#PROFILING">PROFILING(20)</a> <a href="#QEMU">QEMU(2)</a> <a href="#REGEX">REGEX(1)</a> <a href="#RETRANSMISSION">RETRANSMISSION(1)</a> <a href="#SCHEDULER">SCHEDULER(8)</a> <a href="#SCSI">SCSI(1)</a> <a href="#SECURITY">SECURITY(11)</a> <a href="#SIGNALS">SIGNALS(5)</a> <a href="#SIMPLE">SIMPLE(10)</a> <a href="#SOCKET">SOCKET(7)</a> <a href="#SPECULATION">SPECULATION(1)</a> <a href="#STAPGAMES">STAPGAMES(5)</a> <a href="#STATISTICS">STATISTICS(9)</a> <a href="#SYSCALL">SYSCALL(12)</a> <a href="#TCP">TCP(4)</a> <a href="#THREAD">THREAD(2)</a> <a href="#TIME">TIME(3)</a> <a href="#TRACE">TRACE(6)</a> <a href="#TRACEPOINT">TRACEPOINT(4)</a> <a href="#TRAFFIC">TRAFFIC(8)</a> <a href="#TTY">TTY(1)</a> <a href="#VIRTUALIZATION">VIRTUALIZATION(3)</a> <a href="#WATCHDOG">WATCHDOG(1)</a> <a href="#WATCHPOINT">WATCHPOINT(2)</a> </tt></p>
 <h3><a name="_BEST"><a href="#_BEST">&para;</a> _BEST</a></h3>
 <ul>
 <li><a href="general/eventcount.stp">general/eventcount.stp</a> - Count Specified Events<br>
@@ -746,6 +746,12 @@ keywords: <a href="keyword-index.html#VIRTUALIZATION">VIRTUALIZATION</a> <a href
 keywords: <a href="keyword-index.html#REGEX">REGEX</a> <br>
 <p>Uses the regex functionality to detect opened files whose names match a pattern given on the command line. If no command line parameter is given, demonstrate by filtering for files that end with an extension showing them to be an archive.</p><p><font size="-2"><pre># stap regex.stp -T 1</pre></font></p>
 </li></ul>
+<h3><a name="RETRANSMISSION"><a href="#RETRANSMISSION">&para;</a> RETRANSMISSION</a></h3>
+<ul>
+<li><a href="network/tcp_retransmission.stp">network/tcp_retransmission.stp</a> - print tcp retransmission packet<br>
+keywords: <a href="keyword-index.html#TCP">TCP</a> <a href="keyword-index.html#RETRANSMISSION">RETRANSMISSION</a> <br>
+<p>The tcp_retransmission.stp prints out a line for each tcp retransmission packet</p><p><font size="-2"><pre># stap tcp_retransmission.stp -T 1</pre></font></p>
+</li></ul>
 <h3><a name="SCHEDULER"><a href="#SCHEDULER">&para;</a> SCHEDULER</a></h3>
 <ul>
 <li><a href="process/chng_cpu.stp">process/chng_cpu.stp</a> - Monitor Changes in Processor Executing a Task<br>
@@ -995,6 +1001,9 @@ keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-inde
 </li><li><a href="network/tcp_init_cwnd.stp">network/tcp_init_cwnd.stp</a> - Increase Initial TCP Congestion Window to 10<br>
 keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-index.html#TCP">TCP</a> <a href="keyword-index.html#SOCKET">SOCKET</a> <a href="keyword-index.html#GURU">GURU</a> <br>
 <p>Run the tcp_init_cwnd.stp script in the background to override a kernel&#39;s default tcp cwnd value to 10, which has been found to improve latency for web server type workloads.  The script prints a count of cwnd value changes when it is stopped.</p><p><font size="-2"><pre># stap -g tcp_init_cwnd.stp -T 1</pre></font></p>
+</li><li><a href="network/tcp_retransmission.stp">network/tcp_retransmission.stp</a> - print tcp retransmission packet<br>
+keywords: <a href="keyword-index.html#TCP">TCP</a> <a href="keyword-index.html#RETRANSMISSION">RETRANSMISSION</a> <br>
+<p>The tcp_retransmission.stp prints out a line for each tcp retransmission packet</p><p><font size="-2"><pre># stap tcp_retransmission.stp -T 1</pre></font></p>
 </li></ul>
 <h3><a name="THREAD"><a href="#THREAD">&para;</a> THREAD</a></h3>
 <ul>
diff --git a/testsuite/systemtap.examples/keyword-index.txt b/testsuite/systemtap.examples/keyword-index.txt
index 370483a..1ebc999 100644
--- a/testsuite/systemtap.examples/keyword-index.txt
+++ b/testsuite/systemtap.examples/keyword-index.txt
@@ -2347,6 +2347,17 @@ keywords: regex
   # stap regex.stp -T 1
 
 
+= RETRANSMISSION =
+
+network/tcp_retransmission.stp - print tcp retransmission packet
+keywords: tcp retransmission
+
+  The tcp_retransmission.stp prints out a line for each tcp
+  retransmission packet
+
+  # stap tcp_retransmission.stp -T 1
+
+
 = SCHEDULER =
 
 process/chng_cpu.stp - Monitor Changes in Processor Executing a Task
@@ -3102,6 +3113,15 @@ keywords: network tcp socket guru
   # stap -g tcp_init_cwnd.stp -T 1
 
 
+network/tcp_retransmission.stp - print tcp retransmission packet
+keywords: tcp retransmission
+
+  The tcp_retransmission.stp prints out a line for each tcp
+  retransmission packet
+
+  # stap tcp_retransmission.stp -T 1
+
+
 = THREAD =
 
 general/eventcount.stp - Count Specified Events
diff --git a/testsuite/systemtap.examples/metadatabase.db b/testsuite/systemtap.examples/metadatabase.db
index cf5d564..2447d0e 100644
Binary files a/testsuite/systemtap.examples/metadatabase.db and b/testsuite/systemtap.examples/metadatabase.db differ
diff --git a/testsuite/systemtap.examples/network/tcp_retransmission.meta b/testsuite/systemtap.examples/network/tcp_retransmission.meta
new file mode 100644
index 0000000..98c2be5
--- /dev/null
+++ b/testsuite/systemtap.examples/network/tcp_retransmission.meta
@@ -0,0 +1,6 @@
+title: print tcp retransmission packet
+name: tcp_retransmission.stp
+keywords: tcp retransmission
+description: The tcp_retransmission.stp prints out a line for each tcp retransmission packet
+test_check: stap -p4 tcp_retransmission.stp
+test_installcheck: stap tcp_retransmission.stp -T 1
diff --git a/testsuite/systemtap.examples/network/tcp_retransmission.stp b/testsuite/systemtap.examples/network/tcp_retransmission.stp
new file mode 100755
index 0000000..7d9ac99
--- /dev/null
+++ b/testsuite/systemtap.examples/network/tcp_retransmission.stp
@@ -0,0 +1,37 @@
+#! /usr/bin/env stap
+
+#################################################################
+# tcp_retransmit.stp
+# Author: Yang Bingwu (detailyang) <detailyang@gmail.com>
+# This systemtap script will prints the tcp retransmission packet
+#################################################################
+
+global record
+
+probe begin {
+    warn("Printing tcp retransmission")
+}
+
+probe kernel.function("tcp_retransmit_skb") {
+    sock = $sk
+
+    rto = tcp_get_info_rto(sock)
+    saddr   = format_ipaddr(__ip_sock_saddr($sk), __ip_sock_family($sk))
+    daddr   = format_ipaddr(__ip_sock_daddr($sk), __ip_sock_family($sk))
+    sport   = __tcp_sock_sport($sk)
+    dport   = __tcp_sock_dport($sk)
+    lastrto = record[saddr, sport, daddr, dport]
+    state = tcp_ts_get_info_state(sock)
+
+    if (lastrto != rto) {
+        if (lastrto) {
+            printf("%s:%d => %s:%d STATE:%s RTO:%d -> %d (ms)\n", saddr, sport,
+                daddr, dport, tcp_sockstate_str(state), lastrto/1000, rto/1000)
+        } else {
+            printf("%s:%d => %s:%d STATE:%s RTO:%d (ms)\n", saddr, sport,
+                daddr, dport, tcp_sockstate_str(state), rto/1000)
+        }
+    }
+
+    record[saddr, sport, daddr, dport] = rto
+}

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Add A Sample To Exapmle
  2016-11-07  2:26 Add A Sample To Exapmle Bingwu Yang
@ 2016-11-07 13:46 ` Frank Ch. Eigler
  0 siblings, 0 replies; 2+ messages in thread
From: Frank Ch. Eigler @ 2016-11-07 13:46 UTC (permalink / raw)
  To: Bingwu Yang; +Cc: systemtap


Hi -

> I add a sample systemtap script to source tree. Wish it can be useful:)
> Can anybody help me to review this patch?
> [...]


> diff --git a/testsuite/systemtap.examples/index.html b/testsuite/systemtap.examples/index.html
> index d9a7d47..5952356 100644
> --- a/testsuite/systemtap.examples/index.html
> +++ b/testsuite/systemtap.examples/index.html
> [...]

(This is OK, but you don't have to include diffs of machine-generated
files for review.)


> [...]
> +global record

This is fine, except that there is no limit in your script as to how
many records may be kept alive.  This record array will grow and grow
and eventually overflow with a MAXMAPENTRIES-related error.  Consider

global record%

to activate wrapping (LRU) mode, so that older entries will be 
reused when the array fills up.


> +probe begin {
> +    warn("Printing tcp retransmission")
> +}

Please consider log() or such instead of warn().

Otherwise looks good.  What do you think about the suggestions?

- FChE

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-11-07 13:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-07  2:26 Add A Sample To Exapmle Bingwu Yang
2016-11-07 13:46 ` Frank Ch. Eigler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).