All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
To: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [BUGFIX PATCH 1/6] perf/probe: Fix wrong address verification
Date: Fri, 25 Oct 2019 09:14:48 -0300	[thread overview]
Message-ID: <20191025121448.GC23511@kernel.org> (raw)
In-Reply-To: <157199318513.8075.10463906803299647907.stgit@devnote2>

Em Fri, Oct 25, 2019 at 05:46:25PM +0900, Masami Hiramatsu escreveu:
> Since there are some DIE which has only ranges instead of the
> combination of entrypc/highpc, address verification must use
> dwarf_haspc() instead of dwarf_entrypc/dwarf_highpc.
> 
> Also, the ranges only DIE will have a partial code in different
> section (e.g. unlikely code will be in text.unlikely as "FUNC.cold"
> symbol). In that case, we can not use dwarf_entrypc() or
> die_entrypc(), because the offset from original DIE can be
> a minus value.
> 
> Instead, this simply gets the symbol and offset from symtab.
> 
> Without this patch;
>   # tools/perf/perf probe -D clear_tasks_mm_cpumask:1
>   Failed to get entry address of clear_tasks_mm_cpumask
>     Error: Failed to add events.
> 
> And with this patch
>   # tools/perf/perf probe -D clear_tasks_mm_cpumask:1
>   p:probe/clear_tasks_mm_cpumask clear_tasks_mm_cpumask+0
>   p:probe/clear_tasks_mm_cpumask_1 clear_tasks_mm_cpumask+5
>   p:probe/clear_tasks_mm_cpumask_2 clear_tasks_mm_cpumask+8
>   p:probe/clear_tasks_mm_cpumask_3 clear_tasks_mm_cpumask+16
>   p:probe/clear_tasks_mm_cpumask_4 clear_tasks_mm_cpumask+82

Ok, so this just asks for the definition, but doesn't try to actually
_use_ it, which I did and it fails:

[root@quaco tracebuffer]# perf probe -D clear_tasks_mm_cpumask:1
p:probe/clear_tasks_mm_cpumask _text+919968
p:probe/clear_tasks_mm_cpumask_1 _text+919973
p:probe/clear_tasks_mm_cpumask_2 _text+919976
[root@quaco tracebuffer]#
[root@quaco tracebuffer]# perf probe clear_tasks_mm_cpumask
Probe point 'clear_tasks_mm_cpumask' not found.
  Error: Failed to add events.
[root@quaco tracebuffer]#

So I'll tentatively continue to apply the other patches in this series,
maybe one of them will fix this.

- Arnaldo
 
> Reported-by: Arnaldo Carvalho de Melo <acme@kernel.org>
> Fixes: 576b523721b7 ("perf probe: Fix probing symbols with optimization suffix")
> Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
> ---
>  tools/perf/util/probe-finder.c |   32 ++++++++++----------------------
>  1 file changed, 10 insertions(+), 22 deletions(-)
> 
> diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
> index cd9f95e5044e..2b6513e5725c 100644
> --- a/tools/perf/util/probe-finder.c
> +++ b/tools/perf/util/probe-finder.c
> @@ -604,38 +604,26 @@ static int convert_to_trace_point(Dwarf_Die *sp_die, Dwfl_Module *mod,
>  				  const char *function,
>  				  struct probe_trace_point *tp)
>  {
> -	Dwarf_Addr eaddr, highaddr;
> +	Dwarf_Addr eaddr;
>  	GElf_Sym sym;
>  	const char *symbol;
>  
>  	/* Verify the address is correct */
> -	if (dwarf_entrypc(sp_die, &eaddr) != 0) {
> -		pr_warning("Failed to get entry address of %s\n",
> -			   dwarf_diename(sp_die));
> -		return -ENOENT;
> -	}
> -	if (dwarf_highpc(sp_die, &highaddr) != 0) {
> -		pr_warning("Failed to get end address of %s\n",
> -			   dwarf_diename(sp_die));
> -		return -ENOENT;
> -	}
> -	if (paddr > highaddr) {
> -		pr_warning("Offset specified is greater than size of %s\n",
> +	if (!dwarf_haspc(sp_die, paddr)) {
> +		pr_warning("Specified offset is out of %s\n",
>  			   dwarf_diename(sp_die));
>  		return -EINVAL;
>  	}
>  
> -	symbol = dwarf_diename(sp_die);
> +	/* Try to get actual symbol name from symtab */
> +	symbol = dwfl_module_addrsym(mod, paddr, &sym, NULL);
>  	if (!symbol) {
> -		/* Try to get the symbol name from symtab */
> -		symbol = dwfl_module_addrsym(mod, paddr, &sym, NULL);
> -		if (!symbol) {
> -			pr_warning("Failed to find symbol at 0x%lx\n",
> -				   (unsigned long)paddr);
> -			return -ENOENT;
> -		}
> -		eaddr = sym.st_value;
> +		pr_warning("Failed to find symbol at 0x%lx\n",
> +			   (unsigned long)paddr);
> +		return -ENOENT;
>  	}
> +	eaddr = sym.st_value;
> +
>  	tp->offset = (unsigned long)(paddr - eaddr);
>  	tp->address = (unsigned long)paddr;
>  	tp->symbol = strdup(symbol);

-- 

- Arnaldo

  reply	other threads:[~2019-10-25 12:14 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-25  8:46 [BUGFIX PATCH 0/6] perf/probe: Additional fixes for range only functions Masami Hiramatsu
2019-10-25  8:46 ` [BUGFIX PATCH 1/6] perf/probe: Fix wrong address verification Masami Hiramatsu
2019-10-25 12:14   ` Arnaldo Carvalho de Melo [this message]
2019-10-25 12:36     ` Masami Hiramatsu
2019-10-25 14:28       ` Arnaldo Carvalho de Melo
2019-11-12 11:18   ` [tip: perf/core] perf probe: " tip-bot2 for Masami Hiramatsu
2019-10-25  8:46 ` [BUGFIX PATCH 2/6] perf/probe: Fix to probe a function which has no entry pc Masami Hiramatsu
2019-11-12 11:18   ` [tip: perf/core] perf probe: " tip-bot2 for Masami Hiramatsu
2019-10-25  8:46 ` [BUGFIX PATCH 3/6] perf/probe: Fix to probe an inline " Masami Hiramatsu
2019-10-25 14:35   ` Arnaldo Carvalho de Melo
2019-10-25 14:39     ` Arnaldo Carvalho de Melo
2019-10-26  8:04       ` Masami Hiramatsu
2019-11-12 11:18   ` [tip: perf/core] perf probe: " tip-bot2 for Masami Hiramatsu
2019-10-25  8:46 ` [BUGFIX PATCH 4/6] perf/probe: Fix to list probe event with correct line number Masami Hiramatsu
2019-11-12 11:18   ` [tip: perf/core] perf probe: " tip-bot2 for Masami Hiramatsu
2019-10-25  8:47 ` [BUGFIX PATCH 5/6] perf/probe: Fix to show inlined function callsite without entry_pc Masami Hiramatsu
2019-11-12 11:18   ` [tip: perf/core] perf probe: " tip-bot2 for Masami Hiramatsu
2019-10-25  8:47 ` [BUGFIX PATCH 6/6] perf/probe: Fix to show ranges of variables in functions " Masami Hiramatsu
2019-11-12 11:18   ` [tip: perf/core] perf probe: " tip-bot2 for Masami Hiramatsu

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=20191025121448.GC23511@kernel.org \
    --to=arnaldo.melo@gmail.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=namhyung@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.