Skip to contentSkip to conversation

perf trace: Disable events and drain events when forked workload ends

tip:perf/urgent tip-bot for Arnaldo Carvalho de Melo 1 participant 1 message May 1, 2015 perf events

lore
Share & tools
lore
#0 lore raw
Commit-ID:  02ac5421ddc634767c732f9b6a10a395a9ecfc4f
Gitweb:     http://git.kernel.org/tip/02ac5421ddc634767c732f9b6a10a395a9ecfc4f
Author:     Arnaldo Carvalho de Melo <[email protected]>
AuthorDate: Wed, 22 Apr 2015 11:11:57 -0300
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 23 Apr 2015 17:08:08 -0300

perf trace: Disable events and drain events when forked workload ends

We were not checking in the inner event processing loop if the forked workload had finished, which, on a busy system, may make it take a long time trying to drain events, entering a seemingly neverending loop, waiting for the system to get idle enough to make it drain the buffers.

Fix it by disabling the events when 'done' is true, in the inner loop, to start draining what is in the buffers.

Now:

[root@ssdandy ~]# time trace --filter-pids 14003 -a sleep 1 | tail
996.748 ( 0.002 ms): sh/30296 rt_sigprocmask(how: SETMASK, nset: 0x7ffc83418160, sigsetsize: 8) = 0 996.751 ( 0.002 ms): sh/30296 rt_sigprocmask(how: BLOCK, nset: 0x7ffc834181f0, oset: 0x7ffc83418270, sigsetsize: 8) = 0 996.755 ( 0.002 ms): sh/30296 rt_sigaction(sig: INT, act: 0x7ffc83417f50, oact: 0x7ffc83417ff0, sigsetsize: 8) = 0
1004.543 ( 0.362 ms): tail/30198 ... [continued]: read()) = 4096
1004.548 ( 7.791 ms): sh/30296 wait4(upid: -1, stat_addr: 0x7ffc834181a0) ...
1004.975 ( 0.427 ms): tail/30198 read(buf: 0x7633f0, count: 8192) = 4096
1005.390 ( 0.410 ms): tail/30198 read(buf: 0x765410, count: 8192) = 4096
1005.743 ( 0.348 ms): tail/30198 read(buf: 0x7633f0, count: 8192) = 4096
1006.197 ( 0.449 ms): tail/30198 read(buf: 0x765410, count: 8192) = 4096
1006.492 ( 0.290 ms): tail/30198 read(buf: 0x7633f0, count: 8192) = 4096

real 0m1.219s
user 0m0.704s
sys 0m0.331s
[root@ssdandy ~]#

---
 tools/perf/builtin-trace.c | 5 +++++
 1 file changed, 5 insertions(+)
tools/perf/builtin-trace.c +5 -0
index 8842218..e122970 100644
@@ -2273,6 +2273,11 @@ next_event:
 
 			if (interrupted)
 				goto out_disable;
+
+			if (done && !draining) {
+				perf_evlist__disable(evlist);
+				draining = true;
+			}
 		}
 	}