- assert(FD(evsel, cpu, thread_index) >= 0);
- fcntl(FD(evsel, cpu, thread_index), F_SETFL, O_NONBLOCK);
-
- if (evsel->idx || thread_index) {
- struct perf_evsel *first;
- first = list_entry(evlist->entries.next, struct perf_evsel, node);
- ret = ioctl(FD(evsel, cpu, thread_index),
- PERF_EVENT_IOC_SET_OUTPUT,
- FD(first, cpu, 0));
- if (ret) {
- error("failed to set output: %d (%s)\n", errno,
- strerror(errno));
- exit(-1);
- }
- } else {
- mmap_array[cpu].prev = 0;
- mmap_array[cpu].mask = mmap_pages*page_size - 1;
- mmap_array[cpu].base = mmap(NULL, (mmap_pages+1)*page_size,
- PROT_READ | PROT_WRITE, MAP_SHARED, FD(evsel, cpu, thread_index), 0);
- if (mmap_array[cpu].base == MAP_FAILED) {
- error("failed to mmap with %d (%s)\n", errno, strerror(errno));
- exit(-1);
- }
-
- evlist->pollfd[evlist->nr_fds].fd = FD(evsel, cpu, thread_index);
- evlist->pollfd[evlist->nr_fds].events = POLLIN;
- evlist->nr_fds++;
- }
-