diff options
Diffstat (limited to 'SystemTap_Beginners_Guide/timeoutssect.html')
| -rw-r--r-- | SystemTap_Beginners_Guide/timeoutssect.html | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/SystemTap_Beginners_Guide/timeoutssect.html b/SystemTap_Beginners_Guide/timeoutssect.html index 174ef67d..714d98cb 100644 --- a/SystemTap_Beginners_Guide/timeoutssect.html +++ b/SystemTap_Beginners_Guide/timeoutssect.html | |||
| @@ -1,12 +1,12 @@ | |||
| 1 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> | 1 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> |
| 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title xmlns:d="http://docbook.org/ns/docbook">5.3.4. Monitoring Polling Applications</title><link rel="stylesheet" type="text/css" href="Common_Content/css/default.css" /><link rel="stylesheet" media="print" href="Common_Content/css/print.css" type="text/css" /><meta xmlns:d="http://docbook.org/ns/docbook" name="generator" content="not publican" /><meta xmlns:d="http://docbook.org/ns/docbook" name="package" content="" /><link rel="home" href="index.html" title="SystemTap Beginners Guide" /><link rel="up" href="mainsect-profiling.html" title="5.3. Profiling" /><link rel="prev" href="threadtimessect.html" title="5.3.3. Determining Time Spent in Kernel and User Space" /><link rel="next" href="topsyssect.html" title="5.3.5. Tracking Most Frequently Used System Calls" /></head><body><p id="title"></p><ul class="docnav top"><li class="previous"><a accesskey="p" href="threadtimessect.html"><strong>Prev</strong></a></li><li class="home">SystemTap Beginners Guide</li><li class="next"><a accesskey="n" href="topsyssect.html"><strong>Next</strong></a></li></ul><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="timeoutssect"> | 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title xmlns:d="http://docbook.org/ns/docbook">5.3.4. Monitoring Polling Applications</title><link rel="stylesheet" type="text/css" href="Common_Content/css/default.css" /><link rel="stylesheet" media="print" href="Common_Content/css/print.css" type="text/css" /><meta xmlns:d="http://docbook.org/ns/docbook" name="generator" content="not publican" /><meta xmlns:d="http://docbook.org/ns/docbook" name="package" content="" /><link rel="home" href="index.html" title="SystemTap Beginners Guide" /><link rel="up" href="mainsect-profiling.html" title="5.3. Profiling" /><link rel="prev" href="threadtimessect.html" title="5.3.3. Determining Time Spent in Kernel and User Space" /><link rel="next" href="topsyssect.html" title="5.3.5. Tracking Most Frequently Used System Calls" /></head><body><p id="title"></p><ul class="docnav top"><li class="previous"><a accesskey="p" href="threadtimessect.html"><strong>Prev</strong></a></li><li class="home">SystemTap Beginners Guide</li><li class="next"><a accesskey="n" href="topsyssect.html"><strong>Next</strong></a></li></ul><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="timeoutssect"> |
| 3 | </a>5.3.4. Monitoring Polling Applications</h3></div></div></div><a id="idm47006125928784" class="indexterm"></a><a id="idm47006120521200" class="indexterm"></a><a id="idm47006119729264" class="indexterm"></a><a id="idm47006121542656" class="indexterm"></a><div class="para"> | 3 | </a>5.3.4. Monitoring Polling Applications</h3></div></div></div><a id="idp71890970445760" class="indexterm"></a><a id="idp71890961144160" class="indexterm"></a><a id="idp71890973637392" class="indexterm"></a><a id="idp71890960995472" class="indexterm"></a><div class="para"> |
| 4 | This section describes how to identify and monitor which applications are polling. Doing so allows you to track | 4 | This section describes how to identify and monitor which applications are polling. Doing so allows you to track |
| 5 | unnecessary or excessive polling, which can help you pinpoint areas for improvement in terms of CPU usage | 5 | unnecessary or excessive polling, which can help you pinpoint areas for improvement in terms of CPU usage |
| 6 | and power savings. | 6 | and power savings. |
| 7 | </div><div class="para"><div xmlns:d="http://docbook.org/ns/docbook" class="title">timeout.stp</div> | 7 | </div><div class="para"><div xmlns:d="http://docbook.org/ns/docbook" class="title">timeout.stp</div> |
| 8 | <pre class="programlisting">#! /usr/bin/env stap | 8 | <pre class="programlisting">#! /usr/bin/env stap |
| 9 | # Copyright (C) 2009 Red Hat, Inc. | 9 | # Copyright (C) 2009-2018 Red Hat, Inc. |
| 10 | # Written by Ulrich Drepper <drepper@redhat.com> | 10 | # Written by Ulrich Drepper <drepper@redhat.com> |
| 11 | # Modified by William Cohen <wcohen@redhat.com> | 11 | # Modified by William Cohen <wcohen@redhat.com> |
| 12 | 12 | ||
| @@ -14,12 +14,12 @@ global process, timeout_count, to | |||
| 14 | global poll_timeout, epoll_timeout, select_timeout, itimer_timeout | 14 | global poll_timeout, epoll_timeout, select_timeout, itimer_timeout |
| 15 | global nanosleep_timeout, futex_timeout, signal_timeout | 15 | global nanosleep_timeout, futex_timeout, signal_timeout |
| 16 | 16 | ||
| 17 | probe syscall.poll, syscall.epoll_wait { | 17 | probe syscall.{poll,epoll_wait} { |
| 18 | if (timeout) to[pid()]=timeout | 18 | if (timeout) to[pid()]=timeout |
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | probe syscall.poll.return { | 21 | probe syscall.poll.return { |
| 22 | if ($return == 0 && to[pid()] > 0 ) { | 22 | if (retval == 0 && to[pid()] > 0 ) { |
| 23 | poll_timeout[pid()]++ | 23 | poll_timeout[pid()]++ |
| 24 | timeout_count[pid()]++ | 24 | timeout_count[pid()]++ |
| 25 | process[pid()] = execname() | 25 | process[pid()] = execname() |
| @@ -28,16 +28,16 @@ probe syscall.poll.return { | |||
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | probe syscall.epoll_wait.return { | 30 | probe syscall.epoll_wait.return { |
| 31 | if ($return == 0 && to[pid()] > 0 ) { | 31 | if (retval == 0 && to[pid()] > 0 ) { |
| 32 | epoll_timeout[pid()]++ | 32 | epoll_timeout[pid()]++ |
| 33 | timeout_count[pid()]++ | 33 | timeout_count[pid()]++ |
| 34 | process[p] = execname() | 34 | process[pid()] = execname() |
| 35 | delete to[pid()] | 35 | delete to[pid()] |
| 36 | } | 36 | } |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | probe syscall.select.return { | 39 | probe syscall.select.return { |
| 40 | if ($return == 0) { | 40 | if (retval == 0) { |
| 41 | select_timeout[pid()]++ | 41 | select_timeout[pid()]++ |
| 42 | timeout_count[pid()]++ | 42 | timeout_count[pid()]++ |
| 43 | process[pid()] = execname() | 43 | process[pid()] = execname() |
| @@ -45,7 +45,7 @@ probe syscall.select.return { | |||
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | probe syscall.futex.return { | 47 | probe syscall.futex.return { |
| 48 | if (errno_str($return) == "ETIMEDOUT") { | 48 | if (errno_str(retval) == "ETIMEDOUT") { |
| 49 | futex_timeout[pid()]++ | 49 | futex_timeout[pid()]++ |
| 50 | timeout_count[pid()]++ | 50 | timeout_count[pid()]++ |
| 51 | process[pid()] = execname() | 51 | process[pid()] = execname() |
| @@ -53,7 +53,7 @@ probe syscall.futex.return { | |||
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | probe syscall.nanosleep.return { | 55 | probe syscall.nanosleep.return { |
| 56 | if ($return == 0) { | 56 | if (retval == 0) { |
| 57 | nanosleep_timeout[pid()]++ | 57 | nanosleep_timeout[pid()]++ |
| 58 | timeout_count[pid()]++ | 58 | timeout_count[pid()]++ |
| 59 | process[pid()] = execname() | 59 | process[pid()] = execname() |
| @@ -67,7 +67,7 @@ probe kernel.function("it_real_fn") { | |||
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | probe syscall.rt_sigtimedwait.return { | 69 | probe syscall.rt_sigtimedwait.return { |
| 70 | if (errno_str($return) == "EAGAIN") { | 70 | if (errno_str(retval) == "EAGAIN") { |
| 71 | signal_timeout[pid()]++ | 71 | signal_timeout[pid()]++ |
| 72 | timeout_count[pid()]++ | 72 | timeout_count[pid()]++ |
| 73 | process[pid()] = execname() | 73 | process[pid()] = execname() |
| @@ -99,13 +99,30 @@ probe timer.s(1) { | |||
| 99 | signal_timeout[p], process[p]) | 99 | signal_timeout[p], process[p]) |
| 100 | } | 100 | } |
| 101 | } | 101 | } |
| 102 | |||
| 103 | global prom_arr | ||
| 104 | |||
| 105 | probe prometheus { | ||
| 106 | foreach (p in timeout_count- limit 20) { | ||
| 107 | prom_arr[poll_timeout[p], select_timeout[p], | ||
| 108 | epoll_timeout[p], itimer_timeout[p], | ||
| 109 | futex_timeout[p], nanosleep_timeout[p], | ||
| 110 | signal_timeout[p]] = process[p] | ||
| 111 | } | ||
| 112 | |||
| 113 | @prometheus_dump_array7(prom_arr, "process", "poll_timeout", "select_timeout", | ||
| 114 | "epoll_timeout", "itimer_timeout", | ||
| 115 | "futex_timeout", "nanosleep_timeout", | ||
| 116 | "signal_timeout") | ||
| 117 | delete prom_arr | ||
| 118 | } | ||
| 102 | </pre> | 119 | </pre> |
| 103 | </div><div class="para"> | 120 | </div><div class="para"> |
| 104 | <a class="xref" href="timeoutssect.html#timeouts">timeout.stp</a> tracks how many times each | 121 | <a class="xref" href="timeoutssect.html#timeouts">timeout.stp</a> tracks how many times each |
| 105 | of the following system calls completed | 122 | of the following system calls completed |
| 106 | due to time expiring rather than due to an actual event | 123 | due to time expiring rather than due to an actual event |
| 107 | occurring: | 124 | occurring: |
| 108 | </div><div xmlns:d="http://docbook.org/ns/docbook" class="itemizedlist"><ul><li class="listitem"><div class="para"><code class="command">poll</code></div></li><li class="listitem"><div class="para"><code class="command">select</code></div></li><li class="listitem"><div class="para"><code class="command">epoll</code></div></li><li class="listitem"><div class="para"><code class="command">itimer</code></div></li><li class="listitem"><div class="para"><code class="command">futex</code></div></li><li class="listitem"><div class="para"><code class="command">nanosleep</code></div></li><li class="listitem"><div class="para"><code class="command">signal</code></div></li></ul></div><a id="idm47006129265504" class="indexterm"></a><a id="idm47006120640176" class="indexterm"></a><a id="idm47006125169120" class="indexterm"></a><div class="example"><a id="timeoutsoutput"> | 125 | </div><div xmlns:d="http://docbook.org/ns/docbook" class="itemizedlist"><ul><li class="listitem"><div class="para"><code class="command">poll</code></div></li><li class="listitem"><div class="para"><code class="command">select</code></div></li><li class="listitem"><div class="para"><code class="command">epoll</code></div></li><li class="listitem"><div class="para"><code class="command">itimer</code></div></li><li class="listitem"><div class="para"><code class="command">futex</code></div></li><li class="listitem"><div class="para"><code class="command">nanosleep</code></div></li><li class="listitem"><div class="para"><code class="command">signal</code></div></li></ul></div><a id="idp71890972012320" class="indexterm"></a><a id="idp71890960012016" class="indexterm"></a><a id="idp71890965642672" class="indexterm"></a><div class="example"><a id="timeoutsoutput"> |
| 109 | </a><p class="title"><strong>Example 5.16. <a class="xref" href="timeoutssect.html#timeouts">timeout.stp</a> Sample Output</strong></p><div class="example-contents"><pre class="screen"> uid | poll select epoll itimer futex nanosle signal| process | 126 | </a><p class="title"><strong>Example 5.16. <a class="xref" href="timeoutssect.html#timeouts">timeout.stp</a> Sample Output</strong></p><div class="example-contents"><pre class="screen"> uid | poll select epoll itimer futex nanosle signal| process |
| 110 | 28937 | 148793 0 0 4727 37288 0 0| firefox | 127 | 28937 | 148793 0 0 4727 37288 0 0| firefox |
| 111 | 22945 | 0 56949 0 1 0 0 0| scim-bridge | 128 | 22945 | 0 56949 0 1 0 0 0| scim-bridge |
