8 #include <subcmd/parse-options.h> 19 int err = -EAGAIN,
fd;
20 static pid_t
pid = -1;
34 if (pid == -1 && errno == EACCES) {
62 const char *
try[] = {
"cycles:u",
"instructions:u",
"cpu-clock:u", NULL};
76 }
while (ret == -EAGAIN &&
try[i]);
83 evsel->
attr.sample_type |= PERF_SAMPLE_IDENTIFIER;
88 evsel->
attr.comm_exec = 1;
93 evsel->
attr.context_switch = 1;
113 struct perf_event_attr attr = {
114 .type = PERF_TYPE_SOFTWARE,
115 .config = PERF_COUNT_SW_CPU_CLOCK,
139 bool use_sample_identifier =
false;
157 if (evsel->
tracking && use_comm_exec)
158 evsel->
attr.comm_exec = 1;
173 if (evsel->
attr.sample_type == first->
attr.sample_type)
191 return sysctl__read_int(
"kernel/perf_event_max_sample_rate", (
int *)rate);
196 bool user_freq = opts->
user_freq != UINT_MAX;
197 unsigned int max_rate;
209 else if (opts->
freq) {
212 pr_err(
"frequency and count are zero, aborting\n");
222 if (user_freq && (max_rate < opts->freq)) {
224 pr_err(
"error: Maximum frequency rate (%'u Hz) exceeded.\n" 225 " Please use -F freq option with a lower value or consider\n" 226 " tweaking /proc/sys/kernel/perf_event_max_sample_rate.\n",
230 pr_warning(
"warning: Maximum frequency rate (%'u Hz) exceeded, throttling from %'u Hz to %'u Hz.\n" 231 " The limit can be raised via /proc/sys/kernel/perf_event_max_sample_rate.\n" 232 " The kernel will lower it when perf's interrupts take too long.\n" 233 " Use --strict-freq to disable this throttling, refusing to record.\n",
234 max_rate, opts->
freq, max_rate);
236 opts->
freq = max_rate;
243 if (max_rate < opts->freq) {
244 pr_warning(
"Lowering default frequency rate to %u.\n" 245 "Please consider tweaking " 246 "/proc/sys/kernel/perf_event_max_sample_rate.\n",
248 opts->
freq = max_rate;
280 cpu = cpus ? cpus->
map[0] : 0;
290 if (pid == -1 && errno == EACCES) {
314 if (strcasecmp(str,
"max") == 0) {
316 pr_err(
"couldn't read /proc/sys/kernel/perf_event_max_sample_rate\n");
319 pr_info(
"info: Using a maximum frequency rate of %'d Hz\n", freq);
static void perf_probe_comm_exec(struct perf_evsel *evsel)
void perf_evlist__set_leader(struct perf_evlist *evlist)
void perf_evlist__set_id_pos(struct perf_evlist *evlist)
struct xyarray * sample_id
void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts, struct callchain_param *callchain)
int record_opts__config(struct record_opts *opts)
void perf_evlist__delete(struct perf_evlist *evlist)
static bool perf_probe_api(setup_probe_fn_t fn)
bool perf_can_sample_identifier(void)
static int sys_perf_event_open(struct perf_event_attr *attr, pid_t pid, int cpu, int group_fd, unsigned long flags)
int parse_events(struct perf_evlist *evlist, const char *str, struct parse_events_error *err)
void cpu_map__put(struct cpu_map *map)
struct perf_evlist * evlist
#define evlist__for_each_entry(evlist, evsel)
static bool cpu_map__empty(const struct cpu_map *map)
static int record_opts__config_freq(struct record_opts *opts)
static int str(yyscan_t scanner, int token)
static void perf_probe_context_switch(struct perf_evsel *evsel)
bool perf_can_record_switch_events(void)
static bool perf_can_comm_exec(void)
bool perf_evlist__can_select_event(struct perf_evlist *evlist, const char *str)
static void perf_probe_sample_identifier(struct perf_evsel *evsel)
bool perf_can_record_cpu_wide(void)
static int perf_do_probe_api(setup_probe_fn_t fn, int cpu, const char *str)
unsigned long perf_event_open_cloexec_flag(void)
static struct perf_evsel * perf_evlist__first(struct perf_evlist *evlist)
static int get_max_rate(unsigned int *rate)
void perf_evsel__set_sample_id(struct perf_evsel *evsel, bool can_sample_identifier)
void(* setup_probe_fn_t)(struct perf_evsel *evsel)
void perf_evlist__config(struct perf_evlist *evlist, struct record_opts *opts, struct callchain_param *callchain)
static struct perf_evsel * perf_evlist__last(struct perf_evlist *evlist)
#define pr_warning(fmt,...)
struct cpu_map * cpu_map__new(const char *cpu_list)
int record__parse_freq(const struct option *opt, const char *str, int unset __maybe_unused)
struct perf_evlist * perf_evlist__new(void)
struct perf_event_attr attr