Commit 1ca72260 authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo

perf kvm stat live: Use fdarray object instead of pollfd

The reason is that we don't need to count the number of file descriptors
because it's already handled in fdarray object.
Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Milian Wolff <mail@milianw.de>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1412179229-19466-5-git-send-email-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 0cae013c
...@@ -896,8 +896,7 @@ static int perf_kvm__handle_stdin(void) ...@@ -896,8 +896,7 @@ static int perf_kvm__handle_stdin(void)
static int kvm_events_live_report(struct perf_kvm_stat *kvm) static int kvm_events_live_report(struct perf_kvm_stat *kvm)
{ {
struct pollfd *pollfds = NULL; int nr_stdin, ret, err = -EINVAL;
int nr_fds, nr_stdin, ret, err = -EINVAL;
struct termios save; struct termios save;
/* live flag must be set first */ /* live flag must be set first */
...@@ -919,9 +918,6 @@ static int kvm_events_live_report(struct perf_kvm_stat *kvm) ...@@ -919,9 +918,6 @@ static int kvm_events_live_report(struct perf_kvm_stat *kvm)
signal(SIGINT, sig_handler); signal(SIGINT, sig_handler);
signal(SIGTERM, sig_handler); signal(SIGTERM, sig_handler);
/* use pollfds -- need to add timerfd and stdin */
nr_fds = kvm->evlist->pollfd.nr;
/* add timer fd */ /* add timer fd */
if (perf_kvm__timerfd_create(kvm) < 0) { if (perf_kvm__timerfd_create(kvm) < 0) {
err = -1; err = -1;
...@@ -931,22 +927,18 @@ static int kvm_events_live_report(struct perf_kvm_stat *kvm) ...@@ -931,22 +927,18 @@ static int kvm_events_live_report(struct perf_kvm_stat *kvm)
if (perf_evlist__add_pollfd(kvm->evlist, kvm->timerfd) < 0) if (perf_evlist__add_pollfd(kvm->evlist, kvm->timerfd) < 0)
goto out; goto out;
nr_fds++;
nr_stdin = perf_evlist__add_pollfd(kvm->evlist, fileno(stdin)); nr_stdin = perf_evlist__add_pollfd(kvm->evlist, fileno(stdin));
if (nr_stdin < 0) if (nr_stdin < 0)
goto out; goto out;
nr_fds++;
if (fd_set_nonblock(fileno(stdin)) != 0) if (fd_set_nonblock(fileno(stdin)) != 0)
goto out; goto out;
pollfds = kvm->evlist->pollfd.entries;
/* everything is good - enable the events and process */ /* everything is good - enable the events and process */
perf_evlist__enable(kvm->evlist); perf_evlist__enable(kvm->evlist);
while (!done) { while (!done) {
struct fdarray *fda = &kvm->evlist->pollfd;
int rc; int rc;
rc = perf_kvm__mmap_read(kvm); rc = perf_kvm__mmap_read(kvm);
...@@ -957,11 +949,11 @@ static int kvm_events_live_report(struct perf_kvm_stat *kvm) ...@@ -957,11 +949,11 @@ static int kvm_events_live_report(struct perf_kvm_stat *kvm)
if (err) if (err)
goto out; goto out;
if (pollfds[nr_stdin].revents & POLLIN) if (fda->entries[nr_stdin].revents & POLLIN)
done = perf_kvm__handle_stdin(); done = perf_kvm__handle_stdin();
if (!rc && !done) if (!rc && !done)
err = poll(pollfds, nr_fds, 100); err = fdarray__poll(fda, 100);
} }
perf_evlist__disable(kvm->evlist); perf_evlist__disable(kvm->evlist);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment