Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752658AbdCPSI6 (ORCPT ); Thu, 16 Mar 2017 14:08:58 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:34573 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751663AbdCPSI4 (ORCPT ); Thu, 16 Mar 2017 14:08:56 -0400 Date: Thu, 16 Mar 2017 11:08:52 -0700 From: Alexei Starovoitov To: Daniel Borkmann Cc: acme@kernel.org, ast@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] perf: fix symbols__fixup_end heuristic for corner cases Message-ID: <20170316180850.GA59520@ast-mbp.thefacebook.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1721 Lines: 35 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 > Signed-off-by: Daniel Borkmann Acked-by: Alexei Starovoitov Tested-by: Alexei Starovoitov thanks!