From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
Adrian Hunter <adrian.hunter@intel.com>,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
Ingo Molnar <mingo@redhat.com>,
Namhyung Kim <namhyung@kernel.org>, Jiri Olsa <jolsa@redhat.com>
Subject: Re: [PATCH perf/core 17/22] perf: Fix __machine__addnew_vdso to put dso after add to dsos
Date: Wed, 9 Dec 2015 11:38:37 -0300 [thread overview]
Message-ID: <20151209143837.GH15864@kernel.org> (raw)
In-Reply-To: <20151209021125.10245.54213.stgit@localhost.localdomain>
Em Wed, Dec 09, 2015 at 11:11:25AM +0900, Masami Hiramatsu escreveu:
> Fix __machine__addnew_vdso to put dso after add to dsos because
> the dso is already gotten by the dsos via __dsos__add().
>
> This function is called finally from machine__findnew_vdso()
> which locks machine->dsos.lock. And before unlock it, the
> function gets the dso's refcnt. Thus we can ensure that the
> dso is not removed from the machine while this operation,
> and we don't need to get the dso except for the machine->dsos.
>
> refcnt debugger shows:
> -----
> $ ./perf top --stdio -v (note: run by non-root user)
> [...]
> ==== [3] ====
> Unreclaimed dso@0x27a0a30
> Refcount +1 => 1 at
> ./perf(dso__new+0x2bc) [0x4a778c]
> ./perf(machine__findnew_vdso+0x272) [0x4e8792]
> ./perf(map__new+0x2db) [0x4bfb4b]
> ./perf(machine__process_mmap2_event+0xf3) [0x4bda33]
> ./perf(perf_event__synthesize_mmap_events+0x364) [0x484e74]
> ./perf(perf_event__synthesize_threads+0x3ee) [0x48583e]
> ./perf(cmd_top+0xdc2) [0x43cfb2]
> ./perf() [0x47ba35]
> ./perf(main+0x617) [0x4225b7]
> /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f2b01387af5]
> ./perf() [0x42272d]
> Refcount +1 => 2 at
> ./perf(machine__findnew_vdso+0x289) [0x4e87a9]
> ./perf(map__new+0x2db) [0x4bfb4b]
> ./perf(machine__process_mmap2_event+0xf3) [0x4bda33]
> ./perf(perf_event__synthesize_mmap_events+0x364) [0x484e74]
> ./perf(perf_event__synthesize_threads+0x3ee) [0x48583e]
> ./perf(cmd_top+0xdc2) [0x43cfb2]
> ./perf() [0x47ba35]
> ./perf(main+0x617) [0x4225b7]
> /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f2b01387af5]
> ./perf() [0x42272d]
> Refcount +1 => 3 at
> ./perf(dso__get+0x32) [0x4a7b52]
> ./perf(machine__findnew_vdso+0xc1) [0x4e85e1]
> ./perf(map__new+0x2db) [0x4bfb4b]
> ./perf(machine__process_mmap2_event+0xf3) [0x4bda33]
> ./perf(perf_event__synthesize_mmap_events+0x364) [0x484e74]
> ./perf(perf_event__synthesize_threads+0x3ee) [0x48583e]
> ./perf(cmd_top+0xdc2) [0x43cfb2]
> ./perf() [0x47ba35]
> ./perf(main+0x617) [0x4225b7]
> /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f2b01387af5]
> ./perf() [0x42272d]
> [...]
> -----
>
> The log shows that the machine__findnew_vdso gets a dso
> so many unnaturally. I've traced the code and found this
> bug.
>
> Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
> ---
> tools/perf/util/vdso.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/tools/perf/util/vdso.c b/tools/perf/util/vdso.c
> index 44d440d..fea0d18 100644
> --- a/tools/perf/util/vdso.c
> +++ b/tools/perf/util/vdso.c
> @@ -130,6 +130,8 @@ static struct dso *__machine__addnew_vdso(struct machine *machine, const char *s
> __dsos__add(&machine->dsos, dso);
> dso__set_long_name(dso, long_name, false);
> }
> + /* Put the dso here because it is already gotten by __dsos__add */
> + dso__put(dso);
>
> return dso;
> }
We cannot put it here, because we're returning a pointer to it, so,
whoever receives this pointer, receives a recfount with it, that it, in
turn, should put.
And indeed, this dso adding code is confusing, will have to look at it
harder :-\
- Arnaldo
next prev parent reply other threads:[~2015-12-09 14:38 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 [this message]
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)
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=20151209143837.GH15864@kernel.org \
--to=acme@kernel.org \
--cc=a.p.zijlstra@chello.nl \
--cc=adrian.hunter@intel.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).