Lines Matching defs:evsel
36 #include "util/evsel.h"
134 struct evsel *sys_enter,
293 * The evsel->priv as used by 'perf trace'
320 static inline struct syscall_tp *__evsel__syscall_tp(struct evsel *evsel)
322 struct evsel_trace *et = evsel->priv;
327 static struct syscall_tp *evsel__syscall_tp(struct evsel *evsel)
329 if (evsel->priv == NULL) {
330 evsel->priv = evsel_trace__new();
331 if (evsel->priv == NULL)
335 return __evsel__syscall_tp(evsel);
341 static inline struct syscall_arg_fmt *__evsel__syscall_arg_fmt(struct evsel *evsel)
343 struct evsel_trace *et = evsel->priv;
348 static struct syscall_arg_fmt *evsel__syscall_arg_fmt(struct evsel *evsel)
350 struct evsel_trace *et = evsel->priv;
352 if (evsel->priv == NULL) {
353 et = evsel->priv = evsel_trace__new();
360 et->fmt = calloc(evsel->tp_format->format.nr_fields, sizeof(struct syscall_arg_fmt));
365 return __evsel__syscall_arg_fmt(evsel);
368 evsel_trace__delete(evsel->priv);
369 evsel->priv = NULL;
373 static int evsel__init_tp_uint_field(struct evsel *evsel, struct tp_field *field, const char *name)
375 struct tep_format_field *format_field = evsel__field(evsel, name);
380 return tp_field__init_uint(field, format_field, evsel->needs_swap);
383 #define perf_evsel__init_sc_tp_uint_field(evsel, name) \
384 ({ struct syscall_tp *sc = __evsel__syscall_tp(evsel);\
385 evsel__init_tp_uint_field(evsel, &sc->name, #name); })
387 static int evsel__init_tp_ptr_field(struct evsel *evsel, struct tp_field *field, const char *name)
389 struct tep_format_field *format_field = evsel__field(evsel, name);
397 #define perf_evsel__init_sc_tp_ptr_field(evsel, name) \
398 ({ struct syscall_tp *sc = __evsel__syscall_tp(evsel);\
399 evsel__init_tp_ptr_field(evsel, &sc->name, #name); })
401 static void evsel__delete_priv(struct evsel *evsel)
403 zfree(&evsel->priv);
404 evsel__delete(evsel);
407 static int evsel__init_syscall_tp(struct evsel *evsel)
409 struct syscall_tp *sc = evsel__syscall_tp(evsel);
412 if (evsel__init_tp_uint_field(evsel, &sc->id, "__syscall_nr") &&
413 evsel__init_tp_uint_field(evsel, &sc->id, "nr"))
422 static int evsel__init_augmented_syscall_tp(struct evsel *evsel, struct evsel *tp)
424 struct syscall_tp *sc = evsel__syscall_tp(evsel);
431 __tp_field__init_uint(&sc->id, syscall_id->size, syscall_id->offset, evsel->needs_swap))
440 static int evsel__init_augmented_syscall_tp_args(struct evsel *evsel)
442 struct syscall_tp *sc = __evsel__syscall_tp(evsel);
447 static int evsel__init_augmented_syscall_tp_ret(struct evsel *evsel)
449 struct syscall_tp *sc = __evsel__syscall_tp(evsel);
451 return __tp_field__init_uint(&sc->ret, sizeof(u64), sc->id.offset + sizeof(u64), evsel->needs_swap);
454 static int evsel__init_raw_syscall_tp(struct evsel *evsel, void *handler)
456 if (evsel__syscall_tp(evsel) != NULL) {
457 if (perf_evsel__init_sc_tp_uint_field(evsel, id))
460 evsel->handler = handler;
467 static struct evsel *perf_evsel__raw_syscall_newtp(const char *direction, void *handler)
469 struct evsel *evsel = evsel__newtp("raw_syscalls", direction);
472 if (IS_ERR(evsel))
473 evsel = evsel__newtp("syscalls", direction);
475 if (IS_ERR(evsel))
478 if (evsel__init_raw_syscall_tp(evsel, handler))
481 return evsel;
484 evsel__delete_priv(evsel);
488 #define perf_evsel__sc_tp_uint(evsel, name, sample) \
489 ({ struct syscall_tp *fields = __evsel__syscall_tp(evsel); \
492 #define perf_evsel__sc_tp_ptr(evsel, name, sample) \
493 ({ struct syscall_tp *fields = __evsel__syscall_tp(evsel); \
1874 static int evsel__init_tp_arg_scnprintf(struct evsel *evsel)
1876 struct syscall_arg_fmt *fmt = evsel__syscall_arg_fmt(evsel);
1879 syscall_arg_fmt__init_array(fmt, evsel->tp_format->format.fields);
2123 typedef int (*tracepoint_handler)(struct trace *trace, struct evsel *evsel,
2128 struct evsel *evsel, int id)
2147 id, evsel__name(evsel), ++n);
2277 static int trace__fprintf_sample(struct trace *trace, struct evsel *evsel,
2286 evsel__name(evsel), ts,
2328 static int trace__sys_enter(struct trace *trace, struct evsel *evsel,
2336 int id = perf_evsel__sc_tp_uint(evsel, id, sample), err = -1;
2339 struct syscall *sc = trace__syscall_info(trace, evsel, id);
2350 trace__fprintf_sample(trace, evsel, sample, thread);
2352 args = perf_evsel__sc_tp_ptr(evsel, args, sample);
2370 * here and avoid using augmented syscalls when the evsel is the raw_syscalls one.
2372 if (evsel != trace->syscalls.events.sys_enter)
2407 static int trace__fprintf_sys_enter(struct trace *trace, struct evsel *evsel,
2412 int id = perf_evsel__sc_tp_uint(evsel, id, sample), err = -1;
2413 struct syscall *sc = trace__syscall_info(trace, evsel, id);
2430 args = perf_evsel__sc_tp_ptr(evsel, args, sample);
2440 static int trace__resolve_callchain(struct trace *trace, struct evsel *evsel,
2445 int max_stack = evsel->core.attr.sample_max_stack ?
2446 evsel->core.attr.sample_max_stack :
2454 err = thread__resolve_callchain(al.thread, cursor, evsel, sample, NULL, NULL, max_stack);
2470 static const char *errno_to_name(struct evsel *evsel, int err)
2472 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;
4425 struct evsel *evsel;
4427 evlist__for_each_entry(evlist, evsel) {
4428 if (evsel->handler == NULL)
4429 evsel->handler = handler;
4433 static void evsel__set_syscall_arg_fmt(struct evsel *evsel, const char *name)
4435 struct syscall_arg_fmt *fmt = evsel__syscall_arg_fmt(evsel);
4443 if (strcmp(evsel->tp_format->format.fields->name, "__syscall_nr") == 0 ||
4444 strcmp(evsel->tp_format->format.fields->name, "nr") == 0)
4447 memcpy(fmt + skip, scfmt->arg, (evsel->tp_format->format.nr_fields - skip) * sizeof(*fmt));
4454 struct evsel *evsel;
4456 evlist__for_each_entry(evlist, evsel) {
4457 if (evsel->priv || !evsel->tp_format)
4460 if (strcmp(evsel->tp_format->system, "syscalls")) {
4461 evsel__init_tp_arg_scnprintf(evsel);
4465 if (evsel__init_syscall_tp(evsel))
4468 if (!strncmp(evsel->tp_format->name, "sys_enter_", 10)) {
4469 struct syscall_tp *sc = __evsel__syscall_tp(evsel);
4474 evsel__set_syscall_arg_fmt(evsel, evsel->tp_format->name + sizeof("sys_enter_") - 1);
4475 } else if (!strncmp(evsel->tp_format->name, "sys_exit_", 9)) {
4476 struct syscall_tp *sc = __evsel__syscall_tp(evsel);
4478 if (__tp_field__init_uint(&sc->ret, sizeof(u64), sc->id.offset + sizeof(u64), evsel->needs_swap))
4481 evsel__set_syscall_arg_fmt(evsel, evsel->tp_format->name + sizeof("sys_exit_") - 1);
4787 struct evsel *evsel;
4958 evlist__for_each_entry(trace.evlist, evsel) {
4959 bool raw_syscalls_sys_exit = strcmp(evsel__name(evsel), "raw_syscalls:sys_exit") == 0;
4967 strstr(evsel__name(evsel), "syscalls:sys_enter")) {
4968 struct evsel *augmented = trace.syscalls.events.bpf_output;
4969 if (evsel__init_augmented_syscall_tp(augmented, evsel) ||
4984 if (evsel__init_augmented_syscall_tp(evsel, evsel) ||
4985 evsel__init_augmented_syscall_tp_args(evsel))
4987 evsel->handler = trace__sys_enter;
4990 if (strstarts(evsel__name(evsel), "syscalls:sys_exit_")) {
4993 if (evsel__init_augmented_syscall_tp(evsel, evsel))
4995 sc = __evsel__syscall_tp(evsel);
5017 evsel__init_augmented_syscall_tp_ret(evsel);
5018 evsel->handler = trace__sys_exit;