These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / tools / perf / util / record.c
index 8acd0df..0467367 100644 (file)
@@ -20,7 +20,7 @@ static int perf_do_probe_api(setup_probe_fn_t fn, int cpu, const char *str)
        if (!evlist)
                return -ENOMEM;
 
-       if (parse_events(evlist, str))
+       if (parse_events(evlist, str, NULL))
                goto out_delete;
 
        evsel = perf_evlist__first(evlist);
@@ -64,7 +64,7 @@ static bool perf_probe_api(setup_probe_fn_t fn)
        if (!cpus)
                return false;
        cpu = cpus->map[0];
-       cpu_map__delete(cpus);
+       cpu_map__put(cpus);
 
        do {
                ret = perf_do_probe_api(fn, cpu, try[i++]);
@@ -85,6 +85,11 @@ static void perf_probe_comm_exec(struct perf_evsel *evsel)
        evsel->attr.comm_exec = 1;
 }
 
+static void perf_probe_context_switch(struct perf_evsel *evsel)
+{
+       evsel->attr.context_switch = 1;
+}
+
 bool perf_can_sample_identifier(void)
 {
        return perf_probe_api(perf_probe_sample_identifier);
@@ -95,6 +100,35 @@ static bool perf_can_comm_exec(void)
        return perf_probe_api(perf_probe_comm_exec);
 }
 
+bool perf_can_record_switch_events(void)
+{
+       return perf_probe_api(perf_probe_context_switch);
+}
+
+bool perf_can_record_cpu_wide(void)
+{
+       struct perf_event_attr attr = {
+               .type = PERF_TYPE_SOFTWARE,
+               .config = PERF_COUNT_SW_CPU_CLOCK,
+               .exclude_kernel = 1,
+       };
+       struct cpu_map *cpus;
+       int cpu, fd;
+
+       cpus = cpu_map__new(NULL);
+       if (!cpus)
+               return false;
+       cpu = cpus->map[0];
+       cpu_map__put(cpus);
+
+       fd = sys_perf_event_open(&attr, -1, cpu, -1, 0);
+       if (fd < 0)
+               return false;
+       close(fd);
+
+       return true;
+}
+
 void perf_evlist__config(struct perf_evlist *evlist, struct record_opts *opts)
 {
        struct perf_evsel *evsel;
@@ -119,7 +153,16 @@ void perf_evlist__config(struct perf_evlist *evlist, struct record_opts *opts)
                        evsel->attr.comm_exec = 1;
        }
 
-       if (evlist->nr_entries > 1) {
+       if (opts->full_auxtrace) {
+               /*
+                * Need to be able to synthesize and parse selected events with
+                * arbitrary sample types, which requires always being able to
+                * match the id.
+                */
+               use_sample_identifier = perf_can_sample_identifier();
+               evlist__for_each(evlist, evsel)
+                       perf_evsel__set_sample_id(evsel, use_sample_identifier);
+       } else if (evlist->nr_entries > 1) {
                struct perf_evsel *first = perf_evlist__first(evlist);
 
                evlist__for_each(evlist, evsel) {
@@ -207,7 +250,7 @@ bool perf_evlist__can_select_event(struct perf_evlist *evlist, const char *str)
        if (!temp_evlist)
                return false;
 
-       err = parse_events(temp_evlist, str);
+       err = parse_events(temp_evlist, str, NULL);
        if (err)
                goto out_delete;
 
@@ -217,7 +260,7 @@ bool perf_evlist__can_select_event(struct perf_evlist *evlist, const char *str)
                struct cpu_map *cpus = cpu_map__new(NULL);
 
                cpu =  cpus ? cpus->map[0] : 0;
-               cpu_map__delete(cpus);
+               cpu_map__put(cpus);
        } else {
                cpu = evlist->cpus->map[0];
        }