linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
To: Jiri Olsa <jolsa@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>,
	Ravi Bangoria <ravi.bangoria@linux.ibm.com>,
	lkml <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Michael Petlan <mpetlan@redhat.com>
Subject: Re: [PATCHv2 2/4] perf tools: Mark ksymbol dsos with kernel type
Date: Tue, 11 Feb 2020 10:47:13 -0300	[thread overview]
Message-ID: <20200211134713.GB32066@kernel.org> (raw)
In-Reply-To: <20200210200847.GA36715@krava>

Em Mon, Feb 10, 2020 at 09:08:47PM +0100, Jiri Olsa escreveu:
> On Mon, Feb 10, 2020 at 04:25:37PM +0100, Jiri Olsa wrote:
> > On Mon, Feb 10, 2020 at 12:17:59PM -0300, Arnaldo Carvalho de Melo wrote:
> > > Em Mon, Feb 10, 2020 at 03:32:16PM +0100, Jiri Olsa escreveu:
> > > > We add ksymbol map into machine->kmaps, so it needs to be
> > > > created as 'struct kmap', which is dependent on its dso
> > > > having kernel type.
> > > > 
> > > > Reported-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
> > > > Tested-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
> > > > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > > > ---
> > > >  tools/perf/util/machine.c | 10 ++++++++--
> > > >  1 file changed, 8 insertions(+), 2 deletions(-)
> > > > 
> > > > diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
> > > > index e3e5490f6de5..0a43dc83d7b2 100644
> > > > --- a/tools/perf/util/machine.c
> > > > +++ b/tools/perf/util/machine.c
> > > > @@ -727,8 +727,14 @@ static int machine__process_ksymbol_register(struct machine *machine,
> > > >  	struct map *map = maps__find(&machine->kmaps, event->ksymbol.addr);
> > > >  
> > > >  	if (!map) {
> > > > -		map = dso__new_map(event->ksymbol.name);
> > > > -		if (!map)
> > > > +		struct dso *dso = dso__new(event->ksymbol.name);
> > > > +
> > > > +		if (dso) {
> > > > +			dso->kernel = DSO_TYPE_KERNEL;
> > > > +			map = map__new2(0, dso);
> > > > +		}
> > > > +
> > > > +		if (!dso || !map)
> > > 
> > > We leak dso if map creation fails?
> > 
> > yep :-\ will post v2
> 
> v2 attached, it's also all in my perf/top branch

Thanks for fixing it, will process it into my perf/urgent branch.

- Arnaldo
 
> thanks,
> jirka
> 
> 
> ---
> We add ksymbol map into machine->kmaps, so it needs to be
> created as 'struct kmap', which is dependent on its dso
> having kernel type.
> 
> Reported-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
> Tested-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
>  tools/perf/util/machine.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
> index e3e5490f6de5..0ad026561c7f 100644
> --- a/tools/perf/util/machine.c
> +++ b/tools/perf/util/machine.c
> @@ -727,9 +727,17 @@ static int machine__process_ksymbol_register(struct machine *machine,
>  	struct map *map = maps__find(&machine->kmaps, event->ksymbol.addr);
>  
>  	if (!map) {
> -		map = dso__new_map(event->ksymbol.name);
> -		if (!map)
> +		struct dso *dso = dso__new(event->ksymbol.name);
> +
> +		if (dso) {
> +			dso->kernel = DSO_TYPE_KERNEL;
> +			map = map__new2(0, dso);
> +		}
> +
> +		if (!dso || !map) {
> +			dso__put(dso);
>  			return -ENOMEM;
> +		}
>  
>  		map->start = event->ksymbol.addr;
>  		map->end = map->start + event->ksymbol.len;
> -- 
> 2.24.1
> 

-- 

- Arnaldo

  reply	other threads:[~2020-02-11 13:47 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-10 14:32 [PATCH 0/4] perf tools: Fix kmap handling Jiri Olsa
2020-02-10 14:32 ` [PATCH 1/4] perf tools: Mark modules dsos with kernel type Jiri Olsa
2020-02-15  8:41   ` [tip: perf/urgent] perf maps: Mark module DSOs " tip-bot2 for Jiri Olsa
2020-02-10 14:32 ` [PATCH 2/4] perf tools: Mark ksymbol dsos " Jiri Olsa
2020-02-10 15:17   ` Arnaldo Carvalho de Melo
2020-02-10 15:25     ` Jiri Olsa
2020-02-10 19:58       ` Arnaldo Carvalho de Melo
2020-02-10 20:34         ` Jiri Olsa
2020-02-10 20:08       ` [PATCHv2 " Jiri Olsa
2020-02-11 13:47         ` Arnaldo Carvalho de Melo [this message]
2020-02-15  8:41         ` [tip: perf/urgent] perf maps: Mark ksymbol DSOs " tip-bot2 for Jiri Olsa
2020-02-10 14:32 ` [PATCH 3/4] perf tools: Fix map__clone for struct kmap Jiri Olsa
2020-02-15  8:41   ` [tip: perf/urgent] perf maps: Fix map__clone() " tip-bot2 for Jiri Olsa
2020-02-10 14:32 ` [PATCH 4/4] perf tools: Move kmap::kmaps setup to maps__insert Jiri Olsa
2020-02-15  8:41   ` [tip: perf/urgent] perf maps: Move kmap::kmaps setup to maps__insert() tip-bot2 for Jiri Olsa
2020-02-10 16:47 ` [PATCH 0/4] perf tools: Fix kmap handling Kim Phillips
2020-02-10 20:35   ` 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=20200211134713.GB32066@kernel.org \
    --to=arnaldo.melo@gmail.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=jolsa@kernel.org \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=mpetlan@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=ravi.bangoria@linux.ibm.com \
    /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).