]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - tools/perf/util/evlist.c
perf tests: Add 'keep tracking' test
[karo-tx-linux.git] / tools / perf / util / evlist.c
index 5df4ca91bed346050727e6de6394bc582b84cbcb..b8727ae45e3b9dc959734f1cd4bc9fc888a6dc4b 100644 (file)
@@ -246,7 +246,7 @@ void perf_evlist__disable(struct perf_evlist *evlist)
 
        for (cpu = 0; cpu < nr_cpus; cpu++) {
                list_for_each_entry(pos, &evlist->entries, node) {
-                       if (!perf_evsel__is_group_leader(pos))
+                       if (!perf_evsel__is_group_leader(pos) || !pos->fd)
                                continue;
                        for (thread = 0; thread < nr_threads; thread++)
                                ioctl(FD(pos, cpu, thread),
@@ -264,7 +264,7 @@ void perf_evlist__enable(struct perf_evlist *evlist)
 
        for (cpu = 0; cpu < nr_cpus; cpu++) {
                list_for_each_entry(pos, &evlist->entries, node) {
-                       if (!perf_evsel__is_group_leader(pos))
+                       if (!perf_evsel__is_group_leader(pos) || !pos->fd)
                                continue;
                        for (thread = 0; thread < nr_threads; thread++)
                                ioctl(FD(pos, cpu, thread),
@@ -273,6 +273,44 @@ void perf_evlist__enable(struct perf_evlist *evlist)
        }
 }
 
+int perf_evlist__disable_event(struct perf_evlist *evlist,
+                              struct perf_evsel *evsel)
+{
+       int cpu, thread, err;
+
+       if (!evsel->fd)
+               return 0;
+
+       for (cpu = 0; cpu < evlist->cpus->nr; cpu++) {
+               for (thread = 0; thread < evlist->threads->nr; thread++) {
+                       err = ioctl(FD(evsel, cpu, thread),
+                                   PERF_EVENT_IOC_DISABLE, 0);
+                       if (err)
+                               return err;
+               }
+       }
+       return 0;
+}
+
+int perf_evlist__enable_event(struct perf_evlist *evlist,
+                             struct perf_evsel *evsel)
+{
+       int cpu, thread, err;
+
+       if (!evsel->fd)
+               return -EINVAL;
+
+       for (cpu = 0; cpu < evlist->cpus->nr; cpu++) {
+               for (thread = 0; thread < evlist->threads->nr; thread++) {
+                       err = ioctl(FD(evsel, cpu, thread),
+                                   PERF_EVENT_IOC_ENABLE, 0);
+                       if (err)
+                               return err;
+               }
+       }
+       return 0;
+}
+
 static int perf_evlist__alloc_pollfd(struct perf_evlist *evlist)
 {
        int nr_cpus = cpu_map__nr(evlist->cpus);