Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1601765 > unrolled thread

[PATCH] perf: fix symbols__fixup_end heuristic for corner cases

Started byDaniel Borkmann <daniel@iogearbox.net>
First post2017-03-15 23:00 +0100
Last post2017-03-17 15:20 +0100
Articles 5 — 4 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] perf: fix symbols__fixup_end heuristic for corner cases Daniel Borkmann <daniel@iogearbox.net> - 2017-03-15 23:00 +0100
    Re: [PATCH] perf: fix symbols__fixup_end heuristic for corner cases Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-03-16 02:10 +0100
      Re: [PATCH] perf: fix symbols__fixup_end heuristic for corner cases Daniel Borkmann <daniel@iogearbox.net> - 2017-03-16 10:10 +0100
    Re: [PATCH] perf: fix symbols__fixup_end heuristic for corner cases Alexei Starovoitov <alexei.starovoitov@gmail.com> - 2017-03-16 19:10 +0100
    [tip:perf/urgent] perf symbols: Fix symbols__fixup_end heuristic  for corner cases tip-bot for Daniel Borkmann <tipbot@zytor.com> - 2017-03-17 15:20 +0100

#1601765 — [PATCH] perf: fix symbols__fixup_end heuristic for corner cases

FromDaniel Borkmann <daniel@iogearbox.net>
Date2017-03-15 23:00 +0100
Subject[PATCH] perf: fix symbols__fixup_end heuristic for corner cases
Message-ID<tlp7z-5du-9@gated-at.bofh.it>
The current symbols__fixup_end() heuristic for the last entry in the
rb tree is suboptimal as it leads to not being able to recognize the
symbol in the call graph in a couple of corner cases, for example:

 i) If the symbol has a start address (f.e. exposed via kallsyms)
    that is at a page boundary, then the roundup(curr->start, 4096)
    for the last entry will result in curr->start == curr->end with
    a symbol length of zero.

ii) If the symbol has a start address that is shortly before a page
    boundary, then also here, curr->end - curr->start will just be
    very few bytes, where it's unrealistic that we could perform a
    match against.

Instead, change the heuristic to roundup(curr->start, 4096) + 4096,
so that we can catch such corner cases and have a better chance to
find that specific symbol. It's still just best effort as the real
end of the symbol is unknown to us (and could even be at a larger
offset than the current range), but better than the current situation.

Alexei reported that he recently run into case i) with a JITed eBPF
program (these are all page aligned) as the last symbol which wasn't
properly shown in the call graph (while other eBPF program symbols
in the rb tree were displayed correctly). Since this is a generic
issue, lets try to improve the heuristic a bit.

Fixes: 2e538c4a1847 ("perf tools: Improve kernel/modules symbol lookup")
Reported-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
---
 tools/perf/util/symbol.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 70e389b..9b4d8ba 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -202,7 +202,7 @@ void symbols__fixup_end(struct rb_root *symbols)
 
 	/* Last entry */
 	if (curr->end == curr->start)
-		curr->end = roundup(curr->start, 4096);
+		curr->end = roundup(curr->start, 4096) + 4096;
 }
 
 void __map_groups__fixup_end(struct map_groups *mg, enum map_type type)
-- 
1.9.3

[toc] | [next] | [standalone]


#1601825

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2017-03-16 02:10 +0100
Message-ID<tls5r-7wD-3@gated-at.bofh.it>
In reply to#1601765
Em Wed, Mar 15, 2017 at 10:53:37PM +0100, Daniel Borkmann escreveu:
> The current symbols__fixup_end() heuristic for the last entry in the
> rb tree is suboptimal as it leads to not being able to recognize the
> symbol in the call graph in a couple of corner cases, for example:

Thanks, will apply, test and push to Ingo via perf/urgent, tomorrow.

- Arnaldo
 
>  i) If the symbol has a start address (f.e. exposed via kallsyms)
>     that is at a page boundary, then the roundup(curr->start, 4096)
>     for the last entry will result in curr->start == curr->end with
>     a symbol length of zero.
> 
> ii) If the symbol has a start address that is shortly before a page
>     boundary, then also here, curr->end - curr->start will just be
>     very few bytes, where it's unrealistic that we could perform a
>     match against.
> 
> Instead, change the heuristic to roundup(curr->start, 4096) + 4096,
> so that we can catch such corner cases and have a better chance to
> find that specific symbol. It's still just best effort as the real
> end of the symbol is unknown to us (and could even be at a larger
> offset than the current range), but better than the current situation.
> 
> Alexei reported that he recently run into case i) with a JITed eBPF
> program (these are all page aligned) as the last symbol which wasn't
> properly shown in the call graph (while other eBPF program symbols
> in the rb tree were displayed correctly). Since this is a generic
> issue, lets try to improve the heuristic a bit.
> 
> Fixes: 2e538c4a1847 ("perf tools: Improve kernel/modules symbol lookup")
> Reported-by: Alexei Starovoitov <ast@kernel.org>
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
> ---
>  tools/perf/util/symbol.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
> index 70e389b..9b4d8ba 100644
> --- a/tools/perf/util/symbol.c
> +++ b/tools/perf/util/symbol.c
> @@ -202,7 +202,7 @@ void symbols__fixup_end(struct rb_root *symbols)
>  
>  	/* Last entry */
>  	if (curr->end == curr->start)
> -		curr->end = roundup(curr->start, 4096);
> +		curr->end = roundup(curr->start, 4096) + 4096;
>  }
>  
>  void __map_groups__fixup_end(struct map_groups *mg, enum map_type type)
> -- 
> 1.9.3

[toc] | [prev] | [next] | [standalone]


#1602115

FromDaniel Borkmann <daniel@iogearbox.net>
Date2017-03-16 10:10 +0100
Message-ID<tlzzY-4tY-33@gated-at.bofh.it>
In reply to#1601825
On 03/16/2017 02:07 AM, Arnaldo Carvalho de Melo wrote:
> Em Wed, Mar 15, 2017 at 10:53:37PM +0100, Daniel Borkmann escreveu:
>> The current symbols__fixup_end() heuristic for the last entry in the
>> rb tree is suboptimal as it leads to not being able to recognize the
>> symbol in the call graph in a couple of corner cases, for example:
>
> Thanks, will apply, test and push to Ingo via perf/urgent, tomorrow.

Great, thanks Arnaldo!

[toc] | [prev] | [next] | [standalone]


#1602722

FromAlexei Starovoitov <alexei.starovoitov@gmail.com>
Date2017-03-16 19:10 +0100
Message-ID<tlI0x-25v-5@gated-at.bofh.it>
In reply to#1601765
On Wed, Mar 15, 2017 at 10:53:37PM +0100, Daniel Borkmann wrote:
> The current symbols__fixup_end() heuristic for the last entry in the
> rb tree is suboptimal as it leads to not being able to recognize the
> symbol in the call graph in a couple of corner cases, for example:
> 
>  i) If the symbol has a start address (f.e. exposed via kallsyms)
>     that is at a page boundary, then the roundup(curr->start, 4096)
>     for the last entry will result in curr->start == curr->end with
>     a symbol length of zero.
> 
> ii) If the symbol has a start address that is shortly before a page
>     boundary, then also here, curr->end - curr->start will just be
>     very few bytes, where it's unrealistic that we could perform a
>     match against.
> 
> Instead, change the heuristic to roundup(curr->start, 4096) + 4096,
> so that we can catch such corner cases and have a better chance to
> find that specific symbol. It's still just best effort as the real
> end of the symbol is unknown to us (and could even be at a larger
> offset than the current range), but better than the current situation.
> 
> Alexei reported that he recently run into case i) with a JITed eBPF
> program (these are all page aligned) as the last symbol which wasn't
> properly shown in the call graph (while other eBPF program symbols
> in the rb tree were displayed correctly). Since this is a generic
> issue, lets try to improve the heuristic a bit.
> 
> Fixes: 2e538c4a1847 ("perf tools: Improve kernel/modules symbol lookup")
> Reported-by: Alexei Starovoitov <ast@kernel.org>
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>

Acked-by: Alexei Starovoitov <ast@kernel.org>
Tested-by: Alexei Starovoitov <ast@kernel.org>

thanks!

[toc] | [prev] | [next] | [standalone]


#1603353 — [tip:perf/urgent] perf symbols: Fix symbols__fixup_end heuristic for corner cases

Fromtip-bot for Daniel Borkmann <tipbot@zytor.com>
Date2017-03-17 15:20 +0100
Subject[tip:perf/urgent] perf symbols: Fix symbols__fixup_end heuristic for corner cases
Message-ID<tm0Tw-7D7-25@gated-at.bofh.it>
In reply to#1601765
Commit-ID:  e7ede72a6d40cb3a30c087142d79381ca8a31dab
Gitweb:     http://git.kernel.org/tip/e7ede72a6d40cb3a30c087142d79381ca8a31dab
Author:     Daniel Borkmann <daniel@iogearbox.net>
AuthorDate: Wed, 15 Mar 2017 22:53:37 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 17 Mar 2017 10:30:22 -0300

perf symbols: Fix symbols__fixup_end heuristic for corner cases

The current symbols__fixup_end() heuristic for the last entry in the rb
tree is suboptimal as it leads to not being able to recognize the symbol
in the call graph in a couple of corner cases, for example:

 i) If the symbol has a start address (f.e. exposed via kallsyms)
    that is at a page boundary, then the roundup(curr->start, 4096)
    for the last entry will result in curr->start == curr->end with
    a symbol length of zero.

ii) If the symbol has a start address that is shortly before a page
    boundary, then also here, curr->end - curr->start will just be
    very few bytes, where it's unrealistic that we could perform a
    match against.

Instead, change the heuristic to roundup(curr->start, 4096) + 4096, so
that we can catch such corner cases and have a better chance to find
that specific symbol. It's still just best effort as the real end of the
symbol is unknown to us (and could even be at a larger offset than the
current range), but better than the current situation.

Alexei reported that he recently run into case i) with a JITed eBPF
program (these are all page aligned) as the last symbol which wasn't
properly shown in the call graph (while other eBPF program symbols in
the rb tree were displayed correctly). Since this is a generic issue,
lets try to improve the heuristic a bit.

Reported-and-Tested-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Fixes: 2e538c4a1847 ("perf tools: Improve kernel/modules symbol lookup")
Link: http://lkml.kernel.org/r/bb5c80d27743be6f12afc68405f1956a330e1bc9.1489614365.git.daniel@iogearbox.net
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/symbol.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 70e389b..9b4d8ba 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -202,7 +202,7 @@ void symbols__fixup_end(struct rb_root *symbols)
 
 	/* Last entry */
 	if (curr->end == curr->start)
-		curr->end = roundup(curr->start, 4096);
+		curr->end = roundup(curr->start, 4096) + 4096;
 }
 
 void __map_groups__fixup_end(struct map_groups *mg, enum map_type type)

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web