Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1271880
| From | Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH perf/core 09/13] perf: Make dso to use refcnt for debug |
| Date | 2015-11-18 07:50 +0100 |
| Message-ID | <qw4J4-7HS-25@gated-at.bofh.it> (permalink) |
| References | <qw4J3-7HS-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Make 'dso' object to use refcnt interface for debug.
This can find refcnt related memory leaks on dsos.
E.g.
----
# ./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
REFCNT: BUG: Unreclaimed objects found.
REFCNT: Total 75 objects are not reclaimed.
To see all backtraces, rerun with -v option
----
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
---
tools/perf/util/dso.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index 7c0c083..28ad06a 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -1049,7 +1049,7 @@ struct dso *dso__new(const char *name)
INIT_LIST_HEAD(&dso->node);
INIT_LIST_HEAD(&dso->data.open_entry);
pthread_mutex_init(&dso->lock, NULL);
- atomic_set(&dso->refcnt, 1);
+ refcnt__init(dso, refcnt);
}
return dso;
@@ -1081,19 +1081,20 @@ void dso__delete(struct dso *dso)
dso__free_a2l(dso);
zfree(&dso->symsrc_filename);
pthread_mutex_destroy(&dso->lock);
+ refcnt__exit(dso, refcnt);
free(dso);
}
struct dso *dso__get(struct dso *dso)
{
if (dso)
- atomic_inc(&dso->refcnt);
+ refcnt__get(dso, refcnt);
return dso;
}
void dso__put(struct dso *dso)
{
- if (dso && atomic_dec_and_test(&dso->refcnt))
+ if (dso && refcnt__put(dso, refcnt))
dso__delete(dso);
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH perf/core 00/13] perf memory/refcnt leak fixes Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> - 2015-11-18 07:50 +0100
[PATCH perf/core 12/13] perf: Fix machine__findnew_module_map to put dso Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> - 2015-11-18 07:50 +0100
[tip:perf/core] perf machine: Fix machine__findnew_module_map to put dso tip-bot for Masami Hiramatsu <tipbot@zytor.com> - 2015-11-23 17:20 +0100
[PATCH perf/core 13/13] perf: Fix dso__load_sym to put dso Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> - 2015-11-18 07:50 +0100
[PATCH perf/core 10/13] perf: Fix __dsos__addnew to put dso after adding it to the list Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> - 2015-11-18 07:50 +0100
[tip:perf/core] perf tools: Fix __dsos__addnew to put dso after adding it to the list tip-bot for Masami Hiramatsu <tipbot@zytor.com> - 2015-11-23 17:20 +0100
[PATCH perf/core 05/13] perf: Fix machine__findnew_module_map to put registered map Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> - 2015-11-18 07:50 +0100
Re: [PATCH perf/core 05/13] perf: Fix machine__findnew_module_map to put registered map Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-11-18 23:40 +0100
[tip:perf/core] perf machine: Fix machine__findnew_module_map to put registered map tip-bot for Masami Hiramatsu <tipbot@zytor.com> - 2015-11-23 17:20 +0100
[PATCH perf/core 09/13] perf: Make dso to use refcnt for debug Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> - 2015-11-18 07:50 +0100
[PATCH perf/core 02/13] perf: Make perf_exec_path always returns malloc'd string Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> - 2015-11-18 08:00 +0100
[PATCH perf/core 03/13] perf: Introduce generic refcount APIs with debug feature Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> - 2015-11-18 08:00 +0100
Re: [PATCH perf/core 03/13] perf: Introduce generic refcount APIs with debug feature Namhyung Kim <namhyung@kernel.org> - 2015-11-20 04:00 +0100
RE: [PATCH perf/core 03/13] perf: Introduce generic refcount APIs with debug feature 平松雅巳 / HIRAMATU,MASAMI <masami.hiramatsu.pt@hitachi.com> - 2015-11-20 05:20 +0100
Re: [PATCH perf/core 03/13] perf: Introduce generic refcount APIs with debug feature Namhyung Kim <namhyung@kernel.org> - 2015-11-20 07:00 +0100
Re: [PATCH perf/core 00/13] perf memory/refcnt leak fixes Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-11-18 13:50 +0100
RE: [PATCH perf/core 00/13] perf memory/refcnt leak fixes 平松雅巳 / HIRAMATU,MASAMI <masami.hiramatsu.pt@hitachi.com> - 2015-11-19 04:00 +0100
csiph-web