brintos

brintos / linux-shallow public Read only

0
0
Text · 2.6 KiB · eabd791 Raw
71 lines · c
1/* 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 and12 * when possible sends this number in a PERF_RECORD_LOST event. The number of13 * such "chunks" of lost events is stored in .nr_events[PERF_EVENT_LOST] while14 * total_lost tells exactly how many events the kernel in fact lost, i.e. it is15 * the sum of all struct perf_record_lost.lost fields reported.16 *17 * The kernel discards mixed up samples and sends the number in a18 * PERF_RECORD_LOST_SAMPLES event. The number of lost-samples events is stored19 * in .nr_events[PERF_RECORD_LOST_SAMPLES] while total_lost_samples tells20 * exactly how many samples the kernel in fact dropped, i.e. it is the sum of21 * all struct perf_record_lost_samples.lost fields reported without setting the22 * misc field in the header.23 *24 * The BPF program can discard samples according to the filter expressions given25 * by the user.  This number is kept in a BPF map and dumped at the end of perf26 * record in a PERF_RECORD_LOST_SAMPLES event.  To differentiate it from other27 * lost samples, perf tools sets PERF_RECORD_MISC_LOST_SAMPLES_BPF flag in the28 * header.misc field.  The number of dropped-samples events is stored in29 * .nr_events[PERF_RECORD_LOST_SAMPLES] while total_dropped_samples tells30 * exactly how many samples the BPF program in fact dropped, i.e. it is the sum31 * of all struct perf_record_lost_samples.lost fields reported with the misc32 * field set in the header.33 *34 * The total_period is needed because by default auto-freq is used, so35 * multiplying nr_events[PERF_EVENT_SAMPLE] by a frequency isn't possible to get36 * the total number of low level events, it is necessary to sum all struct37 * perf_record_sample.period and stash the result in total_period.38 */39struct events_stats {40	u64 total_lost;41	u64 total_lost_samples;42	u64 total_dropped_samples;43	u64 total_aux_lost;44	u64 total_aux_partial;45	u64 total_aux_collision;46	u64 total_invalid_chains;47	u32 nr_events[PERF_RECORD_HEADER_MAX];48	u32 nr_lost_warned;49	u32 nr_unknown_events;50	u32 nr_invalid_chains;51	u32 nr_unknown_id;52	u32 nr_unprocessable_samples;53	u32 nr_auxtrace_errors[PERF_AUXTRACE_ERROR_MAX];54	u32 nr_proc_map_timeout;55};56 57struct hists_stats {58	u64 total_period;59	u64 total_non_filtered_period;60	u32 nr_samples;61	u32 nr_non_filtered_samples;62	u32 nr_lost_samples;63	u32 nr_dropped_samples;64};65 66void events_stats__inc(struct events_stats *stats, u32 type);67 68size_t events_stats__fprintf(struct events_stats *stats, FILE *fp);69 70#endif /* __PERF_EVENTS_STATS_ */71