Lines Matching refs:evsel

36 #include "util/evsel.h"
135 struct evsel *sys_enter,
294 * The evsel->priv as used by 'perf trace'
321 static inline struct syscall_tp *__evsel__syscall_tp(struct evsel *evsel)
323 struct evsel_trace *et = evsel->priv;
328 static struct syscall_tp *evsel__syscall_tp(struct evsel *evsel)
330 if (evsel->priv == NULL) {
331 evsel->priv = evsel_trace__new();
332 if (evsel->priv == NULL)
336 return __evsel__syscall_tp(evsel);
342 static inline struct syscall_arg_fmt *__evsel__syscall_arg_fmt(struct evsel *evsel)
344 struct evsel_trace *et = evsel->priv;
349 static struct syscall_arg_fmt *evsel__syscall_arg_fmt(struct evsel *evsel)
351 struct evsel_trace *et = evsel->priv;
353 if (evsel->priv == NULL) {
354 et = evsel->priv = evsel_trace__new();
361 et->fmt = calloc(evsel->tp_format->format.nr_fields, sizeof(struct syscall_arg_fmt));
366 return __evsel__syscall_arg_fmt(evsel);
369 evsel_trace__delete(evsel->priv);
370 evsel->priv = NULL;
374 static int evsel__init_tp_uint_field(struct evsel *evsel, struct tp_field *field, const char *name)
376 struct tep_format_field *format_field = evsel__field(evsel, name);
381 return tp_field__init_uint(field, format_field, evsel->needs_swap);
384 #define perf_evsel__init_sc_tp_uint_field(evsel, name) \
385 ({ struct syscall_tp *sc = __evsel__syscall_tp(evsel);\
386 evsel__init_tp_uint_field(evsel, &sc->name, #name); })
388 static int evsel__init_tp_ptr_field(struct evsel *evsel, struct tp_field *field, const char *name)
390 struct tep_format_field *format_field = evsel__field(evsel, name);
398 #define perf_evsel__init_sc_tp_ptr_field(evsel, name) \
399 ({ struct syscall_tp *sc = __evsel__syscall_tp(evsel);\
400 evsel__init_tp_ptr_field(evsel, &sc->name, #name); })
402 static void evsel__delete_priv(struct evsel *evsel)
404 zfree(&evsel->priv);
405 evsel__delete(evsel);
408 static int evsel__init_syscall_tp(struct evsel *evsel)
410 struct syscall_tp *sc = evsel__syscall_tp(evsel);
413 if (evsel__init_tp_uint_field(evsel, &sc->id, "__syscall_nr") &&
414 evsel__init_tp_uint_field(evsel, &sc->id, "nr"))
423 static int evsel__init_augmented_syscall_tp(struct evsel *evsel, struct evsel *tp)
425 struct syscall_tp *sc = evsel__syscall_tp(evsel);
432 __tp_field__init_uint(&sc->id, syscall_id->size, syscall_id->offset, evsel->needs_swap))
441 static int evsel__init_augmented_syscall_tp_args(struct evsel *evsel)
443 struct syscall_tp *sc = __evsel__syscall_tp(evsel);
448 static int evsel__init_augmented_syscall_tp_ret(struct evsel *evsel)
450 struct syscall_tp *sc = __evsel__syscall_tp(evsel);
452 return __tp_field__init_uint(&sc->ret, sizeof(u64), sc->id.offset + sizeof(u64), evsel->needs_swap);
455 static int evsel__init_raw_syscall_tp(struct evsel *evsel, void *handler)
457 if (evsel__syscall_tp(evsel) != NULL) {
458 if (perf_evsel__init_sc_tp_uint_field(evsel, id))
461 evsel->handler = handler;
468 static struct evsel *perf_evsel__raw_syscall_newtp(const char *direction, void *handler)
470 struct evsel *evsel = evsel__newtp("raw_syscalls", direction);
473 if (IS_ERR(evsel))
474 evsel = evsel__newtp("syscalls", direction);
476 if (IS_ERR(evsel))
479 if (evsel__init_raw_syscall_tp(evsel, handler))
482 return evsel;
485 evsel__delete_priv(evsel);
489 #define perf_evsel__sc_tp_uint(evsel, name, sample) \
490 ({ struct syscall_tp *fields = __evsel__syscall_tp(evsel); \
493 #define perf_evsel__sc_tp_ptr(evsel, name, sample) \
494 ({ struct syscall_tp *fields = __evsel__syscall_tp(evsel); \
1875 static int evsel__init_tp_arg_scnprintf(struct evsel *evsel)
1877 struct syscall_arg_fmt *fmt = evsel__syscall_arg_fmt(evsel);
1880 syscall_arg_fmt__init_array(fmt, evsel->tp_format->format.fields);
2124 typedef int (*tracepoint_handler)(struct trace *trace, struct evsel *evsel,
2129 struct evsel *evsel, int id)
2148 id, evsel__name(evsel), ++n);
2278 static int trace__fprintf_sample(struct trace *trace, struct evsel *evsel,
2287 evsel__name(evsel), ts,
2329 static int trace__sys_enter(struct trace *trace, struct evsel *evsel,
2337 int id = perf_evsel__sc_tp_uint(evsel, id, sample), err = -1;
2340 struct syscall *sc = trace__syscall_info(trace, evsel, id);
2351 trace__fprintf_sample(trace, evsel, sample, thread);
2353 args = perf_evsel__sc_tp_ptr(evsel, args, sample);
2371 * here and avoid using augmented syscalls when the evsel is the raw_syscalls one.
2373 if (evsel != trace->syscalls.events.sys_enter)
2408 static int trace__fprintf_sys_enter(struct trace *trace, struct evsel *evsel,
2413 int id = perf_evsel__sc_tp_uint(evsel, id, sample), err = -1;
2414 struct syscall *sc = trace__syscall_info(trace, evsel, id);
2431 args = perf_evsel__sc_tp_ptr(evsel, args, sample);
2441 static int trace__resolve_callchain(struct trace *trace, struct evsel *evsel,
2446 int max_stack = evsel->core.attr.sample_max_stack ?
2447 evsel->core.attr.sample_max_stack :
2455 err = thread__resolve_callchain(al.thread, cursor, evsel, sample, NULL, NULL, max_stack);
2471 static const char *errno_to_name(struct evsel *evsel, int err)
2473 struct perf_env *env = evsel__env(evsel);
2478 static int trace__sys_exit(struct trace *trace, struct evsel *evsel,
2486 int id = perf_evsel__sc_tp_uint(evsel, id, sample), err = -1, callchain_ret = 0, printed = 0;
2488 struct syscall *sc = trace__syscall_info(trace, evsel, id);
2499 trace__fprintf_sample(trace, evsel, sample, thread);
2501 ret = perf_evsel__sc_tp_uint(evsel, ret, sample);
2523 callchain_ret = trace__resolve_callchain(trace, evsel, sample, cursor);
2563 *e = errno_to_name(evsel, -ret);
2605 pr_err("Problem processing %s callchain, skipping...\n", evsel__name(evsel));
2614 static int trace__vfs_getname(struct trace *trace, struct evsel *evsel,
2623 const char *filename = evsel__rawptr(evsel, sample, "pathname");
2675 static int trace__sched_stat_runtime(struct trace *trace, struct evsel *evsel,
2679 u64 runtime = evsel__intval(evsel, sample, "runtime");
2697 evsel->name,
2698 evsel__strval(evsel, sample, "comm"),
2699 (pid_t)evsel__intval(evsel, sample, "pid"),
2701 evsel__intval(evsel, sample, "vruntime"));
2737 static size_t trace__fprintf_tp_fields(struct trace *trace, struct evsel *evsel, struct perf_sample *sample,
2742 struct tep_format_field *field = evsel->tp_format->format.fields;
2743 struct syscall_arg_fmt *arg = __evsel__syscall_arg_fmt(evsel);
2769 offset = format_field__intval(field, sample, evsel->needs_swap);
2778 val = format_field__intval(field, sample, evsel->needs_swap);
2809 static int trace__event_handler(struct trace *trace, struct evsel *evsel,
2816 * Check if we called perf_evsel__disable(evsel) due to, for instance,
2821 if (evsel->disabled)
2829 callchain_ret = trace__resolve_callchain(trace, evsel, sample, cursor);
2846 if (evsel == trace->syscalls.events.bpf_output) {
2847 int id = perf_evsel__sc_tp_uint(evsel, id, sample);
2848 struct syscall *sc = trace__syscall_info(trace, evsel, id);
2852 trace__fprintf_sys_enter(trace, evsel, sample);
2864 fprintf(trace->output, "%s(", evsel->name);
2866 if (evsel__is_bpf_output(evsel)) {
2868 } else if (evsel->tp_format) {
2869 if (strncmp(evsel->tp_format->name, "sys_enter_", 10) ||
2870 trace__fprintf_sys_enter(trace, evsel, sample)) {
2872 event_format__fprintf(evsel->tp_format, sample->cpu,
2876 trace__fprintf_tp_fields(trace, evsel, sample, thread, NULL, 0);
2887 pr_err("Problem processing %s callchain, skipping...\n", evsel__name(evsel));
2891 if (evsel->max_events != ULONG_MAX && ++evsel->nr_events_printed == evsel->max_events) {
2892 evsel__disable(evsel);
2893 evsel__close(evsel);
2918 struct evsel *evsel,
2935 callchain_ret = trace__resolve_callchain(trace, evsel, sample, cursor);
2947 if (evsel->core.attr.config == PERF_COUNT_SW_PAGE_FAULTS_MAJ)
2960 evsel->core.attr.config == PERF_COUNT_SW_PAGE_FAULTS_MAJ ?
2985 pr_err("Problem processing %s callchain, skipping...\n", evsel__name(evsel));
2997 struct evsel *evsel,
3009 (evsel->core.attr.sample_type & PERF_SAMPLE_TIME))
3016 struct evsel *evsel,
3023 tracepoint_handler handler = evsel->handler;
3029 trace__set_base_time(trace, evsel, sample);
3033 handler(trace, evsel, event, sample);
3113 struct evsel *evsel, *tmp;
3123 evlist__for_each_entry_safe(evlist, evsel, tmp) {
3124 if (!strstarts(evsel__name(evsel), "probe:vfs_getname"))
3127 if (evsel__field(evsel, "pathname")) {
3128 evsel->handler = trace__vfs_getname;
3133 list_del_init(&evsel->core.node);
3134 evsel->evlist = NULL;
3135 evsel__delete(evsel);
3141 static struct evsel *evsel__new_pgfault(u64 config)
3143 struct evsel *evsel;
3154 evsel = evsel__new(&attr);
3155 if (evsel)
3156 evsel->handler = trace__pgfault;
3158 return evsel;
3163 struct evsel *evsel;
3165 evlist__for_each_entry(evlist, evsel) {
3166 evsel_trace__delete(evsel->priv);
3167 evsel->priv = NULL;
3174 struct evsel *evsel;
3181 evsel = evlist__id2evsel(trace->evlist, sample->id);
3182 if (evsel == NULL) {
3187 if (evswitch__discard(&trace->evswitch, evsel))
3190 trace__set_base_time(trace, evsel, sample);
3192 if (evsel->core.attr.type == PERF_TYPE_TRACEPOINT &&
3195 evsel__name(evsel), sample->tid,
3198 tracepoint_handler handler = evsel->handler;
3199 handler(trace, evsel, event, sample);
3210 struct evsel *sys_enter, *sys_exit;
3258 struct evsel *sys_exit;
3684 static struct syscall_arg_fmt *evsel__find_syscall_arg_fmt_by_name(struct evsel *evsel, char *arg)
3687 struct syscall_arg_fmt *fmt = __evsel__syscall_arg_fmt(evsel);
3689 if (evsel->tp_format == NULL || fmt == NULL)
3692 for (field = evsel->tp_format->format.fields; field; field = field->next, ++fmt)
3699 static int trace__expand_filter(struct trace *trace __maybe_unused, struct evsel *evsel)
3701 char *tok, *left = evsel->filter, *new_filter = evsel->filter;
3739 fmt = evsel__find_syscall_arg_fmt_by_name(evsel, arg);
3742 arg, evsel->name, evsel->filter);
3767 if (new_filter != evsel->filter)
3773 right_size, right, arg, evsel->name, evsel->filter);
3778 arg, evsel->name, evsel->filter);
3788 if (new_filter != evsel->filter) {
3789 pr_debug("New filter for %s: %s\n", evsel->name, new_filter);
3790 evsel__set_filter(evsel, new_filter);
3797 static int trace__expand_filters(struct trace *trace, struct evsel **err_evsel)
3800 struct evsel *evsel;
3802 evlist__for_each_entry(evlist, evsel) {
3803 if (evsel->filter == NULL)
3806 if (trace__expand_filter(trace, evsel)) {
3807 *err_evsel = evsel;
3818 struct evsel *evsel, *pgfault_maj = NULL, *pgfault_min = NULL;
3879 * only for the evsels still without a cgroup, i.e. evsel->cgroup == NULL.
3960 err = trace__expand_filters(trace, &evsel);
3963 err = evlist__apply_filters(evlist, &evsel);
3987 * Now that we already used evsel->core.attr to ask the kernel to setup the
3988 * events, lets reuse evsel->core.attr.sample_max_stack as the limit in
3992 evlist__for_each_entry(evlist, evsel) {
3993 if (evsel__has_callchain(evsel) &&
3994 evsel->core.attr.sample_max_stack == 0)
3995 evsel->core.attr.sample_max_stack = trace->max_stack;
4098 evsel->filter, evsel__name(evsel), errno,
4122 struct evsel *evsel;
4161 evsel = evlist__find_tracepoint_by_name(session->evlist, "raw_syscalls:sys_enter");
4162 trace->syscalls.events.sys_enter = evsel;
4164 if (evsel == NULL)
4165 evsel = evlist__find_tracepoint_by_name(session->evlist, "syscalls:sys_enter");
4167 if (evsel &&
4168 (evsel__init_raw_syscall_tp(evsel, trace__sys_enter) < 0 ||
4169 perf_evsel__init_sc_tp_ptr_field(evsel, args))) {
4174 evsel = evlist__find_tracepoint_by_name(session->evlist, "raw_syscalls:sys_exit");
4175 trace->syscalls.events.sys_exit = evsel;
4176 if (evsel == NULL)
4177 evsel = evlist__find_tracepoint_by_name(session->evlist, "syscalls:sys_exit");
4178 if (evsel &&
4179 (evsel__init_raw_syscall_tp(evsel, trace__sys_exit) < 0 ||
4180 perf_evsel__init_sc_tp_uint_field(evsel, ret))) {
4185 evlist__for_each_entry(session->evlist, evsel) {
4186 if (evsel->core.attr.type == PERF_TYPE_SOFTWARE &&
4187 (evsel->core.attr.config == PERF_COUNT_SW_PAGE_FAULTS_MAJ ||
4188 evsel->core.attr.config == PERF_COUNT_SW_PAGE_FAULTS_MIN ||
4189 evsel->core.attr.config == PERF_COUNT_SW_PAGE_FAULTS))
4190 evsel->handler = trace__pgfault;
4428 struct evsel *evsel;
4430 evlist__for_each_entry(evlist, evsel) {
4431 if (evsel->handler == NULL)
4432 evsel->handler = handler;
4436 static void evsel__set_syscall_arg_fmt(struct evsel *evsel, const char *name)
4438 struct syscall_arg_fmt *fmt = evsel__syscall_arg_fmt(evsel);
4446 if (strcmp(evsel->tp_format->format.fields->name, "__syscall_nr") == 0 ||
4447 strcmp(evsel->tp_format->format.fields->name, "nr") == 0)
4450 memcpy(fmt + skip, scfmt->arg, (evsel->tp_format->format.nr_fields - skip) * sizeof(*fmt));
4457 struct evsel *evsel;
4459 evlist__for_each_entry(evlist, evsel) {
4460 if (evsel->priv || !evsel->tp_format)
4463 if (strcmp(evsel->tp_format->system, "syscalls")) {
4464 evsel__init_tp_arg_scnprintf(evsel);
4468 if (evsel__init_syscall_tp(evsel))
4471 if (!strncmp(evsel->tp_format->name, "sys_enter_", 10)) {
4472 struct syscall_tp *sc = __evsel__syscall_tp(evsel);
4477 evsel__set_syscall_arg_fmt(evsel, evsel->tp_format->name + sizeof("sys_enter_") - 1);
4478 } else if (!strncmp(evsel->tp_format->name, "sys_exit_", 9)) {
4479 struct syscall_tp *sc = __evsel__syscall_tp(evsel);
4481 if (__tp_field__init_uint(&sc->ret, sizeof(u64), sc->id.offset + sizeof(u64), evsel->needs_swap))
4484 evsel__set_syscall_arg_fmt(evsel, evsel->tp_format->name + sizeof("sys_exit_") - 1);
4790 struct evsel *evsel;
4961 evlist__for_each_entry(trace.evlist, evsel) {
4962 bool raw_syscalls_sys_exit = strcmp(evsel__name(evsel), "raw_syscalls:sys_exit") == 0;
4970 strstr(evsel__name(evsel), "syscalls:sys_enter")) {
4971 struct evsel *augmented = trace.syscalls.events.bpf_output;
4972 if (evsel__init_augmented_syscall_tp(augmented, evsel) ||
4987 if (evsel__init_augmented_syscall_tp(evsel, evsel) ||
4988 evsel__init_augmented_syscall_tp_args(evsel))
4990 evsel->handler = trace__sys_enter;
4993 if (strstarts(evsel__name(evsel), "syscalls:sys_exit_")) {
4996 if (evsel__init_augmented_syscall_tp(evsel, evsel))
4998 sc = __evsel__syscall_tp(evsel);
5020 evsel__init_augmented_syscall_tp_ret(evsel);
5021 evsel->handler = trace__sys_exit;