summaryrefslogtreecommitdiffstats
path: root/runtime/map.c
diff options
context:
space:
mode:
authorhunt <hunt>2005-11-11 06:17:29 +0000
committerhunt <hunt>2005-11-11 06:17:29 +0000
commit5176158645ef1076c42252689b29c42b02d511df (patch)
treea541e0fd3596c091af3fc75a72a5ad029a0de875 /runtime/map.c
parent15997cc74dd4e2a17b62d49d45eee410cd0db49c (diff)
downloadsystemtap-steved-5176158645ef1076c42252689b29c42b02d511df.tar.gz
systemtap-steved-5176158645ef1076c42252689b29c42b02d511df.tar.xz
systemtap-steved-5176158645ef1076c42252689b29c42b02d511df.zip
2005-11-10 Martin Hunt <hunt@redhat.com>
* pmap-gen.c (_stp_pmap_get()): New function. Aggregates the per-cpu map nodes into an aggregation map node. * map.c (_stp_new_agg): Return a struct map_node *. (_stp_add_agg): If count is 0 when adding, just set the stats.
Diffstat (limited to 'runtime/map.c')
-rw-r--r--runtime/map.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/runtime/map.c b/runtime/map.c
index f962bfe5..98382b88 100644
--- a/runtime/map.c
+++ b/runtime/map.c
@@ -715,14 +715,14 @@ void _stp_pmap_printn_cpu (MAP map, int n, const char *fmt, int cpu)
_stp_map_printn (m, n, fmt);
}
-static int _stp_new_agg(MAP agg, struct hlist_head *ahead, struct map_node *ptr)
+static struct map_node *_stp_new_agg(MAP agg, struct hlist_head *ahead, struct map_node *ptr)
{
struct map_node *aptr;
/* copy keys and aggregate */
dbug("creating new entry in %lx\n", (long)agg);
aptr = _new_map_create(agg, ahead);
if (aptr == NULL)
- return -1;
+ return NULL;
(*agg->copy)(aptr, ptr);
switch (agg->type) {
case INT64:
@@ -755,7 +755,7 @@ static int _stp_new_agg(MAP agg, struct hlist_head *ahead, struct map_node *ptr)
default:
_stp_error("Attempted to aggregate map of type %d\n", agg->type);
}
- return 0;
+ return aptr;
}
static void _stp_add_agg(struct map_node *aptr, struct map_node *ptr)
@@ -777,12 +777,19 @@ static void _stp_add_agg(struct map_node *aptr, struct map_node *ptr)
stat *sd1 = (stat *)((long)aptr + aptr->map->data_offset);
stat *sd2 = (stat *)((long)ptr + ptr->map->data_offset);
Hist st = &aptr->map->hist;
- sd1->count += sd2->count;
- sd1->sum += sd2->sum;
- if (sd2->min < sd1->min)
+ if (sd1->count == 0) {
+ sd1->count = sd2->count;
sd1->min = sd2->min;
- if (sd2->max > sd1->max)
sd1->max = sd2->max;
+ sd1->sum = sd2->sum;
+ } else {
+ sd1->count += sd2->count;
+ sd1->sum += sd2->sum;
+ if (sd2->min < sd1->min)
+ sd1->min = sd2->min;
+ if (sd2->max > sd1->max)
+ sd1->max = sd2->max;
+ }
if (st->type != HIST_NONE) {
int j;
for (j = 0; j < st->buckets; j++)
@@ -883,7 +890,6 @@ static void _new_map_clear_node (struct map_node *m)
static struct map_node *_new_map_create (MAP map, struct hlist_head *head)
{
struct map_node *m;
- dbug("map=%lx\n", map);
if (list_empty(&map->pool)) {
if (!map->wrap) {
/* ERROR. no space left */