From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932200AbcEMNMW (ORCPT ); Fri, 13 May 2016 09:12:22 -0400 Received: from mail.kernel.org ([198.145.29.136]:35400 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751900AbcEMNMU (ORCPT ); Fri, 13 May 2016 09:12:20 -0400 Date: Fri, 13 May 2016 10:12:09 -0300 From: Arnaldo Carvalho de Melo To: Wang Nan Cc: arnaldo.melo@gmail.com, linux-kernel@vger.kernel.org, He Kuang , Arnaldo Carvalho de Melo , Jiri Olsa , Masami Hiramatsu , Namhyung Kim , Zefan Li , pi3orama@163.com Subject: Re: [PATCH 08/17] perf record: Don't poll on overwrite channel Message-ID: <20160513131209.GJ11346@kernel.org> References: <1463126174-119290-1-git-send-email-wangnan0@huawei.com> <1463126174-119290-9-git-send-email-wangnan0@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1463126174-119290-9-git-send-email-wangnan0@huawei.com> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.6.0 (2016-04-01) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Fri, May 13, 2016 at 07:56:05AM +0000, Wang Nan escreveu: > There's no need to receive events from overwritable ring buffer. Instead, > perf should make them run background until something happen. This patch > makes normal events from overwrite ring buffer ignored. > > Signed-off-by: Wang Nan > Signed-off-by: He Kuang > Cc: Arnaldo Carvalho de Melo > Cc: Jiri Olsa > Cc: Masami Hiramatsu > Cc: Namhyung Kim > Cc: Zefan Li > Cc: pi3orama@163.com > --- > tools/perf/util/evlist.c | 23 +++++++++++++++++++---- > 1 file changed, 19 insertions(+), 4 deletions(-) > > diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c > index abce588..f0b0457 100644 > --- a/tools/perf/util/evlist.c > +++ b/tools/perf/util/evlist.c > @@ -461,9 +461,9 @@ int perf_evlist__alloc_pollfd(struct perf_evlist *evlist) > return 0; > } > > -static int __perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd, int idx) > +static int __perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd, int idx, short revent) > { > - int pos = fdarray__add(&evlist->pollfd, fd, POLLIN | POLLERR | POLLHUP); > + int pos = fdarray__add(&evlist->pollfd, fd, revent | POLLERR | POLLHUP); > /* > * Save the idx so that when we filter out fds POLLHUP'ed we can > * close the associated evlist->mmap[] entry. > @@ -479,7 +479,7 @@ static int __perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd, int idx > > int perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd) > { > - return __perf_evlist__add_pollfd(evlist, fd, -1); > + return __perf_evlist__add_pollfd(evlist, fd, -1, POLLIN); > } > > static void perf_evlist__munmap_filtered(struct fdarray *fda, int fd) > @@ -1077,6 +1077,18 @@ perf_evlist__channel_complete(struct perf_evlist *evlist) > return 0; > } > > +static bool > +perf_evlist__should_poll(struct perf_evlist *evlist, > + struct perf_evsel *evsel, > + int channel) > +{ > + if (evsel->system_wide) > + return false; So, what is the above doing in this patch? If we should not poll when in syswide mode, then this should be in a separate patch, unrelated to 'channels'. No? I.e. it would be an improvement that would be cherry pickable right now, even before reviewing the channel concept. - Arnaldo > + if (perf_evlist__channel_check(evlist, channel, RDONLY)) > + return false; > + return true; > +} > + > static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int _idx, > struct mmap_params *mp, int cpu, > int thread, int *outputs) > @@ -1085,6 +1097,7 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int _idx, > > evlist__for_each(evlist, evsel) { > int fd, channel, idx, err; > + short revent = POLLIN; > > channel = perf_evlist__channel_find(evlist, evsel, false); > if (channel < 0) { > @@ -1114,6 +1127,8 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int _idx, > perf_evlist__mmap_get(evlist, idx); > } > > + if (!perf_evlist__should_poll(evlist, evsel, channel)) > + revent = 0; > /* > * The system_wide flag causes a selected event to be opened > * always without a pid. Consequently it will never get a > @@ -1122,7 +1137,7 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int _idx, > * Therefore don't add it for polling. > */ > if (!evsel->system_wide && > - __perf_evlist__add_pollfd(evlist, fd, idx) < 0) { > + __perf_evlist__add_pollfd(evlist, fd, idx, revent) < 0) { > perf_evlist__mmap_put(evlist, idx); > return -1; > } > -- > 1.8.3.4