tools: rename bitmap_alloc() to bitmap_zalloc()
[linux-2.6-microblaze.git] / tools / perf / builtin-record.c
index 84803ab..f1b30ac 100644 (file)
@@ -891,11 +891,12 @@ static int record__open(struct record *rec)
        int rc = 0;
 
        /*
-        * For initial_delay or system wide, we need to add a dummy event so
-        * that we can track PERF_RECORD_MMAP to cover the delay of waiting or
-        * event synthesis.
+        * For initial_delay, system wide or a hybrid system, we need to add a
+        * dummy event so that we can track PERF_RECORD_MMAP to cover the delay
+        * of waiting or event synthesis.
         */
-       if (opts->initial_delay || target__has_cpu(&opts->target)) {
+       if (opts->initial_delay || target__has_cpu(&opts->target) ||
+           perf_pmu__has_hybrid()) {
                pos = evlist__get_tracking_event(evlist);
                if (!evsel__is_dummy_event(pos)) {
                        /* Set up dummy event. */
@@ -926,7 +927,7 @@ try_again:
                                goto try_again;
                        }
                        if ((errno == EINVAL || errno == EBADF) &&
-                           pos->leader != pos &&
+                           pos->core.leader != &pos->core &&
                            pos->weak_group) {
                                pos = evlist__reset_weak_group(evlist, pos, true);
                                goto try_again;
@@ -969,6 +970,15 @@ out:
        return rc;
 }
 
+static void set_timestamp_boundary(struct record *rec, u64 sample_time)
+{
+       if (rec->evlist->first_sample_time == 0)
+               rec->evlist->first_sample_time = sample_time;
+
+       if (sample_time)
+               rec->evlist->last_sample_time = sample_time;
+}
+
 static int process_sample_event(struct perf_tool *tool,
                                union perf_event *event,
                                struct perf_sample *sample,
@@ -977,10 +987,7 @@ static int process_sample_event(struct perf_tool *tool,
 {
        struct record *rec = container_of(tool, struct record, tool);
 
-       if (rec->evlist->first_sample_time == 0)
-               rec->evlist->first_sample_time = sample->time;
-
-       rec->evlist->last_sample_time = sample->time;
+       set_timestamp_boundary(rec, sample->time);
 
        if (rec->buildid_all)
                return 0;
@@ -1770,7 +1777,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
                rec->tool.ordered_events = false;
        }
 
-       if (!rec->evlist->nr_groups)
+       if (!rec->evlist->core.nr_groups)
                perf_header__clear_feat(&session->header, HEADER_GROUP_DESC);
 
        if (data->is_pipe) {
@@ -2402,6 +2409,17 @@ static int build_id__process_mmap2(struct perf_tool *tool, union perf_event *eve
        return perf_event__process_mmap2(tool, event, sample, machine);
 }
 
+static int process_timestamp_boundary(struct perf_tool *tool,
+                                     union perf_event *event __maybe_unused,
+                                     struct perf_sample *sample,
+                                     struct machine *machine __maybe_unused)
+{
+       struct record *rec = container_of(tool, struct record, tool);
+
+       set_timestamp_boundary(rec, sample->time);
+       return 0;
+}
+
 /*
  * XXX Ideally would be local to cmd_record() and passed to a record__new
  * because we need to have access to it in record__exit, that is called
@@ -2436,6 +2454,8 @@ static struct record record = {
                .namespaces     = perf_event__process_namespaces,
                .mmap           = build_id__process_mmap,
                .mmap2          = build_id__process_mmap2,
+               .itrace_start   = process_timestamp_boundary,
+               .aux            = process_timestamp_boundary,
                .ordered_events = true,
        },
 };
@@ -2766,7 +2786,7 @@ int cmd_record(int argc, const char **argv)
 
        if (rec->opts.affinity != PERF_AFFINITY_SYS) {
                rec->affinity_mask.nbits = cpu__max_cpu();
-               rec->affinity_mask.bits = bitmap_alloc(rec->affinity_mask.nbits);
+               rec->affinity_mask.bits = bitmap_zalloc(rec->affinity_mask.nbits);
                if (!rec->affinity_mask.bits) {
                        pr_err("Failed to allocate thread mask for %zd cpus\n", rec->affinity_mask.nbits);
                        err = -ENOMEM;