15 delta = val - stats->
mean;
16 stats->
mean += delta / stats->
n;
17 stats->
M2 += delta*(val - stats->
mean);
49 double variance, variance_mean;
54 variance = stats->
M2 / (stats->
n - 1);
55 variance_mean = variance / stats->
n;
57 return sqrt(variance_mean);
65 pct = 100.0 * stddev/
avg;
78 #define ID(id, name) [PERF_STAT_EVSEL_ID__##id] = #name 81 ID(CYCLES_IN_TX, cpu/cycles-t/),
82 ID(TRANSACTION_START, cpu/tx-
start/),
83 ID(ELISION_START, cpu/el-
start/),
84 ID(CYCLES_IN_TX_CP, cpu/cycles-ct/),
85 ID(TOPDOWN_TOTAL_SLOTS, topdown-total-slots),
86 ID(TOPDOWN_SLOTS_ISSUED, topdown-slots-issued),
87 ID(TOPDOWN_SLOTS_RETIRED, topdown-slots-retired),
88 ID(TOPDOWN_FETCH_BUBBLES, topdown-fetch-bubbles),
89 ID(TOPDOWN_RECOVERY_BUBBLES, topdown-recovery-bubbles),
90 ID(SMI_NUM, msr/smi/),
91 ID(APERF, msr/aperf/),
115 for (i = 0; i < 3; i++)
124 if (evsel->
stats == NULL)
148 return counts ? 0 : -ENOMEM;
244 if (!(vals->
run && vals->
ena))
251 *skip = test_and_set_bit(s, mask) == 1;
265 pr_err(
"failed to read per-pkg counter\n");
286 count->
val, 0, &config->
stats[thread]);
316 for (thread = 0; thread <
nthreads; thread++) {
317 for (cpu = 0; cpu <
ncpus; cpu++) {
361 for (i = 0; i < 3; i++)
365 fprintf(config->
output,
"%s: %" PRIu64
" %" PRIu64
" %" PRIu64
"\n",
391 pr_err(
"Failed to resolve counter for stat event.\n");
405 ret = fprintf(fp,
"\n... id %" PRIu64
", cpu %d, thread %d\n",
407 ret += fprintf(fp,
"... value %" PRIu64
", enabled %" PRIu64
", running %" PRIu64
"\n",
418 ret = fprintf(fp,
"\n... time %" PRIu64
", type %s\n", rd->
time,
431 ret = fprintf(fp,
"\n");
432 ret += fprintf(fp,
"... aggr_mode %d\n", sc.
aggr_mode);
433 ret += fprintf(fp,
"... scale %d\n", sc.
scale);
434 ret += fprintf(fp,
"... interval %u\n", sc.
interval);
double avg_stats(struct stats *stats)
struct perf_evlist * evlist
void perf_evlist__free_stats(struct perf_evlist *evlist)
void perf_counts_values__scale(struct perf_counts_values *count, bool scale, s8 *pscaled)
static int process_counter_values(struct perf_stat_config *config, struct perf_evsel *evsel, int cpu, int thread, struct perf_counts_values *count)
static void skip(int size)
static void perf_stat_evsel_id_init(struct perf_evsel *evsel)
static int perf_evsel__alloc_stats(struct perf_evsel *evsel, bool alloc_raw)
size_t perf_event__fprintf_stat(union perf_event *event, FILE *fp)
struct stat_config_event stat_config
double stddev_stats(struct stats *stats)
struct runtime_stat rt_stat
x86 movsq based memset() in arch/x86/lib/memset_64.S") MEMSET_FN(memset_erms
static void init_stats(struct stats *stats)
static void perf_evsel__free_stat_priv(struct perf_evsel *evsel)
static void perf_evsel__free_prev_raw_counts(struct perf_evsel *evsel)
bool __perf_evsel_stat__is(struct perf_evsel *evsel, enum perf_stat_evsel_id id)
struct perf_evlist * evlist
void update_stats(struct stats *stats, u64 val)
static struct perf_session * session
void perf_evsel__reset_counts(struct perf_evsel *evsel)
#define evlist__for_each_entry(evlist, evsel)
static bool cpu_map__empty(const struct cpu_map *map)
static unsigned int nthreads
static struct cpu_map * perf_evsel__cpus(struct perf_evsel *evsel)
struct perf_counts_values aggr
struct perf_counts * prev_raw_counts
size_t perf_event__fprintf_stat_config(union perf_event *event, FILE *fp)
static struct perf_tool tool
static void zero_per_pkg(struct perf_evsel *counter)
void perf_evlist__reset_stats(struct perf_evlist *evlist)
double rel_stddev_stats(double stddev, double avg)
struct perf_evsel * perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id)
static int perf_evsel__alloc_stat_priv(struct perf_evsel *evsel)
static int process_counter_maps(struct perf_stat_config *config, struct perf_evsel *counter)
struct perf_counts * counts
static const char * id_str[PERF_STAT_EVSEL_ID__MAX]
struct stats res_stats[3]
struct thread_map * threads
const char * perf_evsel__name(struct perf_evsel *evsel)
int perf_stat_process_counter(struct perf_stat_config *config, struct perf_evsel *counter)
static int thread_map__nr(struct thread_map *threads)
void perf_evsel__free_counts(struct perf_evsel *evsel)
void perf_stat__update_shadow_stats(struct perf_evsel *counter, u64 count, int cpu, struct runtime_stat *st)
size_t perf_event__fprintf_stat_round(union perf_event *event, FILE *fp)
void perf_counts__delete(struct perf_counts *counts)
struct runtime_stat * stats
int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus, int nthreads)
struct perf_counts * perf_counts__new(int ncpus, int nthreads)
int perf_evlist__alloc_stats(struct perf_evlist *evlist, bool alloc_raw)
int perf_event__process_stat_event(struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_session *session)
unsigned long * per_pkg_mask
static unsigned int ncpus
static void perf_evsel__reset_stat_priv(struct perf_evsel *evsel)
static int perf_evsel__alloc_prev_raw_counts(struct perf_evsel *evsel, int ncpus, int nthreads)
static int perf_evsel__nr_cpus(struct perf_evsel *evsel)
void perf_evsel__compute_deltas(struct perf_evsel *evsel, int cpu, int thread, struct perf_counts_values *count)
static struct perf_counts_values * perf_counts(struct perf_counts *counts, int cpu, int thread)
struct perf_stat_evsel * stats
enum perf_stat_evsel_id id
int cpu_map__get_socket(struct cpu_map *map, int idx, void *data __maybe_unused)
void perf_event__read_stat_config(struct perf_stat_config *config, struct stat_config_event *event)
void static void * zalloc(size_t size)
static int check_per_pkg(struct perf_evsel *counter, struct perf_counts_values *vals, int cpu, bool *skip)