mirror of
https://github.com/torvalds/linux.git
synced 2026-10-07 05:31:08 -04:00
perf kvm stat live: Use perf_evlist__add_pollfd() instead of local equivalent
Since we can add file descriptors to the evlist pollfd and it will autogrow, no need to copy all events to a local pollfd array, just add the timer and stdin file descriptors. Reviewed-by: David Ahern <[email protected]> Acked-by: Jiri Olsa <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Corey Ashford <[email protected]> Cc: David Ahern <[email protected]> Cc: Frederic Weisbecker <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jean Pihet <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Paul Mackerras <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lkml.kernel.org/n/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
This commit is contained in:
1 parent
9ae28035b8
commit
0a04c9e0b2
1 file changed
+9
-13
@@ -919,15 +919,8 @@ static int kvm_events_live_report(struct perf_kvm_stat *kvm)
|
||||
signal(SIGINT, sig_handler);
|
||||
signal(SIGTERM, sig_handler);
|
||||
|
||||
/* copy pollfds -- need to add timerfd and stdin */
|
||||
/* use pollfds -- need to add timerfd and stdin */
|
||||
nr_fds = kvm->evlist->nr_fds;
|
||||
pollfds = zalloc(sizeof(struct pollfd) * (nr_fds + 2));
|
||||
if (!pollfds) {
|
||||
err = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
memcpy(pollfds, kvm->evlist->pollfd,
|
||||
sizeof(struct pollfd) * kvm->evlist->nr_fds);
|
||||
|
||||
/* add timer fd */
|
||||
if (perf_kvm__timerfd_create(kvm) < 0) {
|
||||
@@ -935,17 +928,21 @@ static int kvm_events_live_report(struct perf_kvm_stat *kvm)
|
||||
goto out;
|
||||
}
|
||||
|
||||
pollfds[nr_fds].fd = kvm->timerfd;
|
||||
pollfds[nr_fds].events = POLLIN;
|
||||
if (perf_evlist__add_pollfd(kvm->evlist, kvm->timerfd))
|
||||
goto out;
|
||||
|
||||
nr_fds++;
|
||||
|
||||
pollfds[nr_fds].fd = fileno(stdin);
|
||||
pollfds[nr_fds].events = POLLIN;
|
||||
if (perf_evlist__add_pollfd(kvm->evlist, fileno(stdin)))
|
||||
goto out;
|
||||
|
||||
nr_stdin = nr_fds;
|
||||
nr_fds++;
|
||||
if (fd_set_nonblock(fileno(stdin)) != 0)
|
||||
goto out;
|
||||
|
||||
pollfds = kvm->evlist->pollfd;
|
||||
|
||||
/* everything is good - enable the events and process */
|
||||
perf_evlist__enable(kvm->evlist);
|
||||
|
||||
@@ -979,7 +976,6 @@ out:
|
||||
close(kvm->timerfd);
|
||||
|
||||
tcsetattr(0, TCSAFLUSH, &save);
|
||||
free(pollfds);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user