Lines Matching defs:evsel
31 #include "util/evsel.h"
130 struct evsel *sys_enter,
291 * The evsel->priv as used by 'perf trace'
318 static inline struct syscall_tp *__evsel__syscall_tp(struct evsel *evsel)
320 struct evsel_trace *et = evsel->priv;
325 static struct syscall_tp *evsel__syscall_tp(struct evsel *evsel)
327 if (evsel->priv == NULL) {
328 evsel->priv = evsel_trace__new();
329 if (evsel->priv == NULL)
333 return __evsel__syscall_tp(evsel);
339 static inline struct syscall_arg_fmt *__evsel__syscall_arg_fmt(struct evsel *evsel)
341 struct evsel_trace *et = evsel->priv;
346 static struct syscall_arg_fmt *evsel__syscall_arg_fmt(struct evsel *evsel)
348 struct evsel_trace *et = evsel->priv;
350 if (evsel->priv == NULL) {
351 et = evsel->priv = evsel_trace__new();
358 et->fmt = calloc(evsel->tp_format->format.nr_fields, sizeof(struct syscall_arg_fmt));
363 return __evsel__syscall_arg_fmt(evsel);
366 evsel_trace__delete(evsel->priv);
367 evsel->priv = NULL;
371 static int evsel__init_tp_uint_field(struct evsel *evsel, struct tp_field *field, const char *name)
373 struct tep_format_field *format_field = evsel__field(evsel, name);
378 return tp_field__init_uint(field, format_field, evsel->needs_swap);
381 #define perf_evsel__init_sc_tp_uint_field(evsel, name) \
382 ({ struct syscall_tp *sc = __evsel__syscall_tp(evsel);\
383 evsel__init_tp_uint_field(evsel, &sc->name, #name); })
385 static int evsel__init_tp_ptr_field(struct evsel *evsel, struct tp_field *field, const char *name)
387 struct tep_format_field *format_field = evsel__field(evsel, name);
395 #define perf_evsel__init_sc_tp_ptr_field(evsel, name) \
396 ({ struct syscall_tp *sc = __evsel__syscall_tp(evsel);\
397 evsel__init_tp_ptr_field(evsel, &sc->name, #name); })
399 static void evsel__delete_priv(struct evsel *evsel)
401 zfree(&evsel->priv);
402 evsel__delete(evsel);
405 static int evsel__init_syscall_tp(struct evsel *evsel)
407 struct syscall_tp *sc = evsel__syscall_tp(evsel);
410 if (evsel__init_tp_uint_field(evsel, &sc->id, "__syscall_nr") &&
411 evsel__init_tp_uint_field(evsel, &sc->id, "nr"))
419 static int evsel__init_augmented_syscall_tp(struct evsel *evsel, struct evsel *tp)
421 struct syscall_tp *sc = evsel__syscall_tp(evsel);
428 __tp_field__init_uint(&sc->id, syscall_id->size, syscall_id->offset, evsel->needs_swap))
437 static int evsel__init_augmented_syscall_tp_args(struct evsel *evsel)
439 struct syscall_tp *sc = __evsel__syscall_tp(evsel);
444 static int evsel__init_augmented_syscall_tp_ret(struct evsel *evsel)
446 struct syscall_tp *sc = __evsel__syscall_tp(evsel);
448 return __tp_field__init_uint(&sc->ret, sizeof(u64), sc->id.offset + sizeof(u64), evsel->needs_swap);
451 static int evsel__init_raw_syscall_tp(struct evsel *evsel, void *handler)
453 if (evsel__syscall_tp(evsel) != NULL) {
454 if (perf_evsel__init_sc_tp_uint_field(evsel, id))
457 evsel->handler = handler;
464 static struct evsel *perf_evsel__raw_syscall_newtp(const char *direction, void *handler)
466 struct evsel *evsel = evsel__newtp("raw_syscalls", direction);
469 if (IS_ERR(evsel))
470 evsel = evsel__newtp("syscalls", direction);
472 if (IS_ERR(evsel))
475 if (evsel__init_raw_syscall_tp(evsel, handler))
478 return evsel;
481 evsel__delete_priv(evsel);
485 #define perf_evsel__sc_tp_uint(evsel, name, sample) \
486 ({ struct syscall_tp *fields = __evsel__syscall_tp(evsel); \
489 #define perf_evsel__sc_tp_ptr(evsel, name, sample) \
490 ({ struct syscall_tp *fields = __evsel__syscall_tp(evsel); \
1827 static int evsel__init_tp_arg_scnprintf(struct evsel *evsel)
1829 struct syscall_arg_fmt *fmt = evsel__syscall_arg_fmt(evsel);
1832 syscall_arg_fmt__init_array(fmt, evsel->tp_format->format.fields);
2076 typedef int (*tracepoint_handler)(struct trace *trace, struct evsel *evsel,
2081 struct evsel *evsel, int id)
2100 id, evsel__name(evsel), ++n);
2232 static int trace__fprintf_sample(struct trace *trace, struct evsel *evsel,
2241 evsel__name(evsel), ts,
2275 static int trace__sys_enter(struct trace *trace, struct evsel *evsel,
2283 int id = perf_evsel__sc_tp_uint(evsel, id, sample), err = -1;
2286 struct syscall *sc = trace__syscall_info(trace, evsel, id);
2297 trace__fprintf_sample(trace, evsel, sample, thread);
2299 args = perf_evsel__sc_tp_ptr(evsel, args, sample);
2317 * here and avoid using augmented syscalls when the evsel is the raw_syscalls one.
2319 if (evsel != trace->syscalls.events.sys_enter)
2354 static int trace__fprintf_sys_enter(struct trace *trace, struct evsel *evsel,
2359 int id = perf_evsel__sc_tp_uint(evsel, id, sample), err = -1;
2360 struct syscall *sc = trace__syscall_info(trace, evsel, id);
2377 args = perf_evsel__sc_tp_ptr(evsel, args, sample);
2387 static int trace__resolve_callchain(struct trace *trace, struct evsel *evsel,
2392 int max_stack = evsel->core.attr.sample_max_stack ?
2393 evsel->core.attr.sample_max_stack :
2400 err = thread__resolve_callchain(al.thread, cursor, evsel, sample, NULL, NULL, max_stack);
2415 static const char *errno_to_name(struct evsel *evsel, int err)
2417 struct perf_env *env = evsel__env(evsel);
2423 static int trace__sys_exit(struct trace *trace, struct evsel *evsel,
2431 int id = perf_evsel__sc_tp_uint(evsel, id, sample), err = -1, callchain_ret = 0, printed = 0;
2433 struct syscall *sc = trace__syscall_info(trace, evsel, id);
2444 trace__fprintf_sample(trace, evsel, sample, thread);
2446 ret = perf_evsel__sc_tp_uint(evsel, ret, sample);
2466 callchain_ret = trace__resolve_callchain(trace, evsel, sample, &callchain_cursor);
2506 *e = errno_to_name(evsel, -ret);
2548 pr_err("Problem processing %s callchain, skipping...\n", evsel__name(evsel));
2557 static int trace__vfs_getname(struct trace *trace, struct evsel *evsel,
2566 const char *filename = evsel__rawptr(evsel, sample, "pathname");
2618 static int trace__sched_stat_runtime(struct trace *trace, struct evsel *evsel,
2622 u64 runtime = evsel__intval(evsel, sample, "runtime");
2640 evsel->name,
2641 evsel__strval(evsel, sample, "comm"),
2642 (pid_t)evsel__intval(evsel, sample, "pid"),
2644 evsel__intval(evsel, sample, "vruntime"));
2680 static size_t trace__fprintf_tp_fields(struct trace *trace, struct evsel *evsel, struct perf_sample *sample,
2685 struct tep_format_field *field = evsel->tp_format->format.fields;
2686 struct syscall_arg_fmt *arg = __evsel__syscall_arg_fmt(evsel);
2712 offset = format_field__intval(field, sample, evsel->needs_swap);
2719 val = format_field__intval(field, sample, evsel->needs_swap);
2754 static int trace__event_handler(struct trace *trace, struct evsel *evsel,
2761 * Check if we called perf_evsel__disable(evsel) due to, for instance,
2766 if (evsel->disabled)
2772 callchain_ret = trace__resolve_callchain(trace, evsel, sample, &callchain_cursor);
2789 if (evsel == trace->syscalls.events.augmented) {
2790 int id = perf_evsel__sc_tp_uint(evsel, id, sample);
2791 struct syscall *sc = trace__syscall_info(trace, evsel, id);
2795 trace__fprintf_sys_enter(trace, evsel, sample);
2807 fprintf(trace->output, "%s(", evsel->name);
2809 if (evsel__is_bpf_output(evsel)) {
2811 } else if (evsel->tp_format) {
2812 if (strncmp(evsel->tp_format->name, "sys_enter_", 10) ||
2813 trace__fprintf_sys_enter(trace, evsel, sample)) {
2815 event_format__fprintf(evsel->tp_format, sample->cpu,
2819 trace__fprintf_tp_fields(trace, evsel, sample, thread, NULL, 0);
2830 pr_err("Problem processing %s callchain, skipping...\n", evsel__name(evsel));
2834 if (evsel->max_events != ULONG_MAX && ++evsel->nr_events_printed == evsel->max_events) {
2835 evsel__disable(evsel);
2836 evsel__close(evsel);
2861 struct evsel *evsel,
2875 callchain_ret = trace__resolve_callchain(trace, evsel, sample, &callchain_cursor);
2887 if (evsel->core.attr.config == PERF_COUNT_SW_PAGE_FAULTS_MAJ)
2900 evsel->core.attr.config == PERF_COUNT_SW_PAGE_FAULTS_MAJ ?
2925 pr_err("Problem processing %s callchain, skipping...\n", evsel__name(evsel));
2936 struct evsel *evsel,
2948 (evsel->core.attr.sample_type & PERF_SAMPLE_TIME))
2955 struct evsel *evsel,
2962 tracepoint_handler handler = evsel->handler;
2968 trace__set_base_time(trace, evsel, sample);
2972 handler(trace, evsel, event, sample);
3052 struct evsel *evsel, *tmp;
3066 evlist__for_each_entry_safe(evlist, evsel, tmp) {
3067 if (!strstarts(evsel__name(evsel), "probe:vfs_getname"))
3070 if (evsel__field(evsel, "pathname")) {
3071 evsel->handler = trace__vfs_getname;
3076 list_del_init(&evsel->core.node);
3077 evsel->evlist = NULL;
3078 evsel__delete(evsel);
3084 static struct evsel *evsel__new_pgfault(u64 config)
3086 struct evsel *evsel;
3097 evsel = evsel__new(&attr);
3098 if (evsel)
3099 evsel->handler = trace__pgfault;
3101 return evsel;
3107 struct evsel *evsel;
3114 evsel = perf_evlist__id2evsel(trace->evlist, sample->id);
3115 if (evsel == NULL) {
3120 if (evswitch__discard(&trace->evswitch, evsel))
3123 trace__set_base_time(trace, evsel, sample);
3125 if (evsel->core.attr.type == PERF_TYPE_TRACEPOINT &&
3128 evsel__name(evsel), sample->tid,
3131 tracepoint_handler handler = evsel->handler;
3132 handler(trace, evsel, event, sample);
3143 struct evsel *sys_enter, *sys_exit;
3191 struct evsel *sys_exit;
3553 struct evsel *evsel, *tmp;
3559 evlist__for_each_entry_safe(trace->evlist, tmp, evsel) {
3560 if (evsel->bpf_obj == trace->bpf_obj) {
3561 evlist__remove(trace->evlist, evsel);
3562 evsel__delete(evsel);
3613 struct evsel *evsel;
3615 evlist__for_each_entry(trace->evlist, evsel) {
3616 if (evsel == trace->syscalls.events.augmented ||
3617 evsel->bpf_obj == trace->bpf_obj)
3763 static struct syscall_arg_fmt *evsel__find_syscall_arg_fmt_by_name(struct evsel *evsel, char *arg)
3766 struct syscall_arg_fmt *fmt = __evsel__syscall_arg_fmt(evsel);
3768 if (evsel->tp_format == NULL || fmt == NULL)
3771 for (field = evsel->tp_format->format.fields; field; field = field->next, ++fmt)
3778 static int trace__expand_filter(struct trace *trace __maybe_unused, struct evsel *evsel)
3780 char *tok, *left = evsel->filter, *new_filter = evsel->filter;
3818 fmt = evsel__find_syscall_arg_fmt_by_name(evsel, arg);
3821 arg, evsel->name, evsel->filter);
3846 if (new_filter != evsel->filter)
3852 right_size, right, arg, evsel->name, evsel->filter);
3857 arg, evsel->name, evsel->filter);
3867 if (new_filter != evsel->filter) {
3868 pr_debug("New filter for %s: %s\n", evsel->name, new_filter);
3869 evsel__set_filter(evsel, new_filter);
3876 static int trace__expand_filters(struct trace *trace, struct evsel **err_evsel)
3879 struct evsel *evsel;
3881 evlist__for_each_entry(evlist, evsel) {
3882 if (evsel->filter == NULL)
3885 if (trace__expand_filter(trace, evsel)) {
3886 *err_evsel = evsel;
3897 struct evsel *evsel, *pgfault_maj = NULL, *pgfault_min = NULL;
3955 * only for the evsels still without a cgroup, i.e. evsel->cgroup == NULL.
4034 err = trace__expand_filters(trace, &evsel);
4037 err = perf_evlist__apply_filters(evlist, &evsel);
4064 * Now that we already used evsel->core.attr to ask the kernel to setup the
4065 * events, lets reuse evsel->core.attr.sample_max_stack as the limit in
4069 evlist__for_each_entry(evlist, evsel) {
4070 if (evsel__has_callchain(evsel) &&
4071 evsel->core.attr.sample_max_stack == 0)
4072 evsel->core.attr.sample_max_stack = trace->max_stack;
4175 evsel->filter, evsel__name(evsel), errno,
4199 struct evsel *evsel;
4238 evsel = perf_evlist__find_tracepoint_by_name(session->evlist,
4241 if (evsel == NULL)
4242 evsel = perf_evlist__find_tracepoint_by_name(session->evlist,
4245 if (evsel &&
4246 (evsel__init_raw_syscall_tp(evsel, trace__sys_enter) < 0 ||
4247 perf_evsel__init_sc_tp_ptr_field(evsel, args))) {
4252 evsel = perf_evlist__find_tracepoint_by_name(session->evlist,
4254 if (evsel == NULL)
4255 evsel = perf_evlist__find_tracepoint_by_name(session->evlist,
4257 if (evsel &&
4258 (evsel__init_raw_syscall_tp(evsel, trace__sys_exit) < 0 ||
4259 perf_evsel__init_sc_tp_uint_field(evsel, ret))) {
4264 evlist__for_each_entry(session->evlist, evsel) {
4265 if (evsel->core.attr.type == PERF_TYPE_SOFTWARE &&
4266 (evsel->core.attr.config == PERF_COUNT_SW_PAGE_FAULTS_MAJ ||
4267 evsel->core.attr.config == PERF_COUNT_SW_PAGE_FAULTS_MIN ||
4268 evsel->core.attr.config == PERF_COUNT_SW_PAGE_FAULTS))
4269 evsel->handler = trace__pgfault;
4502 struct evsel *evsel;
4504 evlist__for_each_entry(evlist, evsel) {
4505 if (evsel->handler == NULL)
4506 evsel->handler = handler;
4510 static void evsel__set_syscall_arg_fmt(struct evsel *evsel, const char *name)
4512 struct syscall_arg_fmt *fmt = evsel__syscall_arg_fmt(evsel);
4520 if (strcmp(evsel->tp_format->format.fields->name, "__syscall_nr") == 0 ||
4521 strcmp(evsel->tp_format->format.fields->name, "nr") == 0)
4524 memcpy(fmt + skip, scfmt->arg, (evsel->tp_format->format.nr_fields - skip) * sizeof(*fmt));
4531 struct evsel *evsel;
4533 evlist__for_each_entry(evlist, evsel) {
4534 if (evsel->priv || !evsel->tp_format)
4537 if (strcmp(evsel->tp_format->system, "syscalls")) {
4538 evsel__init_tp_arg_scnprintf(evsel);
4542 if (evsel__init_syscall_tp(evsel))
4545 if (!strncmp(evsel->tp_format->name, "sys_enter_", 10)) {
4546 struct syscall_tp *sc = __evsel__syscall_tp(evsel);
4551 evsel__set_syscall_arg_fmt(evsel, evsel->tp_format->name + sizeof("sys_enter_") - 1);
4552 } else if (!strncmp(evsel->tp_format->name, "sys_exit_", 9)) {
4553 struct syscall_tp *sc = __evsel__syscall_tp(evsel);
4555 if (__tp_field__init_uint(&sc->ret, sizeof(u64), sc->id.offset + sizeof(u64), evsel->needs_swap))
4558 evsel__set_syscall_arg_fmt(evsel, evsel->tp_format->name + sizeof("sys_exit_") - 1);
4836 struct evsel *evsel;
4906 evsel = bpf__setup_output_event(trace.evlist, "__augmented_syscalls__");
4907 if (IS_ERR(evsel)) {
4908 bpf__strerror_setup_output_event(trace.evlist, PTR_ERR(evsel), bf, sizeof(bf));
4913 if (evsel) {
4914 trace.syscalls.events.augmented = evsel;
4916 evsel = perf_evlist__find_tracepoint_by_name(trace.evlist, "raw_syscalls:sys_enter");
4917 if (evsel == NULL) {
4922 if (evsel->bpf_obj == NULL) {
4927 trace.bpf_obj = evsel->bpf_obj;
5038 evlist__for_each_entry(trace.evlist, evsel) {
5039 bool raw_syscalls_sys_exit = strcmp(evsel__name(evsel), "raw_syscalls:sys_exit") == 0;
5047 strstr(evsel__name(evsel), "syscalls:sys_enter")) {
5048 struct evsel *augmented = trace.syscalls.events.augmented;
5049 if (evsel__init_augmented_syscall_tp(augmented, evsel) ||
5064 if (evsel__init_augmented_syscall_tp(evsel, evsel) ||
5065 evsel__init_augmented_syscall_tp_args(evsel))
5067 evsel->handler = trace__sys_enter;
5070 if (strstarts(evsel__name(evsel), "syscalls:sys_exit_")) {
5073 if (evsel__init_augmented_syscall_tp(evsel, evsel))
5075 sc = __evsel__syscall_tp(evsel);
5097 evsel__init_augmented_syscall_tp_ret(evsel);
5098 evsel->handler = trace__sys_exit;