Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-next
[cascardo/linux.git] / tools / perf / util / evsel.c
index 9f1ef9b..18f7c18 100644 (file)
@@ -168,7 +168,7 @@ void perf_evsel__init(struct perf_evsel *evsel,
        perf_evsel__calc_id_pos(evsel);
 }
 
-struct perf_evsel *perf_evsel__new(struct perf_event_attr *attr, int idx)
+struct perf_evsel *perf_evsel__new_idx(struct perf_event_attr *attr, int idx)
 {
        struct perf_evsel *evsel = zalloc(sizeof(*evsel));
 
@@ -219,7 +219,7 @@ out:
        return format;
 }
 
-struct perf_evsel *perf_evsel__newtp(const char *sys, const char *name, int idx)
+struct perf_evsel *perf_evsel__newtp_idx(const char *sys, const char *name, int idx)
 {
        struct perf_evsel *evsel = zalloc(sizeof(*evsel));
 
@@ -645,7 +645,7 @@ void perf_evsel__config(struct perf_evsel *evsel,
                }
        }
 
-       if (perf_target__has_cpu(&opts->target))
+       if (target__has_cpu(&opts->target))
                perf_evsel__set_sample_bit(evsel, CPU);
 
        if (opts->period)
@@ -653,7 +653,7 @@ void perf_evsel__config(struct perf_evsel *evsel,
 
        if (!perf_missing_features.sample_id_all &&
            (opts->sample_time || !opts->no_inherit ||
-            perf_target__has_cpu(&opts->target)))
+            target__has_cpu(&opts->target)))
                perf_evsel__set_sample_bit(evsel, TIME);
 
        if (opts->raw_samples) {
@@ -663,7 +663,7 @@ void perf_evsel__config(struct perf_evsel *evsel,
        }
 
        if (opts->sample_address)
-               attr->sample_type       |= PERF_SAMPLE_DATA_SRC;
+               perf_evsel__set_sample_bit(evsel, DATA_SRC);
 
        if (opts->no_delay) {
                attr->watermark = 0;
@@ -675,11 +675,14 @@ void perf_evsel__config(struct perf_evsel *evsel,
        }
 
        if (opts->sample_weight)
-               attr->sample_type       |= PERF_SAMPLE_WEIGHT;
+               perf_evsel__set_sample_bit(evsel, WEIGHT);
 
        attr->mmap  = track;
        attr->comm  = track;
 
+       if (opts->sample_transaction)
+               perf_evsel__set_sample_bit(evsel, TRANSACTION);
+
        /*
         * XXX see the function comment above
         *
@@ -693,7 +696,7 @@ void perf_evsel__config(struct perf_evsel *evsel,
         * Setting enable_on_exec for independent events and
         * group leaders for traced executed by perf.
         */
-       if (perf_target__none(&opts->target) && perf_evsel__is_group_leader(evsel))
+       if (target__none(&opts->target) && perf_evsel__is_group_leader(evsel))
                attr->enable_on_exec = 1;
 }
 
@@ -982,6 +985,7 @@ static size_t perf_event_attr__fprintf(struct perf_event_attr *attr, FILE *fp)
        ret += PRINT_ATTR2(exclude_host, exclude_guest);
        ret += PRINT_ATTR2N("excl.callchain_kern", exclude_callchain_kernel,
                            "excl.callchain_user", exclude_callchain_user);
+       ret += PRINT_ATTR_U32(mmap2);
 
        ret += PRINT_ATTR_U32(wakeup_events);
        ret += PRINT_ATTR_U32(wakeup_watermark);
@@ -1047,6 +1051,8 @@ retry_open:
                                                                     group_fd, flags);
                        if (FD(evsel, cpu, thread) < 0) {
                                err = -errno;
+                               pr_debug2("perf_event_open failed, error %d\n",
+                                         err);
                                goto try_fallback;
                        }
                        set_rlimit = NO_CHANGE;
@@ -1213,6 +1219,7 @@ static int perf_evsel__parse_id_sample(const struct perf_evsel *evsel,
 
                sample->pid = u.val32[0];
                sample->tid = u.val32[1];
+               array--;
        }
 
        return 0;
@@ -1452,6 +1459,9 @@ int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event,
                        array = (void *)array + sz;
                        OVERFLOW_CHECK_u64(array);
                        data->user_stack.size = *array++;
+                       if (WARN_ONCE(data->user_stack.size > sz,
+                                     "user stack dump failure\n"))
+                               return -EFAULT;
                }
        }
 
@@ -1469,6 +1479,13 @@ int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event,
                array++;
        }
 
+       data->transaction = 0;
+       if (type & PERF_SAMPLE_TRANSACTION) {
+               OVERFLOW_CHECK_u64(array);
+               data->transaction = *array;
+               array++;
+       }
+
        return 0;
 }
 
@@ -1561,6 +1578,9 @@ size_t perf_event__sample_event_size(const struct perf_sample *sample, u64 type,
        if (type & PERF_SAMPLE_DATA_SRC)
                result += sizeof(u64);
 
+       if (type & PERF_SAMPLE_TRANSACTION)
+               result += sizeof(u64);
+
        return result;
 }
 
@@ -1734,6 +1754,11 @@ int perf_event__synthesize_sample(union perf_event *event, u64 type,
                array++;
        }
 
+       if (type & PERF_SAMPLE_TRANSACTION) {
+               *array = sample->transaction;
+               array++;
+       }
+
        return 0;
 }
 
@@ -1981,8 +2006,7 @@ bool perf_evsel__fallback(struct perf_evsel *evsel, int err,
        return false;
 }
 
-int perf_evsel__open_strerror(struct perf_evsel *evsel,
-                             struct perf_target *target,
+int perf_evsel__open_strerror(struct perf_evsel *evsel, struct target *target,
                              int err, char *msg, size_t size)
 {
        switch (err) {