linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Ahern <dsahern@gmail.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>, Jiri Olsa <jolsa@redhat.com>
Cc: linux-kernel@vger.kernel.org,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Corey Ashford <cjashfor@linux.vnet.ibm.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Ingo Molnar <mingo@kernel.org>,
	Jean Pihet <jean.pihet@linaro.org>, Jiri Olsa <jolsa@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Paul Mackerras <paulus@samba.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>
Subject: Re: [PATCH 08/10] perf kvm stat live: Use perf_evlist__add_pollfd() instead of local equivalent
Date: Tue, 26 Aug 2014 08:04:50 -0600	[thread overview]
Message-ID: <53FC9402.8080008@gmail.com> (raw)
In-Reply-To: <1408741190-5123-9-git-send-email-acme@kernel.org>

On 8/22/14, 2:59 PM, Arnaldo Carvalho de Melo wrote:
> From: Arnaldo Carvalho de Melo <acme@redhat.com>
>
> 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.
>
> 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: Jean Pihet <jean.pihet@linaro.org>
> Cc: Jiri Olsa <jolsa@kernel.org>
> 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/n/tip-2hvp9iromiheh6rl4oaa08x5@git.kernel.org
> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> ---
>   tools/perf/builtin-kvm.c | 22 +++++++++-------------
>   1 file changed, 9 insertions(+), 13 deletions(-)
>
> diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
> index 1a4ef9cd9d5f..b192234096b6 100644
> --- a/tools/perf/builtin-kvm.c
> +++ b/tools/perf/builtin-kvm.c
> @@ -921,15 +921,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) {
> @@ -937,17 +930,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);
>
> @@ -981,7 +978,6 @@ out:
>   		close(kvm->timerfd);
>
>   	tcsetattr(0, TCSAFLUSH, &save);
> -	free(pollfds);
>   	return err;
>   }
>
>

Much simpler. Looks ok to me.

Reviewed-by: David Ahern <dsahern@gmail.com>

David

  reply	other threads:[~2014-08-26 14:04 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-22 20:59 [RFC 00/10] perf pollfd series Arnaldo Carvalho de Melo
2014-08-22 20:59 ` [PATCH 01/10] perf evlist: Introduce perf_evlist__filter_pollfd method Arnaldo Carvalho de Melo
2014-08-25  6:57   ` Adrian Hunter
2014-08-22 20:59 ` [PATCH 02/10] perf tests: Add test for perf_evlist__filter_pollfd() Arnaldo Carvalho de Melo
2014-08-22 20:59 ` [PATCH 03/10] perf evlist: Monitor POLLERR and POLLHUP events too Arnaldo Carvalho de Melo
2014-08-22 20:59 ` [PATCH 04/10] perf record: Filter out POLLHUP'ed file descriptors Arnaldo Carvalho de Melo
2014-08-22 20:59 ` [PATCH 05/10] perf trace: " Arnaldo Carvalho de Melo
2014-08-22 20:59 ` [PATCH 06/10] perf evlist: Allow growing pollfd on add method Arnaldo Carvalho de Melo
2014-08-25  9:41   ` Jiri Olsa
2014-08-25  9:47   ` Jiri Olsa
2014-08-25 15:59     ` Arnaldo Carvalho de Melo
2014-08-22 20:59 ` [PATCH 07/10] perf tests: Add pollfd growing test Arnaldo Carvalho de Melo
2014-08-22 20:59 ` [PATCH 08/10] perf kvm stat live: Use perf_evlist__add_pollfd() instead of local equivalent Arnaldo Carvalho de Melo
2014-08-26 14:04   ` David Ahern [this message]
2014-08-22 20:59 ` [PATCH 09/10] perf evlist: Introduce poll method for common code idiom Arnaldo Carvalho de Melo
2014-08-22 20:59 ` [PATCH 10/10] tools lib api: Adopt fdarray class from perf's evlist Arnaldo Carvalho de Melo
2014-08-26  7:46   ` Namhyung Kim
2014-08-26 13:08     ` Arnaldo Carvalho de Melo
2014-08-25 11:04 ` [RFC 00/10] perf pollfd series Jiri Olsa
2014-08-25 15:56   ` Arnaldo Carvalho de Melo
  -- strict thread matches above, loose matches on Subject: below --
2014-09-03 21:59 [RFC 00/10] perf pollfd series v2 Arnaldo Carvalho de Melo
2014-09-03 22:00 ` [PATCH 08/10] perf kvm stat live: Use perf_evlist__add_pollfd() instead of local equivalent Arnaldo Carvalho de Melo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53FC9402.8080008@gmail.com \
    --to=dsahern@gmail.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=adrian.hunter@intel.com \
    --cc=cjashfor@linux.vnet.ibm.com \
    --cc=fweisbec@gmail.com \
    --cc=jean.pihet@linaro.org \
    --cc=jolsa@kernel.org \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).