mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: a.p.zijlstra@chello.nl, mingo@elte.hu, paulus@samba.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/5] perf tool: Introducing perf_mmap object
Date: Sat, 19 Nov 2011 20:39:07 -0500	[thread overview]
Message-ID: <20111120013907.GB2248@krava.redhat.com> (raw)
In-Reply-To: <20111118143740.GD13052@ghostprotocols.net>

On Fri, Nov 18, 2011 at 12:37:40PM -0200, Arnaldo Carvalho de Melo wrote:
> Em Fri, Nov 18, 2011 at 02:46:43PM +0100, Jiri Olsa escreveu:
> > +++ b/tools/perf/builtin-test.c
> > @@ -476,6 +477,7 @@ static int test__basic_mmap(void)
> >  		     expected_nr_events[nsyscalls], i, j;
> >  	struct perf_evsel *evsels[nsyscalls], *evsel;
> >  	int sample_size = __perf_evsel__sample_size(attr.sample_type);
> > +	struct perf_mmap *md;
> >  
> >  	for (i = 0; i < nsyscalls; ++i) {
> >  		char name[64];
> > @@ -551,7 +553,9 @@ static int test__basic_mmap(void)
> >  			++foo;
> >  		}
> >  
> > -	while ((event = perf_evlist__mmap_read(evlist, 0)) != NULL) {
> > +	md = &evlist->mmap[0];
> > +
> > +	while ((event = perf_mmap__read(md)) != NULL) {
> >  		struct perf_sample sample;
> >  
> >  		if (event->header.type != PERF_RECORD_SAMPLE) {
> 
> Please keep perf_evlist__mmap_read() as just a wrapper for the above
> operation, that way you reduce the patch size by not touching the
> functions that use perf_evlist__mmap_read().
> 
> Later, if we think this is the right thing to do, i.e. to open code it
> like you're doing above, we can elliminate it, but I think its better to
> keep it as perf_evlist__mmap_read(evlist, 0) as it uses just one line
> instead of the 4 above :-)

right, I'll sent v2 shortly

> 
> > diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
> > index 8e02027..032f70d 100644
> > --- a/tools/perf/builtin-top.c
> > +++ b/tools/perf/builtin-top.c
> > @@ -38,6 +38,7 @@

SNIP

> >  void perf_evlist__munmap(struct perf_evlist *evlist)
> >  {
> >  	int i;
> >  
> >  	for (i = 0; i < evlist->nr_mmaps; i++) {
> > -		if (evlist->mmap[i].base != NULL) {
> > -			munmap(evlist->mmap[i].base, evlist->mmap_len);
> > -			evlist->mmap[i].base = NULL;
> > -		}
> > +		struct perf_mmap *m = &evlist->mmap[i];
> > +		if (m->base != NULL)
> > +			perf_mmap__close(m);
> 
> Wouldn't it be perf_mmap__munmap() ? 
> 
> >  	}
> >  
> >  	free(evlist->mmap);
> > @@ -292,20 +225,18 @@ int perf_evlist__alloc_mmap(struct perf_evlist *evlist)
> >  }
> >  
> >  static int __perf_evlist__mmap(struct perf_evlist *evlist,
> > -			       int idx, int prot, int mask, int fd)
> > +			       int idx, int fd)
> >  {
> > -	evlist->mmap[idx].prev = 0;
> > -	evlist->mmap[idx].mask = mask;
> > -	evlist->mmap[idx].base = mmap(NULL, evlist->mmap_len, prot,
> > -				      MAP_SHARED, fd, 0);
> > -	if (evlist->mmap[idx].base == MAP_FAILED)
> > +	struct perf_mmap *m = &evlist->mmap[idx];
> > +
> > +	if (perf_mmap__open(m, fd, evlist->overwrite, evlist->pages))
> 
> And here perf_mmap__mmap or at least perf_mmap__map and the other
> perf_mmap__unmap?

not sure, perf_mmap__open and perf_mmap__close actually does map/umap..
maybe we can rename them ;)

  reply	other threads:[~2011-11-19 18:41 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-18 13:46 [RFC,PATCH] perf tool: Refactoring IO data files code Jiri Olsa
2011-11-18 13:46 ` [PATCH 1/5] perf tool: Fix session host_nachine retrieval Jiri Olsa
2011-11-18 14:24   ` Arnaldo Carvalho de Melo
2011-11-18 13:46 ` [PATCH 2/5] perf tool: Initialize events IDs in a single function Jiri Olsa
2011-11-18 14:22   ` Arnaldo Carvalho de Melo
2011-11-20  1:36     ` Jiri Olsa
2011-11-20  1:03       ` Arnaldo Carvalho de Melo
2011-11-18 13:46 ` [PATCH 3/5] perf tool: Introducing perf_mmap object Jiri Olsa
2011-11-18 14:37   ` Arnaldo Carvalho de Melo
2011-11-20  1:39     ` Jiri Olsa [this message]
2011-11-18 13:46 ` [PATCH 4/5] perf tool: Introducing perf_data object Jiri Olsa
2011-11-18 13:46 ` [PATCH 5/5] perf tool: Putting mmap support to " Jiri Olsa
2011-11-18 14:14 ` [RFC,PATCH] perf tool: Refactoring IO data files code Arnaldo Carvalho de Melo
2011-11-20  2:03 ` [RFC,PATCHv2] " Jiri Olsa
2011-11-20  2:03   ` [PATCHv2 1/5] perf tool: Fix session host_nachine retrieval Jiri Olsa
2011-11-20  2:03   ` [PATCHv2 2/5] perf tool: Initialize events IDs in a single function Jiri Olsa
2011-11-20  2:03   ` [PATCHv2 3/5] perf tool: Introducing perf_mmap object Jiri Olsa
2011-11-20  2:03   ` [PATCHv2 4/5] perf tool: Introducing perf_data object Jiri Olsa
2011-11-20  2:03   ` [PATCHv2 5/5] perf tool: Putting mmap support to " Jiri Olsa

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=20111120013907.GB2248@krava.redhat.com \
    --to=jolsa@redhat.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --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

Powered by JetHome