2012-09-17 16:31:14 +08:00
|
|
|
#ifndef __PERF_STATS_H
|
|
|
|
#define __PERF_STATS_H
|
|
|
|
|
2014-04-26 03:31:02 +08:00
|
|
|
#include <linux/types.h>
|
2015-06-03 22:25:59 +08:00
|
|
|
#include <stdio.h>
|
2015-06-26 17:29:10 +08:00
|
|
|
#include "xyarray.h"
|
2012-09-17 16:31:14 +08:00
|
|
|
|
|
|
|
struct stats
|
|
|
|
{
|
|
|
|
double n, mean, M2;
|
2013-08-03 04:05:40 +08:00
|
|
|
u64 max, min;
|
2012-09-17 16:31:14 +08:00
|
|
|
};
|
|
|
|
|
2015-06-04 21:50:55 +08:00
|
|
|
enum perf_stat_evsel_id {
|
|
|
|
PERF_STAT_EVSEL_ID__NONE = 0,
|
2015-06-03 22:25:52 +08:00
|
|
|
PERF_STAT_EVSEL_ID__CYCLES_IN_TX,
|
|
|
|
PERF_STAT_EVSEL_ID__TRANSACTION_START,
|
|
|
|
PERF_STAT_EVSEL_ID__ELISION_START,
|
|
|
|
PERF_STAT_EVSEL_ID__CYCLES_IN_TX_CP,
|
2015-06-04 21:50:55 +08:00
|
|
|
PERF_STAT_EVSEL_ID__MAX,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct perf_stat {
|
|
|
|
struct stats res_stats[3];
|
|
|
|
enum perf_stat_evsel_id id;
|
|
|
|
};
|
|
|
|
|
2015-06-03 22:25:59 +08:00
|
|
|
enum aggr_mode {
|
|
|
|
AGGR_NONE,
|
|
|
|
AGGR_GLOBAL,
|
|
|
|
AGGR_SOCKET,
|
|
|
|
AGGR_CORE,
|
|
|
|
};
|
|
|
|
|
2015-06-26 17:29:09 +08:00
|
|
|
struct perf_counts_values {
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
u64 val;
|
|
|
|
u64 ena;
|
|
|
|
u64 run;
|
|
|
|
};
|
|
|
|
u64 values[3];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
struct perf_counts {
|
|
|
|
s8 scaled;
|
|
|
|
struct perf_counts_values aggr;
|
2015-06-26 17:29:10 +08:00
|
|
|
struct xyarray *cpu;
|
2015-06-26 17:29:09 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline struct perf_counts_values*
|
2015-06-26 17:29:11 +08:00
|
|
|
perf_counts(struct perf_counts *counts, int cpu, int thread)
|
2015-06-26 17:29:09 +08:00
|
|
|
{
|
2015-06-26 17:29:11 +08:00
|
|
|
return xyarray__entry(counts->cpu, cpu, thread);
|
2015-06-26 17:29:09 +08:00
|
|
|
}
|
|
|
|
|
2012-09-17 16:31:14 +08:00
|
|
|
void update_stats(struct stats *stats, u64 val);
|
|
|
|
double avg_stats(struct stats *stats);
|
|
|
|
double stddev_stats(struct stats *stats);
|
|
|
|
double rel_stddev_stats(double stddev, double avg);
|
|
|
|
|
2013-08-03 04:05:40 +08:00
|
|
|
static inline void init_stats(struct stats *stats)
|
|
|
|
{
|
|
|
|
stats->n = 0.0;
|
|
|
|
stats->mean = 0.0;
|
|
|
|
stats->M2 = 0.0;
|
|
|
|
stats->min = (u64) -1;
|
|
|
|
stats->max = 0;
|
|
|
|
}
|
2015-06-04 21:50:55 +08:00
|
|
|
|
|
|
|
struct perf_evsel;
|
|
|
|
bool __perf_evsel_stat__is(struct perf_evsel *evsel,
|
|
|
|
enum perf_stat_evsel_id id);
|
|
|
|
|
|
|
|
#define perf_stat_evsel__is(evsel, id) \
|
|
|
|
__perf_evsel_stat__is(evsel, PERF_STAT_EVSEL_ID__ ## id)
|
|
|
|
|
|
|
|
void perf_stat_evsel_id_init(struct perf_evsel *evsel);
|
|
|
|
|
2015-06-03 22:25:59 +08:00
|
|
|
extern struct stats walltime_nsecs_stats;
|
|
|
|
|
|
|
|
void perf_stat__reset_shadow_stats(void);
|
|
|
|
void perf_stat__update_shadow_stats(struct perf_evsel *counter, u64 *count,
|
|
|
|
int cpu);
|
|
|
|
void perf_stat__print_shadow_stats(FILE *out, struct perf_evsel *evsel,
|
|
|
|
double avg, int cpu, enum aggr_mode aggr);
|
|
|
|
|
2015-06-26 17:29:11 +08:00
|
|
|
struct perf_counts *perf_counts__new(int ncpus, int nthreads);
|
2015-06-14 16:19:27 +08:00
|
|
|
void perf_counts__delete(struct perf_counts *counts);
|
|
|
|
|
2015-06-26 17:29:10 +08:00
|
|
|
void perf_evsel__reset_counts(struct perf_evsel *evsel);
|
2015-06-26 17:29:11 +08:00
|
|
|
int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus, int nthreads);
|
2015-06-14 16:19:26 +08:00
|
|
|
void perf_evsel__free_counts(struct perf_evsel *evsel);
|
2012-09-17 16:31:14 +08:00
|
|
|
#endif
|