#define MAP_GET_VAL(n) _stp_get_int64(n)
#define NULLRET (int64_t)0
#elif VALUE_TYPE == STAT
-#define VALTYPE stat*
+#define VALTYPE stat_data*
#define VSTYPE int64_t
-#define VALNAME stat
+#define VALNAME stat_data
#define VALN x
#define MAP_SET_VAL(a,b,c,d) _new_map_set_stat(a,b,c,d)
#define MAP_GET_VAL(n) _stp_get_stat(n)
-#define NULLRET (stat*)0
+#define NULLRET (stat_data*)0
#else
#error Need to define VALUE_TYPE as STRING, STAT, or INT64
#endif /* VALUE_TYPE */
#include "stat-common.c"
-static void _stp_map_print_histogram (MAP map, stat *sd)
+static void _stp_map_print_histogram (MAP map, stat_data *sd)
{
_stp_stat_print_histogram (&map->hist, sd);
}
static MAP _stp_map_new_hstat_log (unsigned max_entries, int key_size)
{
/* add size for buckets */
- int size = HIST_LOG_BUCKETS * sizeof(int64_t) + sizeof(stat);
+ int size = HIST_LOG_BUCKETS * sizeof(int64_t) + sizeof(stat_data);
MAP m = _stp_map_new (max_entries, STAT, key_size, size);
if (m) {
m->hist.type = HIST_LOG;
return NULL;
/* add size for buckets */
- size = buckets * sizeof(int64_t) + sizeof(stat);
+ size = buckets * sizeof(int64_t) + sizeof(stat_data);
m = _stp_map_new (max_entries, STAT, ksize, size);
if (m) {
return NULL;
/* add size for buckets */
- size = buckets * sizeof(int64_t) + sizeof(stat);
+ size = buckets * sizeof(int64_t) + sizeof(stat_data);
pmap = _stp_pmap_new (max_entries, STAT, ksize, size);
if (pmap) {
static PMAP _stp_pmap_new_hstat_log (unsigned max_entries, int key_size)
{
/* add size for buckets */
- int size = HIST_LOG_BUCKETS * sizeof(int64_t) + sizeof(stat);
+ int size = HIST_LOG_BUCKETS * sizeof(int64_t) + sizeof(stat_data);
PMAP pmap = _stp_pmap_new (max_entries, STAT, key_size, size);
if (pmap) {
int i;
static int map_sizes[] = {
sizeof(int64_t),
MAP_STRING_LENGTH,
- sizeof(stat),
+ sizeof(stat_data),
0
};
* @param m pointer to the map_node.
* @returns A pointer to the stats.
*/
-static stat *_stp_get_stat(struct map_node *m)
+static stat_data *_stp_get_stat(struct map_node *m)
{
if (!m || m->map->type != STAT)
return 0;
- return (stat *)((long)m + m->map->data_offset);
+ return (stat_data *)((long)m + m->map->data_offset);
}
/** Return an int64 key from a map node.
a = _stp_key_get_int64(m1, keynum);
b = _stp_key_get_int64(m2, keynum);
} else if (keynum < 0) {
- stat *sd1 = (stat *)((long)m1 + m1->map->data_offset);
- stat *sd2 = (stat *)((long)m2 + m2->map->data_offset);
+ stat_data *sd1 = (stat_data *)((long)m1 + m1->map->data_offset);
+ stat_data *sd2 = (stat_data *)((long)m2 + m2->map->data_offset);
switch (keynum) {
case SORT_COUNT:
a = sd1->count;
0);
break;
case STAT: {
- stat *sd1 = (stat *)((long)aptr + agg->data_offset);
- stat *sd2 = (stat *)((long)ptr + ptr->map->data_offset);
+ stat_data *sd1 = (stat_data *)((long)aptr + agg->data_offset);
+ stat_data *sd2 = (stat_data *)((long)ptr + ptr->map->data_offset);
Hist st = &agg->hist;
sd1->count = sd2->count;
sd1->sum = sd2->sum;
1);
break;
case STAT: {
- stat *sd1 = (stat *)((long)aptr + aptr->map->data_offset);
- stat *sd2 = (stat *)((long)ptr + ptr->map->data_offset);
+ stat_data *sd1 = (stat_data *)((long)aptr + aptr->map->data_offset);
+ stat_data *sd2 = (stat_data *)((long)ptr + ptr->map->data_offset);
Hist st = &aptr->map->hist;
if (sd1->count == 0) {
sd1->count = sd2->count;
break;
case STAT:
{
- stat *sd = (stat *)((long)m + m->map->data_offset);
+ stat_data *sd = (stat_data *)((long)m + m->map->data_offset);
Hist st = &m->map->hist;
sd->count = 0;
if (st->type != HIST_NONE) {
static int _new_map_set_stat (MAP map, struct map_node *n, int64_t val, int add)
{
- stat *sd;
+ stat_data *sd;
if (map == NULL || n == NULL)
return -2;
- sd = (stat *)((long)n + map->data_offset);
+ sd = (stat_data *)((long)n + map->data_offset);
if (!add) {
Hist st = &map->hist;
sd->count = 0;
void int64_copy(void *dest, int64_t val);
void int64_add(void *dest, int64_t val);
int64_t int64_get(void *ptr);
-void stat_copy(void *dest, stat *src);
-void stat_add(void *dest, stat *src);
-stat *stat_get(void *ptr);
+void stat_copy(void *dest, stat_data *src);
+void stat_add(void *dest, stat_data *src);
+stat_data *stat_get(void *ptr);
static int64_t _stp_key_get_int64(struct map_node *mn, int n);
static char * _stp_key_get_str(struct map_node *mn, int n);
static unsigned int int64_hash(const int64_t v);
static int str_eq_p(char *key1, char *key2);
static int64_t _stp_get_int64(struct map_node *m);
static char * _stp_get_str(struct map_node *m);
-static stat *_stp_get_stat(struct map_node *m);
+static stat_data *_stp_get_stat(struct map_node *m);
static unsigned int str_hash(const char *key1);
static MAP _stp_map_new(unsigned max_entries, int type, int key_size, int data_size);
static PMAP _stp_pmap_new(unsigned max_entries, int type, int key_size, int data_size);
static int msb64(int64_t x);
static MAP _stp_map_new_hstat_log(unsigned max_entries, int key_size);
static MAP _stp_map_new_hstat_linear(unsigned max_entries, int ksize, int start, int stop, int interval);
-static void _stp_map_print_histogram(MAP map, stat *s);
+static void _stp_map_print_histogram(MAP map, stat_data *s);
static struct map_node * _stp_map_start(MAP map);
static struct map_node * _stp_map_iter(MAP map, struct map_node *m);
static void _stp_map_del(MAP map);
#define MAP_GET_VAL(n) _stp_get_int64(n)
#define NULLRET (int64_t)0
#elif VALUE_TYPE == STAT
-#define VALTYPE stat*
+#define VALTYPE stat_data*
#define VSTYPE int64_t
-#define VALNAME stat
+#define VALNAME stat_data
#define VALN x
#define MAP_SET_VAL(a,b,c,d) _new_map_set_stat(a,b,c,d)
#define MAP_GET_VAL(n) _stp_get_stat(n)
-#define NULLRET (stat*)0
+#define NULLRET (stat_data*)0
#else
#error Need to define VALUE_TYPE as STRING, STAT, or INT64
#endif /* VALUE_TYPE */
#endif
-static void _stp_stat_print_histogram_buf(char *buf, size_t size, Hist st, stat *sd)
+static void _stp_stat_print_histogram_buf(char *buf, size_t size, Hist st,
+ stat_data *sd)
{
int scale, i, j, val_space, cnt_space;
int low_bucket = -1, high_bucket = 0, over = 0, under = 0;
#undef HIST_PRINTF
}
-static void _stp_stat_print_histogram(Hist st, stat *sd)
+static void _stp_stat_print_histogram(Hist st, stat_data *sd)
{
_stp_stat_print_histogram_buf(NULL, 0, st, sd);
_stp_print_flush();
}
-static void __stp_stat_add(Hist st, stat *sd, int64_t val)
+static void __stp_stat_add(Hist st, stat_data *sd, int64_t val)
{
int n;
if (sd->count == 0) {
/* for the paranoid. */
#if NEED_STAT_LOCKS == 1
-#define STAT_LOCK(st) spin_lock(&st->lock)
-#define STAT_UNLOCK(st) spin_unlock(&st->lock)
+#define STAT_LOCK(sd) spin_lock(&sd->lock)
+#define STAT_UNLOCK(sd) spin_unlock(&sd->lock)
#else
-#define STAT_LOCK(st) ;
-#define STAT_UNLOCK(st) ;
+#define STAT_LOCK(sd) ;
+#define STAT_UNLOCK(sd) ;
#endif
/** Stat struct for stat.c. Maps do not need this */
struct _Stat {
struct _Hist hist;
/* per-cpu data. allocated with _stp_alloc_percpu() */
- stat *sd;
+ stat_data *sd;
/* aggregated data */
- stat *agg;
+ stat_data *agg;
};
typedef struct _Stat *Stat;
static Stat _stp_stat_init (int type, ...)
{
int size, buckets=0, start=0, stop=0, interval=0;
- stat *sd, *agg;
+ stat_data *sd, *agg;
Stat st;
if (type != HIST_NONE) {
if (st == NULL)
return NULL;
- size = buckets * sizeof(int64_t) + sizeof(stat);
- sd = (stat *) _stp_alloc_percpu (size);
+ size = buckets * sizeof(int64_t) + sizeof(stat_data);
+ sd = (stat_data *) _stp_alloc_percpu (size);
if (sd == NULL)
goto exit1;
{
int i;
for_each_possible_cpu(i) {
- stat *sdp = per_cpu_ptr (sd, i);
+ stat_data *sdp = per_cpu_ptr (sd, i);
spin_lock_init(sdp->lock);
}
}
#endif
- agg = (stat *)_stp_kmalloc_gfp(size, STP_ALLOC_SLEEP_FLAGS);
+ agg = (stat_data *)_stp_kmalloc_gfp(size, STP_ALLOC_SLEEP_FLAGS);
if (agg == NULL)
goto exit2;
*/
static void _stp_stat_add (Stat st, int64_t val)
{
- stat *sd = per_cpu_ptr (st->sd, get_cpu());
+ stat_data *sd = per_cpu_ptr (st->sd, get_cpu());
STAT_LOCK(sd);
__stp_stat_add (&st->hist, sd, val);
STAT_UNLOCK(sd);
* @param cpu CPU number
* @returns A pointer to a stat.
*/
-static stat *_stp_stat_get_cpu (Stat st, int cpu)
+static stat_data *_stp_stat_get_cpu (Stat st, int cpu)
{
- stat *sd = per_cpu_ptr (st->sd, cpu);
+ stat_data *sd = per_cpu_ptr (st->sd, cpu);
STAT_LOCK(sd);
return sd;
}
-static void _stp_stat_clear_data (Stat st, stat *sd)
+static void _stp_stat_clear_data (Stat st, stat_data *sd)
{
int j;
sd->count = sd->sum = sd->min = sd->max = 0;
* for polling.
* @returns A pointer to a stat.
*/
-static stat *_stp_stat_get (Stat st, int clear)
+static stat_data *_stp_stat_get (Stat st, int clear)
{
int i, j;
- stat *agg = st->agg;
+ stat_data *agg = st->agg;
STAT_LOCK(agg);
_stp_stat_clear_data (st, agg);
for_each_possible_cpu(i) {
- stat *sd = per_cpu_ptr (st->sd, i);
+ stat_data *sd = per_cpu_ptr (st->sd, i);
STAT_LOCK(sd);
if (sd->count) {
if (agg->count == 0) {
{
int i;
for_each_possible_cpu(i) {
- stat *sd = per_cpu_ptr (st->sd, i);
+ stat_data *sd = per_cpu_ptr (st->sd, i);
STAT_LOCK(sd);
_stp_stat_clear_data (st, sd);
STAT_UNLOCK(sd);
#endif
int64_t histogram[];
};
-typedef struct stat_data stat;
+typedef struct stat_data stat_data;
/** Information about the histogram data collected. This data
is global and not duplicated per-cpu. */