3 #include <linux/kernel.h>
4 #include <linux/types.h>
5 #include <linux/bitops.h>
6 #include <linux/log2.h>
7 #include <linux/zalloc.h>
9 #include "../../util/evlist.h"
10 #include "../../util/auxtrace.h"
11 #include "../../util/evsel.h"
12 #include "../../util/record.h"
14 #define PERF_EVENT_CPUM_SF 0xB0000 /* Event: Basic-sampling */
15 #define PERF_EVENT_CPUM_SF_DIAG 0xBD000 /* Event: Combined-sampling */
16 #define DEFAULT_AUX_PAGES 128
17 #define DEFAULT_FREQ 4000
19 static void cpumsf_free(struct auxtrace_record *itr)
24 static size_t cpumsf_info_priv_size(struct auxtrace_record *itr __maybe_unused,
25 struct evlist *evlist __maybe_unused)
31 cpumsf_info_fill(struct auxtrace_record *itr __maybe_unused,
32 struct perf_session *session __maybe_unused,
33 struct perf_record_auxtrace_info *auxtrace_info __maybe_unused,
34 size_t priv_size __maybe_unused)
36 auxtrace_info->type = PERF_AUXTRACE_S390_CPUMSF;
41 cpumsf_reference(struct auxtrace_record *itr __maybe_unused)
47 cpumsf_recording_options(struct auxtrace_record *ar __maybe_unused,
48 struct evlist *evlist __maybe_unused,
49 struct record_opts *opts)
51 unsigned int factor = 1;
54 opts->full_auxtrace = true;
57 * The AUX buffer size should be set properly to avoid
58 * overflow of samples if it is not set explicitly.
59 * DEFAULT_AUX_PAGES is an proper size when sampling frequency
60 * is DEFAULT_FREQ. It is expected to hold about 1/2 second
61 * of sampling data. The size used for AUX buffer will scale
62 * according to the specified frequency and DEFAULT_FREQ.
64 if (!opts->auxtrace_mmap_pages) {
65 if (opts->user_freq != UINT_MAX)
66 factor = (opts->user_freq + DEFAULT_FREQ
68 pages = DEFAULT_AUX_PAGES * factor;
69 opts->auxtrace_mmap_pages = roundup_pow_of_two(pages);
76 cpumsf_parse_snapshot_options(struct auxtrace_record *itr __maybe_unused,
77 struct record_opts *opts __maybe_unused,
78 const char *str __maybe_unused)
84 * auxtrace_record__init is called when perf record
85 * check if the event really need auxtrace
87 struct auxtrace_record *auxtrace_record__init(struct evlist *evlist,
90 struct auxtrace_record *aux;
95 if (evlist->core.nr_entries == 0)
98 evlist__for_each_entry(evlist, pos) {
99 if (pos->core.attr.config == PERF_EVENT_CPUM_SF_DIAG) {
108 /* sampling in diagnose mode. alloc aux buffer */
109 aux = zalloc(sizeof(*aux));
115 aux->parse_snapshot_options = cpumsf_parse_snapshot_options;
116 aux->recording_options = cpumsf_recording_options;
117 aux->info_priv_size = cpumsf_info_priv_size;
118 aux->info_fill = cpumsf_info_fill;
119 aux->free = cpumsf_free;
120 aux->reference = cpumsf_reference;