blob: 3480bafd414b851a771a63b8df53c639614540d1 [file] [log] [blame]
Arnaldo Carvalho de Melo47729252019-08-30 11:44:32 -03001/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef __PERF_EVENTS_STATS_
3#define __PERF_EVENTS_STATS_
4
5#include <stdio.h>
6#include <perf/event.h>
7#include <linux/types.h>
8#include "auxtrace.h"
9
10/*
11 * The kernel collects the number of events it couldn't send in a stretch and
12 * when possible sends this number in a PERF_RECORD_LOST event. The number of
13 * such "chunks" of lost events is stored in .nr_events[PERF_EVENT_LOST] while
14 * total_lost tells exactly how many events the kernel in fact lost, i.e. it is
15 * the sum of all struct perf_record_lost.lost fields reported.
16 *
17 * The kernel discards mixed up samples and sends the number in a
18 * PERF_RECORD_LOST_SAMPLES event. The number of lost-samples events is stored
19 * in .nr_events[PERF_RECORD_LOST_SAMPLES] while total_lost_samples tells
20 * exactly how many samples the kernel in fact dropped, i.e. it is the sum of
21 * all struct perf_record_lost_samples.lost fields reported.
22 *
23 * The total_period is needed because by default auto-freq is used, so
Ingo Molnar4d39c892021-03-23 17:09:15 +010024 * multiplying nr_events[PERF_EVENT_SAMPLE] by a frequency isn't possible to get
Arnaldo Carvalho de Melo47729252019-08-30 11:44:32 -030025 * the total number of low level events, it is necessary to to sum all struct
26 * perf_record_sample.period and stash the result in total_period.
27 */
28struct events_stats {
Arnaldo Carvalho de Melo47729252019-08-30 11:44:32 -030029 u64 total_lost;
30 u64 total_lost_samples;
31 u64 total_aux_lost;
32 u64 total_aux_partial;
33 u64 total_invalid_chains;
34 u32 nr_events[PERF_RECORD_HEADER_MAX];
Arnaldo Carvalho de Melo47729252019-08-30 11:44:32 -030035 u32 nr_lost_warned;
36 u32 nr_unknown_events;
37 u32 nr_invalid_chains;
38 u32 nr_unknown_id;
39 u32 nr_unprocessable_samples;
40 u32 nr_auxtrace_errors[PERF_AUXTRACE_ERROR_MAX];
41 u32 nr_proc_map_timeout;
42};
43
Namhyung Kim0f0abba2021-04-26 18:37:13 -070044struct hists_stats {
45 u64 total_period;
46 u64 total_non_filtered_period;
47 u32 nr_samples;
48 u32 nr_non_filtered_samples;
49};
50
Arnaldo Carvalho de Melo47729252019-08-30 11:44:32 -030051void events_stats__inc(struct events_stats *stats, u32 type);
52
Namhyung Kim2775de02021-04-26 18:37:15 -070053size_t events_stats__fprintf(struct events_stats *stats, FILE *fp,
54 bool skip_empty);
Arnaldo Carvalho de Melo47729252019-08-30 11:44:32 -030055
56#endif /* __PERF_EVENTS_STATS_ */