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

Andrew Vagin avagin at parallels.com
Wed Oct 1 01:03:57 PDT 2014


On Tue, Sep 30, 2014 at 01:23:55PM -0400, Christopher Covington wrote:
> On 09/30/2014 08:05 AM, Andrey Vagin wrote:
> > 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
> 
> The man page on Ubuntu 12.04 says -a and --cgroup are incompatible.
> 
> -a, --all-cpus
>     System-wide collection from all CPUs.
> 
> -G name,..., --cgroup name,...
>     monitor only in the container (cgroup) called "name". This option is
>     available only in per-cpu mode.

Unfortunately the reality is a bit different than it's described in
books.

[root at avagin-fc19-cr ~]# perf record -e raw_syscalls:* --cgroup test,test -a sleep 1
Error:
cgroup monitoring only available in system-wide mode


> 
> Why do you need container based monitoring instead of just command-and-childen
> based with `perf record $CRIU_CPT`?

I want to trace parasite code, which is injected in dumped processes.

> 
> Christopher
> 
> -- 
> Employee of Qualcomm Innovation Center, Inc.
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
> hosted by the Linux Foundation.


More information about the CRIU mailing list