events_stats.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __PERF_EVENTS_STATS_
  3. #define __PERF_EVENTS_STATS_
  4. #include <stdio.h>
  5. #include <perf/event.h>
  6. #include <linux/types.h>
  7. #include "auxtrace.h"
  8. /*
  9. * The kernel collects the number of events it couldn't send in a stretch and
  10. * when possible sends this number in a PERF_RECORD_LOST event. The number of
  11. * such "chunks" of lost events is stored in .nr_events[PERF_EVENT_LOST] while
  12. * total_lost tells exactly how many events the kernel in fact lost, i.e. it is
  13. * the sum of all struct perf_record_lost.lost fields reported.
  14. *
  15. * The kernel discards mixed up samples and sends the number in a
  16. * PERF_RECORD_LOST_SAMPLES event. The number of lost-samples events is stored
  17. * in .nr_events[PERF_RECORD_LOST_SAMPLES] while total_lost_samples tells
  18. * exactly how many samples the kernel in fact dropped, i.e. it is the sum of
  19. * all struct perf_record_lost_samples.lost fields reported.
  20. *
  21. * The total_period is needed because by default auto-freq is used, so
  22. * multipling nr_events[PERF_EVENT_SAMPLE] by a frequency isn't possible to get
  23. * the total number of low level events, it is necessary to to sum all struct
  24. * perf_record_sample.period and stash the result in total_period.
  25. */
  26. struct events_stats {
  27. u64 total_period;
  28. u64 total_non_filtered_period;
  29. 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];
  35. u32 nr_non_filtered_samples;
  36. u32 nr_lost_warned;
  37. u32 nr_unknown_events;
  38. u32 nr_invalid_chains;
  39. u32 nr_unknown_id;
  40. u32 nr_unprocessable_samples;
  41. u32 nr_auxtrace_errors[PERF_AUXTRACE_ERROR_MAX];
  42. u32 nr_proc_map_timeout;
  43. };
  44. void events_stats__inc(struct events_stats *stats, u32 type);
  45. size_t events_stats__fprintf(struct events_stats *stats, FILE *fp);
  46. #endif /* __PERF_EVENTS_STATS_ */