[PATCH perf/core v10 17/23] perf: probe-cache: Add for_each_probe_cache_entry() wrapper

From: Masami Hiramatsu
Date: Wed Jun 08 2016 - 05:32:09 EST


Add for_each_probe_cache_entry() wrapper macro
for hiding list in probe_cache.

Signed-off-by: Masami Hiramatsu <mhiramat@xxxxxxxxxx>
---
Changes in v10:
- Splitted from "perf probe: Allow wildcard for cached events"
---
tools/perf/util/probe-file.c | 8 ++++----
tools/perf/util/probe-file.h | 2 ++
2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c
index 4d8ba72..7b60380 100644
--- a/tools/perf/util/probe-file.c
+++ b/tools/perf/util/probe-file.c
@@ -537,7 +537,7 @@ probe_cache__find(struct probe_cache *pcache, struct perf_probe_event *pev)
if (!cmd)
return NULL;

- list_for_each_entry(entry, &pcache->list, list) {
+ for_each_probe_cache_entry(entry, pcache) {
if (pev->sdt) {
if (entry->pev.event &&
streql(entry->pev.event, pev->event) &&
@@ -567,7 +567,7 @@ probe_cache__find_by_name(struct probe_cache *pcache,
{
struct probe_cache_entry *entry = NULL;

- list_for_each_entry(entry, &pcache->list, list) {
+ for_each_probe_cache_entry(entry, pcache) {
/* Hit if same event name or same command-string */
if (streql(entry->pev.group, group) &&
streql(entry->pev.event, event))
@@ -720,7 +720,7 @@ int probe_cache__commit(struct probe_cache *pcache)
if (ret < 0)
goto out;

- list_for_each_entry(entry, &pcache->list, list) {
+ for_each_probe_cache_entry(entry, pcache) {
ret = probe_cache_entry__write(entry, pcache->fd);
pr_debug("Cache committed: %d\n", ret);
if (ret < 0)
@@ -761,7 +761,7 @@ static int probe_cache__show_entries(struct probe_cache *pcache,
{
struct probe_cache_entry *entry;

- list_for_each_entry(entry, &pcache->list, list) {
+ for_each_probe_cache_entry(entry, pcache) {
if (probe_cache_entry__compare(entry, filter))
printf("%s\n", entry->spev);
}
diff --git a/tools/perf/util/probe-file.h b/tools/perf/util/probe-file.h
index ce98162..6271ec6 100644
--- a/tools/perf/util/probe-file.h
+++ b/tools/perf/util/probe-file.h
@@ -21,6 +21,8 @@ struct probe_cache {

#define PF_FL_UPROBE 1
#define PF_FL_RW 2
+#define for_each_probe_cache_entry(entry, pcache) \
+ list_for_each_entry(entry, &pcache->list, list)

/* probe-file.c depends on libelf */
#ifdef HAVE_LIBELF_SUPPORT