From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754122AbbJBSrH (ORCPT ); Fri, 2 Oct 2015 14:47:07 -0400 Received: from mail.kernel.org ([198.145.29.136]:44030 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752068AbbJBSrE (ORCPT ); Fri, 2 Oct 2015 14:47:04 -0400 Date: Fri, 2 Oct 2015 15:47:00 -0300 From: Arnaldo Carvalho de Melo To: Namhyung Kim Cc: Ingo Molnar , Peter Zijlstra , Jiri Olsa , LKML , Frederic Weisbecker , Stephane Eranian , David Ahern , Andi Kleen Subject: Re: [RFC/PATCH 04/38] perf tools: pass perf_mmap desc directly Message-ID: <20151002184700.GC4736@kernel.org> References: <1443763159-29098-1-git-send-email-namhyung@kernel.org> <1443763159-29098-5-git-send-email-namhyung@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1443763159-29098-5-git-send-email-namhyung@kernel.org> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Fri, Oct 02, 2015 at 02:18:45PM +0900, Namhyung Kim escreveu: > Pass struct perf_mmap to mmap handling functions directly. This will > be used by both of normal mmap and track mmap later. > > Signed-off-by: Namhyung Kim > --- > tools/perf/util/evlist.c | 24 +++++++++++++++--------- > tools/perf/util/evlist.h | 1 + > 2 files changed, 16 insertions(+), 9 deletions(-) > > diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c > index 042dffc67986..8d31883cbeb8 100644 > --- a/tools/perf/util/evlist.c > +++ b/tools/perf/util/evlist.c > @@ -921,8 +921,8 @@ struct mmap_params { > struct auxtrace_mmap_params auxtrace_mp; > }; > > -static int __perf_evlist__mmap(struct perf_evlist *evlist, int idx, > - struct mmap_params *mp, int fd) > +static int perf_mmap__mmap(struct perf_mmap *desc, > + struct mmap_params *mp, int fd) > { > /* > * The last one will be done at perf_evlist__mmap_consume(), so that we > @@ -937,21 +937,26 @@ static int __perf_evlist__mmap(struct perf_evlist *evlist, int idx, > * evlist layer can't just drop it when filtering events in > * perf_evlist__filter_pollfd(). > */ > - atomic_set(&evlist->mmap[idx].refcnt, 2); > - evlist->mmap[idx].prev = 0; > - evlist->mmap[idx].mask = perf_evlist__mmap_mask(mp->len); > - evlist->mmap[idx].base = mmap(NULL, mp->len, mp->prot, > + atomic_set(&desc->refcnt, 2); > + desc->prev = 0; > + desc->mask = perf_evlist__mmap_mask(mp->len); > + desc->base = mmap(NULL, mp->len, mp->prot, > MAP_SHARED, fd, 0); > - if (evlist->mmap[idx].base == MAP_FAILED) { > + if (desc->base == MAP_FAILED) { > pr_debug2("failed to mmap perf event ring buffer, error %d\n", > errno); > - evlist->mmap[idx].base = NULL; > + desc->base = NULL; > return -1; > } > > return 0; > } > > +struct perf_mmap *perf_evlist__mmap_desc(struct perf_evlist *evlist, int idx) > +{ > + return &evlist->mmap[idx]; > +} > + What does 'desc' stands for? Why not just use evlist->mmap[idx]? > static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx, > struct mmap_params *mp, int cpu, > int thread, int *output) > @@ -960,6 +965,7 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx, > > evlist__for_each(evlist, evsel) { > int fd; > + struct perf_mmap *desc = perf_evlist__mmap_desc(evlist, idx); > > if (evsel->system_wide && thread) > continue; > @@ -968,7 +974,7 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx, > > if (*output == -1) { > *output = fd; > - if (__perf_evlist__mmap(evlist, idx, mp, *output) < 0) > + if (perf_mmap__mmap(desc, mp, *output) < 0) > return -1; > > if (auxtrace_mmap__mmap(&evlist->auxtrace_mmap[idx], > diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h > index 51574ce8ac69..79f8245300ad 100644 > --- a/tools/perf/util/evlist.h > +++ b/tools/perf/util/evlist.h > @@ -145,6 +145,7 @@ int perf_evlist__mmap_ex(struct perf_evlist *evlist, unsigned int pages, > int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages, > bool overwrite); > void perf_evlist__munmap(struct perf_evlist *evlist); > +struct perf_mmap *perf_evlist__mmap_desc(struct perf_evlist *evlist, int idx); > > void perf_evlist__disable(struct perf_evlist *evlist); > void perf_evlist__enable(struct perf_evlist *evlist); > -- > 2.6.0