aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/evsel.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/evsel.c')
-rw-r--r--tools/perf/util/evsel.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 8606175fe1e8..21a373ebea22 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -29,6 +29,7 @@ static struct {
29 bool sample_id_all; 29 bool sample_id_all;
30 bool exclude_guest; 30 bool exclude_guest;
31 bool mmap2; 31 bool mmap2;
32 bool cloexec;
32} perf_missing_features; 33} perf_missing_features;
33 34
34#define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) 35#define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y))
@@ -623,7 +624,7 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts)
623 attr->mmap_data = track; 624 attr->mmap_data = track;
624 } 625 }
625 626
626 if (opts->call_graph_enabled) 627 if (opts->call_graph_enabled && !evsel->no_aux_samples)
627 perf_evsel__config_callgraph(evsel, opts); 628 perf_evsel__config_callgraph(evsel, opts);
628 629
629 if (target__has_cpu(&opts->target)) 630 if (target__has_cpu(&opts->target))
@@ -637,7 +638,7 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts)
637 target__has_cpu(&opts->target) || per_cpu)) 638 target__has_cpu(&opts->target) || per_cpu))
638 perf_evsel__set_sample_bit(evsel, TIME); 639 perf_evsel__set_sample_bit(evsel, TIME);
639 640
640 if (opts->raw_samples) { 641 if (opts->raw_samples && !evsel->no_aux_samples) {
641 perf_evsel__set_sample_bit(evsel, TIME); 642 perf_evsel__set_sample_bit(evsel, TIME);
642 perf_evsel__set_sample_bit(evsel, RAW); 643 perf_evsel__set_sample_bit(evsel, RAW);
643 perf_evsel__set_sample_bit(evsel, CPU); 644 perf_evsel__set_sample_bit(evsel, CPU);
@@ -650,7 +651,7 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts)
650 attr->watermark = 0; 651 attr->watermark = 0;
651 attr->wakeup_events = 1; 652 attr->wakeup_events = 1;
652 } 653 }
653 if (opts->branch_stack) { 654 if (opts->branch_stack && !evsel->no_aux_samples) {
654 perf_evsel__set_sample_bit(evsel, BRANCH_STACK); 655 perf_evsel__set_sample_bit(evsel, BRANCH_STACK);
655 attr->branch_sample_type = opts->branch_stack; 656 attr->branch_sample_type = opts->branch_stack;
656 } 657 }
@@ -681,6 +682,11 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts)
681 if (target__none(&opts->target) && perf_evsel__is_group_leader(evsel) && 682 if (target__none(&opts->target) && perf_evsel__is_group_leader(evsel) &&
682 !opts->initial_delay) 683 !opts->initial_delay)
683 attr->enable_on_exec = 1; 684 attr->enable_on_exec = 1;
685
686 if (evsel->immediate) {
687 attr->disabled = 0;
688 attr->enable_on_exec = 0;
689 }
684} 690}
685 691
686int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads) 692int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads)
@@ -960,6 +966,7 @@ static size_t perf_event_attr__fprintf(struct perf_event_attr *attr, FILE *fp)
960 ret += PRINT_ATTR2(exclude_user, exclude_kernel); 966 ret += PRINT_ATTR2(exclude_user, exclude_kernel);
961 ret += PRINT_ATTR2(exclude_hv, exclude_idle); 967 ret += PRINT_ATTR2(exclude_hv, exclude_idle);
962 ret += PRINT_ATTR2(mmap, comm); 968 ret += PRINT_ATTR2(mmap, comm);
969 ret += PRINT_ATTR2(mmap2, comm_exec);
963 ret += PRINT_ATTR2(freq, inherit_stat); 970 ret += PRINT_ATTR2(freq, inherit_stat);
964 ret += PRINT_ATTR2(enable_on_exec, task); 971 ret += PRINT_ATTR2(enable_on_exec, task);
965 ret += PRINT_ATTR2(watermark, precise_ip); 972 ret += PRINT_ATTR2(watermark, precise_ip);
@@ -967,7 +974,6 @@ static size_t perf_event_attr__fprintf(struct perf_event_attr *attr, FILE *fp)
967 ret += PRINT_ATTR2(exclude_host, exclude_guest); 974 ret += PRINT_ATTR2(exclude_host, exclude_guest);
968 ret += PRINT_ATTR2N("excl.callchain_kern", exclude_callchain_kernel, 975 ret += PRINT_ATTR2N("excl.callchain_kern", exclude_callchain_kernel,
969 "excl.callchain_user", exclude_callchain_user); 976 "excl.callchain_user", exclude_callchain_user);
970 ret += PRINT_ATTR_U32(mmap2);
971 977
972 ret += PRINT_ATTR_U32(wakeup_events); 978 ret += PRINT_ATTR_U32(wakeup_events);
973 ret += PRINT_ATTR_U32(wakeup_watermark); 979 ret += PRINT_ATTR_U32(wakeup_watermark);
@@ -989,7 +995,7 @@ static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
989 struct thread_map *threads) 995 struct thread_map *threads)
990{ 996{
991 int cpu, thread; 997 int cpu, thread;
992 unsigned long flags = 0; 998 unsigned long flags = PERF_FLAG_FD_CLOEXEC;
993 int pid = -1, err; 999 int pid = -1, err;
994 enum { NO_CHANGE, SET_TO_MAX, INCREASED_MAX } set_rlimit = NO_CHANGE; 1000 enum { NO_CHANGE, SET_TO_MAX, INCREASED_MAX } set_rlimit = NO_CHANGE;
995 1001
@@ -998,11 +1004,13 @@ static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
998 return -ENOMEM; 1004 return -ENOMEM;
999 1005
1000 if (evsel->cgrp) { 1006 if (evsel->cgrp) {
1001 flags = PERF_FLAG_PID_CGROUP; 1007 flags |= PERF_FLAG_PID_CGROUP;
1002 pid = evsel->cgrp->fd; 1008 pid = evsel->cgrp->fd;
1003 } 1009 }
1004 1010
1005fallback_missing_features: 1011fallback_missing_features:
1012 if (perf_missing_features.cloexec)
1013 flags &= ~(unsigned long)PERF_FLAG_FD_CLOEXEC;
1006 if (perf_missing_features.mmap2) 1014 if (perf_missing_features.mmap2)
1007 evsel->attr.mmap2 = 0; 1015 evsel->attr.mmap2 = 0;
1008 if (perf_missing_features.exclude_guest) 1016 if (perf_missing_features.exclude_guest)
@@ -1071,7 +1079,10 @@ try_fallback:
1071 if (err != -EINVAL || cpu > 0 || thread > 0) 1079 if (err != -EINVAL || cpu > 0 || thread > 0)
1072 goto out_close; 1080 goto out_close;
1073 1081
1074 if (!perf_missing_features.mmap2 && evsel->attr.mmap2) { 1082 if (!perf_missing_features.cloexec && (flags & PERF_FLAG_FD_CLOEXEC)) {
1083 perf_missing_features.cloexec = true;
1084 goto fallback_missing_features;
1085 } else if (!perf_missing_features.mmap2 && evsel->attr.mmap2) {
1075 perf_missing_features.mmap2 = true; 1086 perf_missing_features.mmap2 = true;
1076 goto fallback_missing_features; 1087 goto fallback_missing_features;
1077 } else if (!perf_missing_features.exclude_guest && 1088 } else if (!perf_missing_features.exclude_guest &&
@@ -1940,6 +1951,7 @@ int perf_evsel__fprintf(struct perf_evsel *evsel,
1940 if_print(mmap); 1951 if_print(mmap);
1941 if_print(mmap2); 1952 if_print(mmap2);
1942 if_print(comm); 1953 if_print(comm);
1954 if_print(comm_exec);
1943 if_print(freq); 1955 if_print(freq);
1944 if_print(inherit_stat); 1956 if_print(inherit_stat);
1945 if_print(enable_on_exec); 1957 if_print(enable_on_exec);