Messages in this thread Patch in this message | | | Date | Mon, 23 May 2016 18:24:55 -0300 | From | Arnaldo Carvalho de Melo <> | Subject | Re: [PATCH v3 01/11] perf tools: Add API to pause/resume a evlist |
| |
Em Mon, May 23, 2016 at 07:13:38AM +0000, Wang Nan escreveu: > +++ b/tools/perf/util/evlist.c > @@ -679,6 +679,38 @@ static struct perf_evsel *perf_evlist__event2evsel(struct perf_evlist *evlist, > return NULL; > } > > +static int perf_evlist__set_paused(struct perf_evlist *evlist, bool pause) > +{ > + int i; > + > + for (i = 0; i < evlist->nr_mmaps; i++) { > + int fd = evlist->mmap[i].fd; > + int err; > + > + if (fd < 0) > + continue; > + err = ioctl(fd, PERF_EVENT_IOC_PAUSE_OUTPUT, > + pause ? 1 : 0); > + if (err) { > + err = (errno == 0 ? -EINVAL : -errno); > + pr_err("Unable to pause output on %d: %s\n", > + fd, strerror(-err));
I changed this to: if (err) return err;
Like all other ioctl wrappers in evlist.c, i.e. usage model is the same as with 'ioctl()': -1 indicates that it failed, if code using this function wants to know more about the reason for the error, check errno.
Ah, we can't use 'pause' as a parameter name, that breaks the build on Ubuntu 12.04 and other old glibc headers, I fixed that as well.
- Arnaldo
> + return err; > + } > + } > + return 0;
| |