linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Wangnan (F)" <wangnan0@huawei.com>
To: "平松雅巳 / HIRAMATU,MASAMI" <masami.hiramatsu.pt@hitachi.com>,
	"'Arnaldo Carvalho de Melo'" <acme@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Adrian Hunter <adrian.hunter@intel.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-perf-users@vger.kernel.org"
	<linux-perf-users@vger.kernel.org>,
	Ingo Molnar <mingo@redhat.com>,
	Namhyung Kim <namhyung@kernel.org>, Jiri Olsa <jolsa@redhat.com>,
	Alexei Starovoitov <ast@plumgrid.com>
Subject: Re: [PATCH perf/core  00/22] perf refcnt debugger API and fixes
Date: Fri, 11 Dec 2015 10:42:43 +0800	[thread overview]
Message-ID: <566A3823.9080503@huawei.com> (raw)
In-Reply-To: <50399556C9727B4D88A595C8584AAB37526515F5@GSjpTKYDCembx32.service.hitachi.net>



On 2015/12/11 10:15, 平松雅巳 / HIRAMATU,MASAMI wrote:
> From: 'Arnaldo Carvalho de Melo' [mailto:acme@kernel.org]
>> But this requires having these special refcnt__ routines, that will make
>> tools/perf/ code patterns for reference counts look different that the
>> refcount patterns in the kernel :-\
> BTW, I think even without the refcnt debugger, we'd better introduce this
> kind API to unify the refcnt operation in perf code. As I said, we have many
> miscodings on current implementation. Unifying the API can enforce developers
> to avoid such miscodings.
>
> Thank you,
>

I tried this problem in another way, I'd like to share it here.

First: create two uprobes:

# ./perf probe --exec /home/wangnan/perf dso__new%return %ax
Added new event:
   probe_perf:dso__new  (on dso__new%return in /home/wangnan/perf with %ax)

You can now use it in all perf tools, such as:

     perf record -e probe_perf:dso__new -aR sleep 1

# ./perf probe --exec /home/wangnan/perf dso__delete dso
Added new event:
   probe_perf:dso__delete (on dso__delete in /home/wangnan/perf with dso)

You can now use it in all perf tools, such as:

     perf record -e probe_perf:dso__delete -aR sleep 1


Then start test:

# ./perf record -g -e probe_perf:dso__new -e probe_perf:dso__delete 
./perf probe vfs_read
Added new event:
   probe:vfs_read       (on vfs_read)

You can now use it in all perf tools, such as:

     perf record -e probe:vfs_read -aR sleep 1

[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.048 MB perf.data (178 samples) ]


 From the perf report result I know two dso objects are leak:

90 probe_perf:dso__new `
88 probe_perf:dso__delete


Then convert output to CTF:

$ ./perf data convert --to-ctf ./out.ctf


With a python script, try to find the exact leak objects (I'm not good 
at python,
I believe we can do this with much shorter script):

$ cat refcnt.py
from babeltrace import TraceCollection

tc = TraceCollection();
tc.add_trace('./out.ctf', 'ctf')
objs = {}
for event in tc.events:
     if event.name.startswith('probe_perf:dso__new'):
         if event['arg1'] not in objs:
             objs[event['arg1']] = 1
     if event.name.startswith('probe_perf:dso__delete'):
         if event['dso'] in objs:
             objs[event['dso']] = 0

for x in objs:
     if objs[x] is 0:
         continue
     print("0x%x" % x)

$ python3 ./refcnt.py
0x34cb350
0x34d4640

Then from perf script's result, search for the two address:

perf 23203 [004] 665244.170387: probe_perf:dso__new: (4aaee0 <- 50a5eb) 
arg1=0x34cb350
                   10a5eb dso__load_sym (/home/w00229757/perf)
                    af42d dso__load_vmlinux (/home/w00229757/perf)
                    af58c dso__load_vmlinux_path (/home/w00229757/perf)
                   10c40a open_debuginfo (/home/w00229757/perf)
                   111d39 convert_perf_probe_events (/home/w00229757/perf)
                    603a7 __cmd_probe.isra.3 (/home/w00229757/perf)
                    60a44 cmd_probe (/home/w00229757/perf)
                    7f6d1 run_builtin (/home/w00229757/perf)
                    33056 main (/home/w00229757/perf)
                    21bd5 __libc_start_main 
(/tmp/oxygen_root-w00229757/lib64/libc-2.18.so)

perf 23203 [004] 665244.170679: probe_perf:dso__new: (4aaee0 <- 50a5eb) 
arg1=0x34d4640
                   10a5eb dso__load_sym (/home/w00229757/perf)
                    af42d dso__load_vmlinux (/home/w00229757/perf)
                    af58c dso__load_vmlinux_path (/home/w00229757/perf)
                   10c40a open_debuginfo (/home/w00229757/perf)
                   111d39 convert_perf_probe_events (/home/w00229757/perf)
                    603a7 __cmd_probe.isra.3 (/home/w00229757/perf)
                    60a44 cmd_probe (/home/w00229757/perf)
                    7f6d1 run_builtin (/home/w00229757/perf)
                    33056 main (/home/w00229757/perf)
                    21bd5 __libc_start_main 
(/tmp/oxygen_root-w00229757/lib64/libc-2.18.so)

Thank you.

  reply	other threads:[~2015-12-11  2:43 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-09  2:10 [PATCH perf/core 00/22] perf refcnt debugger API and fixes Masami Hiramatsu
2015-12-09  2:10 ` [PATCH perf/core 01/22] [v2] perf refcnt: Introduce generic refcount APIs with debug feature Masami Hiramatsu
2015-12-09  2:10 ` [PATCH perf/core 02/22] perf refcnt: Use a hash for refcnt_root Masami Hiramatsu
2015-12-09  2:10 ` [PATCH perf/core 03/22] perf refcnt: Add refcnt debug filter Masami Hiramatsu
2015-12-09  2:10 ` [PATCH perf/core 04/22] perf refcnt: refcnt shows summary per object Masami Hiramatsu
2015-12-09  2:10 ` [PATCH perf/core 05/22] perf: make map to use refcnt Masami Hiramatsu
2015-12-09  2:11 ` [PATCH perf/core 06/22] perf: Make dso to use refcnt for debug Masami Hiramatsu
2015-12-09  2:11 ` [PATCH perf/core 07/22] perf: Make map_groups to use refcnt Masami Hiramatsu
2015-12-09  2:11 ` [PATCH perf/core 08/22] perf: Make thread uses refcnt for debug Masami Hiramatsu
2015-12-09  2:11 ` [PATCH perf/core 09/22] perf: Make cpu_map to use " Masami Hiramatsu
2015-12-09  2:11 ` [PATCH perf/core 10/22] perf: Make comm_str " Masami Hiramatsu
2015-12-09  2:11 ` [PATCH perf/core 11/22] perf: Make cgroup_sel " Masami Hiramatsu
2015-12-09  2:11 ` [PATCH perf/core 12/22] perf: Make thread_map " Masami Hiramatsu
2015-12-09  2:11 ` [PATCH perf/core 13/22] perf: Make perf_mmap " Masami Hiramatsu
2015-12-09  2:11 ` [PATCH perf/core 14/22] perf: Fix dso__load_sym to put dso Masami Hiramatsu
2015-12-09 14:16   ` Arnaldo Carvalho de Melo
2015-12-10  8:52     ` 平松雅巳 / HIRAMATU,MASAMI
2015-12-10 19:26       ` 'Arnaldo Carvalho de Melo'
2015-12-09  2:11 ` [PATCH perf/core 15/22] perf: Fix map_groups__clone to put cloned map Masami Hiramatsu
2015-12-09 14:17   ` Arnaldo Carvalho de Melo
2015-12-09  2:11 ` [PATCH perf/core 16/22] perf: Fix __cmd_top and perf_session__process_events to put the idle thread Masami Hiramatsu
2015-12-09 14:30   ` Arnaldo Carvalho de Melo
2015-12-10 10:07     ` 平松雅巳 / HIRAMATU,MASAMI
2015-12-09  2:11 ` [PATCH perf/core 17/22] perf: Fix __machine__addnew_vdso to put dso after add to dsos Masami Hiramatsu
2015-12-09 14:38   ` Arnaldo Carvalho de Melo
2015-12-09  2:11 ` [PATCH perf/core 18/22] perf stat: Fix cmd_stat to release cpu_map Masami Hiramatsu
2015-12-09 15:05   ` Arnaldo Carvalho de Melo
2015-12-09  2:11 ` [PATCH perf/core 19/22] perf: fix hists_evsel to release hists Masami Hiramatsu
2015-12-09 15:12   ` Arnaldo Carvalho de Melo
2015-12-09  2:11 ` [PATCH perf/core 20/22] perf: Fix maps__fixup_overlappings to put used maps Masami Hiramatsu
2015-12-09 15:15   ` Arnaldo Carvalho de Melo
2015-12-09  2:11 ` [PATCH perf/core 21/22] perf: Fix machine.vmlinux_maps to make sure to clear the old one Masami Hiramatsu
2015-12-09 15:22   ` Arnaldo Carvalho de Melo
2015-12-10  2:52     ` Wangnan (F)
2015-12-09  2:11 ` [PATCH perf/core 22/22] perf: Fix write_numa_topology to put cpu_map instead of free Masami Hiramatsu
2015-12-09 15:26   ` Arnaldo Carvalho de Melo
2015-12-09 13:41 ` [PATCH perf/core 00/22] perf refcnt debugger API and fixes Arnaldo Carvalho de Melo
2015-12-10  3:31   ` Alexei Starovoitov
2015-12-10  4:49   ` Namhyung Kim
2015-12-10  8:39     ` 平松雅巳 / HIRAMATU,MASAMI
2015-12-10 11:04   ` 平松雅巳 / HIRAMATU,MASAMI
2015-12-10 12:52     ` Wangnan (F)
2015-12-10 15:12       ` 'Arnaldo Carvalho de Melo'
2015-12-11  1:53         ` Wangnan (F)
2015-12-11  2:08           ` 平松雅巳 / HIRAMATU,MASAMI
2015-12-11  2:22             ` Wangnan (F)
2015-12-11  2:15         ` 平松雅巳 / HIRAMATU,MASAMI
2015-12-11  2:42           ` Wangnan (F) [this message]
2015-12-11  2:53             ` Wangnan (F)
2015-12-11  3:59             ` 平松雅巳 / HIRAMATU,MASAMI
2015-12-11 22:26   ` Arnaldo Carvalho de Melo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=566A3823.9080503@huawei.com \
    --to=wangnan0@huawei.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=ast@plumgrid.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 NNTP newsgroup(s).