Received: by 2002:a17:90a:9103:0:0:0:0 with SMTP id k3csp11800154pjo; Thu, 2 Jan 2020 14:30:06 -0800 (PST) X-Google-Smtp-Source: APXvYqxLUTVIO75Rg0JAHs2w/xeX3JDB2Q34JcnVv+KiQMowvAiG/6bUF0BwABDWFny/xfAkgbEP X-Received: by 2002:a9d:3d0a:: with SMTP id a10mr92565765otc.327.1578004206870; Thu, 02 Jan 2020 14:30:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578004206; cv=none; d=google.com; s=arc-20160816; b=VCQggHQQbGX4JDq+3UFmw5bAp43pNDG9u63XYUD4qglIZ65B4AQKQkP1dcjE84jEL9 ky4P6kLXJvccqjcRzVdm9KHWsBRibmiya5SIOwhnrAeGKUG4cXISlJsFuTeXSMjlwJJg s5wSbg/RLLiEK9ZZUlUngqfPpONArCj+zsPx59o4z3pMH4Ri9eGJ6WzL82lPUZ3R8I+Y NZpLk7tkb0fEEmmOf4DinLeR7/4nHBjpdGeMo+kcgXZfzcXYgPOuX1HyywfSDPxFH/Tk O+l/ZyYzoFcRMnZL+RinkWP7Afw1fYesYT2v/fMM6tpP+BmIxkBpKtnocCxv9PcoTswA /gHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=78svPrlzw0rSeI+4XO/qTmxQWxEmBTbwF6phU+ESVDo=; b=hdZE853EnTEgGXGQLfyUzjuIxktz9GZP+Ly3Rl5yD6nbm1ckAsksYRXvOu8TRODVnL brIB2/2vOOMusjxYaTYN97pidj1EI/4sAKKdEhtEt81YIxt77UIxD6aPF8vGO3JXxxVL 2Pkcza3Qd8S81Nj4+9l3Vyis8shh62BgQUVyjk8nKSnWRuXxQn1uPLcIOektg7n3b1PQ UyPEi1C82gQbSKLhyTJOs0bSHiHsDR0t0C+dmQv5O8hzGTU3dBRHHFOs/AKDyUERK2Ap qizU4FFSNWtc302xq+YxnKA4XC2MQqdt5vIBCpmSU/fV4nl0RY/HiV4Uf9bvVkfI1v6S P7vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LOOOw8jm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w18si23280039otj.148.2020.01.02.14.29.55; Thu, 02 Jan 2020 14:30:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LOOOw8jm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730011AbgABW3O (ORCPT + 99 others); Thu, 2 Jan 2020 17:29:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:59882 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729995AbgABW3L (ORCPT ); Thu, 2 Jan 2020 17:29:11 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E528920866; Thu, 2 Jan 2020 22:29:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578004150; bh=wKqnt0/C+VVp3lrC3xePDo9k5+y1KhGxmXUtKxm83TY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LOOOw8jmA94U8EWsZfM4AkJjYh5G0lz6C6QGEtAY1PBJZh+QtGGXkqVzUU23keX1/ Y2rOMKH4ZhW9gZc77/aRdnYT+7puyT8tCBCjt0jBQ/C7+YH+D6apryg4mHPL8EyOmk 9SwzKreQ97HIQveSVoKX0VIQDGqJb1vhu0pZmnoA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Masami Hiramatsu , Arnaldo Carvalho de Melo , Jiri Olsa , Namhyung Kim , Sasha Levin Subject: [PATCH 4.9 059/171] perf probe: Fix to show calling lines of inlined functions Date: Thu, 2 Jan 2020 23:06:30 +0100 Message-Id: <20200102220555.093184715@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102220546.960200039@linuxfoundation.org> References: <20200102220546.960200039@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Masami Hiramatsu [ Upstream commit 86c0bf8539e7f46d91bd105e55eda96e0064caef ] Fix to show calling lines of inlined functions (where an inline function is called). die_walk_lines() filtered out the lines inside inlined functions based on the address. However this also filtered out the lines which call those inlined functions from the target function. To solve this issue, check the call_file and call_line attributes and do not filter out if it matches to the line information. Without this fix, perf probe -L doesn't show some lines correctly. (don't see the lines after 17) # perf probe -L vfs_read 0 ssize_t vfs_read(struct file *file, char __user *buf, size_t count, loff_t *pos) 1 { 2 ssize_t ret; 4 if (!(file->f_mode & FMODE_READ)) return -EBADF; 6 if (!(file->f_mode & FMODE_CAN_READ)) return -EINVAL; 8 if (unlikely(!access_ok(buf, count))) return -EFAULT; 11 ret = rw_verify_area(READ, file, pos, count); 12 if (!ret) { 13 if (count > MAX_RW_COUNT) count = MAX_RW_COUNT; 15 ret = __vfs_read(file, buf, count, pos); 16 if (ret > 0) { fsnotify_access(file); add_rchar(current, ret); } With this fix: # perf probe -L vfs_read 0 ssize_t vfs_read(struct file *file, char __user *buf, size_t count, loff_t *pos) 1 { 2 ssize_t ret; 4 if (!(file->f_mode & FMODE_READ)) return -EBADF; 6 if (!(file->f_mode & FMODE_CAN_READ)) return -EINVAL; 8 if (unlikely(!access_ok(buf, count))) return -EFAULT; 11 ret = rw_verify_area(READ, file, pos, count); 12 if (!ret) { 13 if (count > MAX_RW_COUNT) count = MAX_RW_COUNT; 15 ret = __vfs_read(file, buf, count, pos); 16 if (ret > 0) { 17 fsnotify_access(file); 18 add_rchar(current, ret); } 20 inc_syscr(current); } Fixes: 4cc9cec636e7 ("perf probe: Introduce lines walker interface") Signed-off-by: Masami Hiramatsu Tested-by: Arnaldo Carvalho de Melo Cc: Jiri Olsa Cc: Namhyung Kim Link: http://lore.kernel.org/lkml/157241937995.32002.17899884017011512577.stgit@devnote2 Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/util/dwarf-aux.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c index 3aea343c7179..41bfb4c977d0 100644 --- a/tools/perf/util/dwarf-aux.c +++ b/tools/perf/util/dwarf-aux.c @@ -765,7 +765,7 @@ int die_walk_lines(Dwarf_Die *rt_die, line_walk_callback_t callback, void *data) Dwarf_Lines *lines; Dwarf_Line *line; Dwarf_Addr addr; - const char *fname, *decf = NULL; + const char *fname, *decf = NULL, *inf = NULL; int lineno, ret = 0; int decl = 0, inl; Dwarf_Die die_mem, *cu_die; @@ -809,13 +809,21 @@ int die_walk_lines(Dwarf_Die *rt_die, line_walk_callback_t callback, void *data) */ if (!dwarf_haspc(rt_die, addr)) continue; + if (die_find_inlinefunc(rt_die, addr, &die_mem)) { + /* Call-site check */ + inf = die_get_call_file(&die_mem); + if ((inf && !strcmp(inf, decf)) && + die_get_call_lineno(&die_mem) == lineno) + goto found; + dwarf_decl_line(&die_mem, &inl); if (inl != decl || decf != dwarf_decl_file(&die_mem)) continue; } } +found: /* Get source line */ fname = dwarf_linesrc(line, NULL, NULL); -- 2.20.1