lkml.org 
[lkml]   [2010]   [Aug]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Date
Subject[PATCHv11 2.6.36-rc2-tip 13/15] 13: perf: Loop thro each of the maps in a map_group.

Introduces map_groups_for_each_map that iterates over a map_group.
This is useful while listing functions through perf-probe.

Signed-off-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Suggested-by: Arnaldo Carvalho de Melo <acme@infradead.org>
---
tools/perf/util/map.h | 27 +++++++++++++++++++++++++++
1 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h
index 7857579..45b5f50 100644
--- a/tools/perf/util/map.h
+++ b/tools/perf/util/map.h
@@ -54,6 +54,33 @@ struct map_groups {
struct machine *machine;
};

+/* For map_groups iteration */
+static inline struct map *map__first(struct map_groups *self,
+ enum map_type type)
+{
+ struct rb_node *rn = rb_first(&self->maps[type]);
+ return rn ? rb_entry(rn, struct map, rb_node) : NULL;
+}
+
+static inline struct map *map__next(struct map *map)
+{
+ struct rb_node *rn;
+ if (!map)
+ return NULL;
+ rn = rb_next(&map->rb_node);
+ return rn ? rb_entry(rn, struct map, rb_node) : NULL;
+}
+
+/**
+ * map_groups__for_each_map - iterate over a map_group
+ * @pos: the &struct map to use as a loop cursor.
+ * @type: the map type.
+ * @self: the &struct map_groups for loop.
+ */
+#define map_groups__for_each_map(pos, type, self) \
+ for (pos = map__first(self, type); pos; \
+ pos = map__next(pos))
+
/* Native host kernel uses -1 as pid index in machine */
#define HOST_KERNEL_ID (-1)
#define DEFAULT_GUEST_KERNEL_ID (0)

\
 
 \ /
  Last update: 2010-08-25 15:53    [W:0.237 / U:2.024 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site