summaryrefslogtreecommitdiff
path: root/tools/perf/builtin-kvm.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/builtin-kvm.c')
-rw-r--r--tools/perf/builtin-kvm.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index d8bf2271f4ea..460a4ce9c044 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -896,8 +896,7 @@ static int perf_kvm__handle_stdin(void)
static int kvm_events_live_report(struct perf_kvm_stat *kvm)
{
- struct pollfd *pollfds = NULL;
- int nr_fds, nr_stdin, ret, err = -EINVAL;
+ int nr_stdin, ret, err = -EINVAL;
struct termios save;
/* live flag must be set first */
@@ -919,34 +918,27 @@ static int kvm_events_live_report(struct perf_kvm_stat *kvm)
signal(SIGINT, sig_handler);
signal(SIGTERM, sig_handler);
- /* use pollfds -- need to add timerfd and stdin */
- nr_fds = kvm->evlist->pollfd.nr;
-
/* add timer fd */
if (perf_kvm__timerfd_create(kvm) < 0) {
err = -1;
goto out;
}
- if (perf_evlist__add_pollfd(kvm->evlist, kvm->timerfd))
+ if (perf_evlist__add_pollfd(kvm->evlist, kvm->timerfd) < 0)
goto out;
- nr_fds++;
-
- if (perf_evlist__add_pollfd(kvm->evlist, fileno(stdin)))
+ nr_stdin = perf_evlist__add_pollfd(kvm->evlist, fileno(stdin));
+ if (nr_stdin < 0)
goto out;
- nr_stdin = nr_fds;
- nr_fds++;
if (fd_set_nonblock(fileno(stdin)) != 0)
goto out;
- pollfds = kvm->evlist->pollfd.entries;
-
/* everything is good - enable the events and process */
perf_evlist__enable(kvm->evlist);
while (!done) {
+ struct fdarray *fda = &kvm->evlist->pollfd;
int rc;
rc = perf_kvm__mmap_read(kvm);
@@ -957,11 +949,11 @@ static int kvm_events_live_report(struct perf_kvm_stat *kvm)
if (err)
goto out;
- if (pollfds[nr_stdin].revents & POLLIN)
+ if (fda->entries[nr_stdin].revents & POLLIN)
done = perf_kvm__handle_stdin();
if (!rc && !done)
- err = poll(pollfds, nr_fds, 100);
+ err = fdarray__poll(fda, 100);
}
perf_evlist__disable(kvm->evlist);