Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef __PERF_EVENTS_STATS_
0003 #define __PERF_EVENTS_STATS_
0004 
0005 #include <stdio.h>
0006 #include <perf/event.h>
0007 #include <linux/types.h>
0008 #include "auxtrace.h"
0009 
0010 /*
0011  * The kernel collects the number of events it couldn't send in a stretch and
0012  * when possible sends this number in a PERF_RECORD_LOST event. The number of
0013  * such "chunks" of lost events is stored in .nr_events[PERF_EVENT_LOST] while
0014  * total_lost tells exactly how many events the kernel in fact lost, i.e. it is
0015  * the sum of all struct perf_record_lost.lost fields reported.
0016  *
0017  * The kernel discards mixed up samples and sends the number in a
0018  * PERF_RECORD_LOST_SAMPLES event. The number of lost-samples events is stored
0019  * in .nr_events[PERF_RECORD_LOST_SAMPLES] while total_lost_samples tells
0020  * exactly how many samples the kernel in fact dropped, i.e. it is the sum of
0021  * all struct perf_record_lost_samples.lost fields reported.
0022  *
0023  * The total_period is needed because by default auto-freq is used, so
0024  * multiplying nr_events[PERF_EVENT_SAMPLE] by a frequency isn't possible to get
0025  * the total number of low level events, it is necessary to sum all struct
0026  * perf_record_sample.period and stash the result in total_period.
0027  */
0028 struct events_stats {
0029     u64 total_lost;
0030     u64 total_lost_samples;
0031     u64 total_aux_lost;
0032     u64 total_aux_partial;
0033     u64 total_aux_collision;
0034     u64 total_invalid_chains;
0035     u32 nr_events[PERF_RECORD_HEADER_MAX];
0036     u32 nr_lost_warned;
0037     u32 nr_unknown_events;
0038     u32 nr_invalid_chains;
0039     u32 nr_unknown_id;
0040     u32 nr_unprocessable_samples;
0041     u32 nr_auxtrace_errors[PERF_AUXTRACE_ERROR_MAX];
0042     u32 nr_proc_map_timeout;
0043 };
0044 
0045 struct hists_stats {
0046     u64 total_period;
0047     u64 total_non_filtered_period;
0048     u32 nr_samples;
0049     u32 nr_non_filtered_samples;
0050 };
0051 
0052 void events_stats__inc(struct events_stats *stats, u32 type);
0053 
0054 size_t events_stats__fprintf(struct events_stats *stats, FILE *fp,
0055                  bool skip_empty);
0056 
0057 #endif /* __PERF_EVENTS_STATS_ */