diff options
author | Jiri Olsa <jolsa@kernel.org> | 2014-10-01 12:00:29 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-10-03 08:39:48 -0400 |
commit | 1ca72260e471a8b03f03fe9a6547deb088710042 (patch) | |
tree | 5bdcb4f5026ae814071d661611d33dbafeaa1131 /tools | |
parent | 0cae013cf4450ea0ecb62241a2f3e7565db09f93 (diff) |
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: Jiri 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.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/builtin-kvm.c | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index dc7d704735bd..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) | |||
896 | 896 | ||
897 | static int kvm_events_live_report(struct perf_kvm_stat *kvm) | 897 | static int kvm_events_live_report(struct perf_kvm_stat *kvm) |
898 | { | 898 | { |
899 | struct pollfd *pollfds = NULL; | 899 | int nr_stdin, ret, err = -EINVAL; |
900 | int nr_fds, nr_stdin, ret, err = -EINVAL; | ||
901 | struct termios save; | 900 | struct termios save; |
902 | 901 | ||
903 | /* live flag must be set first */ | 902 | /* live flag must be set first */ |
@@ -919,9 +918,6 @@ static int kvm_events_live_report(struct perf_kvm_stat *kvm) | |||
919 | signal(SIGINT, sig_handler); | 918 | signal(SIGINT, sig_handler); |
920 | signal(SIGTERM, sig_handler); | 919 | signal(SIGTERM, sig_handler); |
921 | 920 | ||
922 | /* use pollfds -- need to add timerfd and stdin */ | ||
923 | nr_fds = kvm->evlist->pollfd.nr; | ||
924 | |||
925 | /* add timer fd */ | 921 | /* add timer fd */ |
926 | if (perf_kvm__timerfd_create(kvm) < 0) { | 922 | if (perf_kvm__timerfd_create(kvm) < 0) { |
927 | err = -1; | 923 | err = -1; |
@@ -931,22 +927,18 @@ static int kvm_events_live_report(struct perf_kvm_stat *kvm) | |||
931 | if (perf_evlist__add_pollfd(kvm->evlist, kvm->timerfd) < 0) | 927 | if (perf_evlist__add_pollfd(kvm->evlist, kvm->timerfd) < 0) |
932 | goto out; | 928 | goto out; |
933 | 929 | ||
934 | nr_fds++; | ||
935 | |||
936 | nr_stdin = perf_evlist__add_pollfd(kvm->evlist, fileno(stdin)); | 930 | nr_stdin = perf_evlist__add_pollfd(kvm->evlist, fileno(stdin)); |
937 | if (nr_stdin < 0) | 931 | if (nr_stdin < 0) |
938 | goto out; | 932 | goto out; |
939 | 933 | ||
940 | nr_fds++; | ||
941 | if (fd_set_nonblock(fileno(stdin)) != 0) | 934 | if (fd_set_nonblock(fileno(stdin)) != 0) |
942 | goto out; | 935 | goto out; |
943 | 936 | ||
944 | pollfds = kvm->evlist->pollfd.entries; | ||
945 | |||
946 | /* everything is good - enable the events and process */ | 937 | /* everything is good - enable the events and process */ |
947 | perf_evlist__enable(kvm->evlist); | 938 | perf_evlist__enable(kvm->evlist); |
948 | 939 | ||
949 | while (!done) { | 940 | while (!done) { |
941 | struct fdarray *fda = &kvm->evlist->pollfd; | ||
950 | int rc; | 942 | int rc; |
951 | 943 | ||
952 | rc = perf_kvm__mmap_read(kvm); | 944 | rc = perf_kvm__mmap_read(kvm); |
@@ -957,11 +949,11 @@ static int kvm_events_live_report(struct perf_kvm_stat *kvm) | |||
957 | if (err) | 949 | if (err) |
958 | goto out; | 950 | goto out; |
959 | 951 | ||
960 | if (pollfds[nr_stdin].revents & POLLIN) | 952 | if (fda->entries[nr_stdin].revents & POLLIN) |
961 | done = perf_kvm__handle_stdin(); | 953 | done = perf_kvm__handle_stdin(); |
962 | 954 | ||
963 | if (!rc && !done) | 955 | if (!rc && !done) |
964 | err = poll(pollfds, nr_fds, 100); | 956 | err = fdarray__poll(fda, 100); |
965 | } | 957 | } |
966 | 958 | ||
967 | perf_evlist__disable(kvm->evlist); | 959 | perf_evlist__disable(kvm->evlist); |