summaryrefslogtreecommitdiffstats
path: root/runtime/stat.c
diff options
context:
space:
mode:
authorhunt <hunt>2005-11-08 19:48:23 +0000
committerhunt <hunt>2005-11-08 19:48:23 +0000
commit7ba70af105ed918b5b07e5bba8b5d27a8d911249 (patch)
treeb33bcea26aa98488bfa987a62764837ae0c39bad /runtime/stat.c
parent4893e4b2858af12d916c3915a97336cdb0c8236b (diff)
downloadsystemtap-steved-7ba70af105ed918b5b07e5bba8b5d27a8d911249.tar.gz
systemtap-steved-7ba70af105ed918b5b07e5bba8b5d27a8d911249.tar.xz
systemtap-steved-7ba70af105ed918b5b07e5bba8b5d27a8d911249.zip
2005-11-08 Martin Hunt <hunt@redhat.com>
* map.c (_stp_map_init): New function. Extracted from _stp_map_new() so it can be used in _stp_pmap_new(). (_stp_map_new): Call _stp_map_init(). (_stp_pmap_new): New function. (_stp_pmap_new_hstat_linear): New function. (_stp_pmap_new_hstat_log): New function. (_stp_pmap_del): New function. (_stp_pmap_printn_cpu): New function. (_stp_pmap_printn): New function. (_stp_new_agg): New function. (_stp_add_agg): New function. (_stp_pmap_agg): New function. (_new_map_clear_node): New function. * map.h (struct map_root): Add Hist struct. Add copy and cmp function pointers for pmaps. * stat.h: Remove Stat struct. Replace with Hist struct that is limited to only histogram params. * map-stat.c: Fix up references to histogram params in map_root. * stat-common.c: Ditto. * stat.c: Ditto. * pmap-gen.c: New file. Implements per-cpu maps. * map-gen.c: Minor bug fixes. Use new VAL_IS_ZERO() macro. * alloc.c (vmalloc_node): For NUMA, provide a vmalloc that does node-local allocations. (_stp_alloc_cpu): A version of _stp_alloc() that does node-local allocations. (_stp_valloc): A version of _stp_valloc() that does node-local allocations. (__stp_valloc_percpu): New function. Like alloc_percpu() except uses _stp_valloc(). (_stp_vfree_percpu): New function. Like free_percpu().
Diffstat (limited to 'runtime/stat.c')
-rw-r--r--runtime/stat.c66
1 files changed, 39 insertions, 27 deletions
diff --git a/runtime/stat.c b/runtime/stat.c
index b0ae90d1..c759a043 100644
--- a/runtime/stat.c
+++ b/runtime/stat.c
@@ -48,6 +48,18 @@
#define STAT_UNLOCK(st) ;
#endif
+/** Stat struct for stat.c. Maps do not need this */
+struct _Stat {
+ struct _Hist hist;
+ /* per-cpu data. allocated with alloc_percpu() */
+ stat *sd;
+ /* aggregated data */
+ stat *agg;
+};
+
+typedef struct _Stat *Stat;
+
+
/** Initialize a Stat.
* Call this during probe initialization to create a Stat.
*
@@ -64,7 +76,7 @@
Stat _stp_stat_init (int type, ...)
{
int size, buckets=0, start=0, stop=0, interval=0;
- struct stat_data *sd, *agg;
+ stat *sd, *agg;
Stat st;
if (type != HIST_NONE) {
@@ -87,8 +99,8 @@ Stat _stp_stat_init (int type, ...)
if (st == NULL)
return NULL;
- size = buckets * sizeof(int64_t) + sizeof(struct stat_data);
- sd = (struct stat_data *) __alloc_percpu (size, 8);
+ size = buckets * sizeof(int64_t) + sizeof(stat);
+ sd = (stat *) __alloc_percpu (size, 8);
if (sd == NULL)
goto exit1;
@@ -96,21 +108,21 @@ Stat _stp_stat_init (int type, ...)
{
int i;
for_each_cpu(i) {
- struct stat_data *sdp = per_cpu_ptr (sd, i);
+ stat *sdp = per_cpu_ptr (sd, i);
sdp->lock = SPIN_LOCK_UNLOCKED;
}
}
#endif
- agg = (struct stat_data *)kmalloc (size, GFP_KERNEL);
+ agg = (stat *)kmalloc (size, GFP_KERNEL);
if (agg == NULL)
goto exit2;
- st->hist_type = type;
- st->hist_start = start;
- st->hist_stop = stop;
- st->hist_int = interval;
- st->hist_buckets = buckets;
+ st->hist.type = type;
+ st->hist.start = start;
+ st->hist.stop = stop;
+ st->hist.interval = interval;
+ st->hist.buckets = buckets;
st->sd = sd;
st->agg = agg;
return st;
@@ -130,9 +142,9 @@ exit1:
*/
void _stp_stat_add (Stat st, int64_t val)
{
- struct stat_data *sd = per_cpu_ptr (st->sd, get_cpu());
+ stat *sd = per_cpu_ptr (st->sd, get_cpu());
STAT_LOCK(sd);
- __stp_stat_add (st, sd, val);
+ __stp_stat_add (&st->hist, sd, val);
STAT_UNLOCK(sd);
put_cpu();
}
@@ -145,21 +157,21 @@ void _stp_stat_add (Stat st, int64_t val)
*
* @param st Stat
* @param cpu CPU number
- * @returns A pointer to a struct stat_data.
+ * @returns A pointer to a stat.
*/
-struct stat_data *_stp_stat_get_cpu (Stat st, int cpu)
+stat *_stp_stat_get_cpu (Stat st, int cpu)
{
- struct stat_data *sd = per_cpu_ptr (st->sd, cpu);
+ stat *sd = per_cpu_ptr (st->sd, cpu);
STAT_LOCK(sd);
return sd;
}
-static void _stp_stat_clear_data (Stat st, struct stat_data *sd)
+static void _stp_stat_clear_data (Stat st, stat *sd)
{
int j;
sd->count = sd->sum = sd->min = sd->max = 0;
- if (st->hist_type != HIST_NONE) {
- for (j = 0; j < st->hist_buckets; j++)
+ if (st->hist.type != HIST_NONE) {
+ for (j = 0; j < st->hist.buckets; j++)
sd->histogram[j] = 0;
}
}
@@ -173,17 +185,17 @@ static void _stp_stat_clear_data (Stat st, struct stat_data *sd)
* @param st Stat
* @param clear Set if you want the data cleared after the read. Useful
* for polling.
- * @returns A pointer to a struct stat_data.
+ * @returns A pointer to a stat.
*/
-struct stat_data *_stp_stat_get (Stat st, int clear)
+stat *_stp_stat_get (Stat st, int clear)
{
int i, j;
- struct stat_data *agg = st->agg;
+ stat *agg = st->agg;
STAT_LOCK(agg);
_stp_stat_clear_data (st, agg);
for_each_cpu(i) {
- struct stat_data *sd = per_cpu_ptr (st->sd, i);
+ stat *sd = per_cpu_ptr (st->sd, i);
STAT_LOCK(sd);
if (sd->count) {
if (agg->count == 0) {
@@ -196,8 +208,8 @@ struct stat_data *_stp_stat_get (Stat st, int clear)
agg->max = sd->max;
if (sd->min < agg->min)
agg->min = sd->min;
- if (st->hist_type != HIST_NONE) {
- for (j = 0; j < st->hist_buckets; j++)
+ if (st->hist.type != HIST_NONE) {
+ for (j = 0; j < st->hist.buckets; j++)
agg->histogram[j] += sd->histogram[j];
}
if (clear)
@@ -209,13 +221,13 @@ struct stat_data *_stp_stat_get (Stat st, int clear)
}
-static void __stp_stat_print (char *fmt, Stat st, struct stat_data *sd, int cpu)
+static void __stp_stat_print (char *fmt, Stat st, stat *sd, int cpu)
{
int num;
char *f = (char *)fmt;
while (*f) {
f = next_fmt (f, &num);
- _stp_stat_print_valtype (f, st, sd, cpu);
+ _stp_stat_print_valtype (f, &st->hist, sd, cpu);
if (*f)
f++;
}
@@ -235,7 +247,7 @@ void _stp_stat_print_cpu (Stat st, char *fmt, int clear)
{
int i;
for_each_cpu(i) {
- struct stat_data *sd = per_cpu_ptr (st->sd, i);
+ stat *sd = per_cpu_ptr (st->sd, i);
STAT_LOCK(sd);
__stp_stat_print (fmt, st, sd, i);
if (clear)