[CRIU] [PATCH] [RFC] perf: Here is an example how to trace syscalls

Andrey Vagin avagin at openvz.org
Tue Sep 30 05:05:45 PDT 2014


perf doesn't affect performance so significant as strace and
it allows to trace parasite code.

All processes are executed in a new perf_evets cgroup and
"perf record" collects events only for processes from this group.

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 test/zdtm.sh | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/test/zdtm.sh b/test/zdtm.sh
index b5133c3..1eba6d7 100755
--- a/test/zdtm.sh
+++ b/test/zdtm.sh
@@ -1,5 +1,8 @@
 #!/bin/bash
 
+test -d /sys/fs/cgroup/perf_event/zdtm || mkdir /sys/fs/cgroup/perf_event/zdtm || exit 1
+echo $$ > /sys/fs/cgroup/perf_event/zdtm/tasks
+
 ARCH=`uname -m | sed			\
 		-e s/i.86/i386/		\
 		-e s/sun4u/sparc64/	\
@@ -582,8 +585,14 @@ EOF
 
 		save_fds $PID  $ddump/dump.fd
 		save_maps $PID  $ddump/dump.maps
-		setsid $CRIU_CPT $dump_cmd -D $ddump -o dump.log -v4 -t $PID $gen_args $cpt_args
+		echo $$ > /sys/fs/cgroup/perf_event/tasks
+		perf record -o $ddump/perf.dump -e raw_syscalls:sys_exit,raw_syscalls:sys_enter --cgroup test,test -a bash <<EOF
+echo 0 > /sys/fs/cgroup/perf_event/zdtm/tasks &&
+$CRIU_CPT $dump_cmd -D $ddump -o dump.log -v4 -t $PID $gen_args $cpt_args
+EOF
 		retcode=$?
+		echo Use the following command to analize perf data:
+		echo perf trace report -i $ddump/perf.dump
 
 		#
 		# Here we may have two cases: either checkpoint is failed
-- 
1.9.3



More information about the CRIU mailing list