diff options
author | hunt <hunt> | 2005-11-11 06:17:29 +0000 |
---|---|---|
committer | hunt <hunt> | 2005-11-11 06:17:29 +0000 |
commit | 5176158645ef1076c42252689b29c42b02d511df (patch) | |
tree | a541e0fd3596c091af3fc75a72a5ad029a0de875 /runtime | |
parent | 15997cc74dd4e2a17b62d49d45eee410cd0db49c (diff) | |
download | systemtap-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')
-rw-r--r-- | runtime/ChangeLog | 11 | ||||
-rw-r--r-- | runtime/map.c | 22 | ||||
-rw-r--r-- | runtime/map.h | 2 | ||||
-rw-r--r-- | runtime/pmap-gen.c | 33 |
4 files changed, 44 insertions, 24 deletions
diff --git a/runtime/ChangeLog b/runtime/ChangeLog index dff894b4..4376fd78 100644 --- a/runtime/ChangeLog +++ b/runtime/ChangeLog @@ -1,5 +1,16 @@ 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. + +2005-11-10 Martin Hunt <hunt@redhat.com> * map.c: Doc updates. + (_stp_new_agg): + * pmap-gen.c: Change a bunch of generated function names to avoid conflicts with maps with the same key and value types. 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 */ diff --git a/runtime/map.h b/runtime/map.h index 08c06a1e..3a1b01c5 100644 --- a/runtime/map.h +++ b/runtime/map.h @@ -241,6 +241,8 @@ static void _new_map_clear_node (struct map_node *); static void _new_map_del_node (MAP map, struct map_node *n); static MAP _stp_pmap_new_hstat_linear (unsigned max_entries, int ksize, int start, int stop, int interval); static MAP _stp_pmap_new_hstat_log (unsigned max_entries, int key_size, int buckets); +static void _stp_add_agg(struct map_node *aptr, struct map_node *ptr); +static struct map_node *_stp_new_agg(MAP agg, struct hlist_head *ahead, struct map_node *ptr); /* these prototypes suppress warnings from macros */ void _stp_map_key_str(MAP, char *); diff --git a/runtime/pmap-gen.c b/runtime/pmap-gen.c index 0d05fedc..038eba62 100644 --- a/runtime/pmap-gen.c +++ b/runtime/pmap-gen.c @@ -426,7 +426,7 @@ MAP KEYSYM(_stp_pmap_new) (unsigned max_entries) MAP KEYSYM(_stp_pmap_new) (unsigned max_entries, int htype, ...) { int buckets=0, start=0, stop=0, interval=0; - MAP m, map; + MAP map; va_list ap; if (htype != HIST_NONE) { @@ -597,14 +597,14 @@ VALTYPE KEYSYM(_stp_pmap_get_cpu) (MAP pmap, ALLKEYSD(key)) #endif } -#if 0 VALTYPE KEYSYM(_stp_pmap_get) (MAP pmap, ALLKEYSD(key)) { unsigned int hv; - struct hlist_head *head; + int cpu; + struct hlist_head *head, *ahead; struct hlist_node *e; - struct KEYSYM(pmap_node) *n, *anode = NULL; - VALTYPE res; + struct KEYSYM(pmap_node) *n; + struct map_node *anode = NULL; MAP map, agg; if (pmap == NULL) @@ -617,7 +617,6 @@ VALTYPE KEYSYM(_stp_pmap_get) (MAP pmap, ALLKEYSD(key)) ahead = &agg->hashes[hv]; hlist_for_each(e, ahead) { n = (struct KEYSYM(pmap_node) *)((long)e - sizeof(struct list_head)); - dbug("map_node =%lx\n", (long)n); if (KEY1_EQ_P(n->key1, key1) #if KEY_ARITY > 1 && KEY2_EQ_P(n->key2, key2) @@ -632,19 +631,18 @@ VALTYPE KEYSYM(_stp_pmap_get) (MAP pmap, ALLKEYSD(key)) #endif #endif ) { - anode = n; + anode = (struct map_node *)n; + _new_map_clear_node (anode); break; } } - if (anode) - return MAP_SET_VAL(map,(struct map_node *)n, val, 0); + /* now total each cpu */ for_each_cpu(cpu) { - map = per_cpu_ptr (pmap, get_cpu()); + map = per_cpu_ptr (pmap, cpu); head = &map->hashes[hv]; hlist_for_each(e, head) { n = (struct KEYSYM(pmap_node) *)((long)e - sizeof(struct list_head)); - dbug("map_node =%lx\n", (long)n); if (KEY1_EQ_P(n->key1, key1) #if KEY_ARITY > 1 && KEY2_EQ_P(n->key2, key2) @@ -659,21 +657,24 @@ VALTYPE KEYSYM(_stp_pmap_get) (MAP pmap, ALLKEYSD(key)) #endif #endif ) { - res = MAP_GET_VAL((struct map_node *)n); - put_cpu(); - return res; + if (anode == NULL) { + dbug("agg=%lx ahead=%lx\n", (long)agg, (long)ahead); + anode = _stp_new_agg(agg, ahead, (struct map_node *)n); + } else + _stp_add_agg(anode, (struct map_node *)n); } } } + if (anode) + return MAP_GET_VAL(anode); + /* key not found */ - put_cpu(); #if VALUE_TYPE == STRING return ""; #else return (VALTYPE)0; #endif } -#endif /* 0 */ #undef KEY1NAME #undef KEY1N |