From: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
To: 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-perf-users@vger.kernel.org,
Ingo Molnar <mingo@redhat.com>,
Namhyung Kim <namhyung@kernel.org>, Jiri Olsa <jolsa@redhat.com>
Subject: [PATCH perf/core 03/22] perf refcnt: Add refcnt debug filter
Date: Wed, 09 Dec 2015 11:10:55 +0900 [thread overview]
Message-ID: <20151209021054.10245.25855.stgit@localhost.localdomain> (raw)
In-Reply-To: <20151209021047.10245.8918.stgit@localhost.localdomain>
Add refcnt debug filter for filtering the debug objects.
Developers can set the target object name (or glob pattern)
to PERF_REFCNT_DEBUG_FILTER environment variable.
E.g.
# PERF_REFCNT_DEBUG_FILTER=dso ./perf ...
This traces only the dso object. This also removes
unused name arguments from refcnt__record API.
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
---
tools/perf/util/refcnt.c | 29 ++++++++++++++++++-----------
tools/perf/util/refcnt.h | 14 +++++++-------
2 files changed, 25 insertions(+), 18 deletions(-)
diff --git a/tools/perf/util/refcnt.c b/tools/perf/util/refcnt.c
index 9748dba..e83e9a8 100644
--- a/tools/perf/util/refcnt.c
+++ b/tools/perf/util/refcnt.c
@@ -16,13 +16,20 @@
/* A root of backtraces (a hash table of the list of refcnt_object)*/
static struct list_head refcnt_root[REFCNT_HASHSZ];
+static const char *refcnt_filter;
static void __attribute__((constructor)) refcnt__init_root(void)
{
int h;
+ const char *filter;
for (h = 0; h < REFCNT_HASHSZ; h++)
INIT_LIST_HEAD(&refcnt_root[h]);
+
+ /* glob matching filter */
+ filter = getenv("PERF_REFCNT_DEBUG_FILTER");
+ if (filter && *filter)
+ refcnt_filter = filter;
}
static void refcnt_object__delete(struct refcnt_object *ref)
@@ -54,11 +61,9 @@ void refcnt__delete(void *addr)
{
struct refcnt_object *ref = refcnt_object__find(addr);
- if (!ref) {
- pr_debug("REFCNT: Delete uninitialized refcnt: %p\n", addr);
- return;
- }
- refcnt_object__delete(ref);
+ /* If !ref, it is already filtered out */
+ if (ref)
+ refcnt_object__delete(ref);
}
static void refcnt_object__record(struct refcnt_object *ref, int count)
@@ -98,21 +103,23 @@ static struct refcnt_object *refcnt_object__new(void *obj, const char *name)
/* This is called via refcnt__init */
void refcnt__recordnew(void *obj, const char *name, int count)
{
- struct refcnt_object *ref = refcnt_object__new(obj, name);
+ struct refcnt_object *ref;
+
+ if (refcnt_filter && !strglobmatch(name, refcnt_filter))
+ return;
+ ref = refcnt_object__new(obj, name);
if (ref)
refcnt_object__record(ref, count);
}
/* This is called via refcnt__get/put */
-void refcnt__record(void *obj, const char *name, int count)
+void refcnt__record(void *obj, int count)
{
struct refcnt_object *ref = refcnt_object__find(obj);
- /* If no entry, allocate new one */
- if (!ref)
- refcnt__recordnew(obj, name, count);
- else
+ /* If no entry, it should be filtered out */
+ if (ref)
refcnt_object__record(ref, count);
}
diff --git a/tools/perf/util/refcnt.h b/tools/perf/util/refcnt.h
index cd5e4e4..21569e1 100644
--- a/tools/perf/util/refcnt.h
+++ b/tools/perf/util/refcnt.h
@@ -24,7 +24,7 @@ struct refcnt_buffer {
};
void refcnt__recordnew(void *obj, const char *name, int count);
-void refcnt__record(void *obj, const char *name, int count);
+void refcnt__record(void *obj, int count);
void refcnt__delete(void *obj);
static inline void __refcnt__init(atomic_t *refcnt, int n, void *obj,
@@ -34,15 +34,15 @@ static inline void __refcnt__init(atomic_t *refcnt, int n, void *obj,
refcnt__recordnew(obj, name, n);
}
-static inline void __refcnt__get(atomic_t *refcnt, void *obj, const char *name)
+static inline void __refcnt__get(atomic_t *refcnt, void *obj)
{
atomic_inc(refcnt);
- refcnt__record(obj, name, atomic_read(refcnt));
+ refcnt__record(obj, atomic_read(refcnt));
}
-static inline int __refcnt__put(atomic_t *refcnt, void *obj, const char *name)
+static inline int __refcnt__put(atomic_t *refcnt, void *obj)
{
- refcnt__record(obj, name, -atomic_read(refcnt));
+ refcnt__record(obj, -atomic_read(refcnt));
return atomic_dec_and_test(refcnt);
}
@@ -53,9 +53,9 @@ static inline int __refcnt__put(atomic_t *refcnt, void *obj, const char *name)
#define refcnt__exit(obj, member) \
refcnt__delete(obj)
#define refcnt__get(obj, member) \
- __refcnt__get(&(obj)->member, obj, #obj)
+ __refcnt__get(&(obj)->member, obj)
#define refcnt__put(obj, member) \
- __refcnt__put(&(obj)->member, obj, #obj)
+ __refcnt__put(&(obj)->member, obj)
#else /* !REFCNT_DEBUG */
next prev parent reply other threads:[~2015-12-09 2:10 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 ` Masami Hiramatsu [this message]
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)
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=20151209021054.10245.25855.stgit@localhost.localdomain \
--to=masami.hiramatsu.pt@hitachi.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--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).