summaryrefslogtreecommitdiffstats
path: root/runtime/map.c
diff options
context:
space:
mode:
authorhunt <hunt>2005-12-08 18:57:45 +0000
committerhunt <hunt>2005-12-08 18:57:45 +0000
commit99675700179e2a22adf8a9492b73864ff8755add (patch)
treecd2c4a0e84f71d51c5ce3d68c7e44ef38291cb7b /runtime/map.c
parenta2872cffd4ecf7d2ef947cd5b86f9a67f5d2ddcb (diff)
downloadsystemtap-steved-99675700179e2a22adf8a9492b73864ff8755add.tar.gz
systemtap-steved-99675700179e2a22adf8a9492b73864ff8755add.tar.xz
systemtap-steved-99675700179e2a22adf8a9492b73864ff8755add.zip
2005-12-08 Martin Hunt <hunt@redhat.com>
* map.c (_new_map_create): Only increment map size if a node was moved off the free list. (_stp_map_size): New function. (_stp_pmap_size): New function.
Diffstat (limited to 'runtime/map.c')
-rw-r--r--runtime/map.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/runtime/map.c b/runtime/map.c
index fa4150fe..19c02580 100644
--- a/runtime/map.c
+++ b/runtime/map.c
@@ -926,14 +926,13 @@ static struct map_node *_new_map_create (MAP map, struct hlist_head *head)
hlist_del_init(&m->hnode);
} else {
m = (struct map_node *)map->pool.next;
+ map->num++;
dbug ("got %lx off pool\n", (long)m);
}
list_move_tail(&m->lnode, &map->head);
/* add node to new hash list */
hlist_add_head(&m->hnode, head);
-
- map->num++;
return m;
}
@@ -1000,5 +999,31 @@ static int _new_map_set_stat (MAP map, struct map_node *n, int64_t val, int add)
return 0;
}
+/** Return the number of elements in a map
+ * This function will return the number of active elements
+ * in a map.
+ * @param map
+ * @returns an int
+ */
+#define _stp_map_size(map) (map->num)
+
+/** Return the number of elements in a pmap
+ * This function will return the number of active elements
+ * in all the per-cpu maps in a pmap. This is a quick sum and is
+ * not the same as the number of unique elements that would
+ * be in the aggragated map.
+ * @param pmap
+ * @returns an int
+ */
+int _stp_pmap_size (PMAP pmap)
+{
+ int i, num = 0;
+
+ for_each_cpu(i) {
+ MAP m = per_cpu_ptr (pmap->map, i);
+ num += m->num;
+ }
+ return num;
+}
#endif /* _MAP_C_ */