Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp13341209ybl; Sun, 29 Dec 2019 09:40:36 -0800 (PST) X-Google-Smtp-Source: APXvYqzdT811H0lhuyPB/UYQ1zigvy6GVhM0g8GOHPmQDFP4i3JqBEnOOpUeKUF8spIOadwaVEnP X-Received: by 2002:a9d:133:: with SMTP id 48mr67280185otu.15.1577641236292; Sun, 29 Dec 2019 09:40:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577641236; cv=none; d=google.com; s=arc-20160816; b=G65w4WyY2VXdg0vHWZlRSDZCVgzDbAPXKoQt2uXTyoUhlTymSb9NZtVzxG2+PR6Y6u XrRVYg1M5cW9zE08DS8amsDAPU07Oo80GAULorJZZCdhKAKcoOwII6KcPPPHJUKTeKfs KgEnGav405ZwXv3N8oPx7LfjMU3eoQBtJ/PDbXg9LWvvAfD/ucoj2mF9ybXNzD/J2Swn 5XqzMOQAOU1ToTthGRUWroFPtShkQsgucuqvhh06t1S/+a8EwQOhZ5OEQoIxyLq1QroX QdUm2eYYJzIN0N1Mvwt1ngjdJ9b/7VqRiNX1r00T17dbHMBKmh7tyR54cxmYeM1rUbOq jUag== 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=Aed7RN8dqs+2oJICtwBh7xf0aTANx5KWoG1GOHxnUQE=; b=aAHo2pXJ68NtByry9TNnJqZfCdRt2cY2uCBLp8wN2YUprW7iYDH5ekkEGN184Mvsc5 +Z3b9pOGPGsjTR4+gzrV8fL2mU3ZZ3WW2YXg4dGlnBvE5fmGvOr7ycbq7oGPYx+0FDEf 0ivj1pSrSMffCLo7gphtxm8Wbxo1LF5g1V91+B+RMEH4VCuMiyRatiHZfiwe7AsJMQQ6 m/n+mWo0eu8EWZr+RMVvJ69rNcsygRBJokaxQrS5M++5jkoZ9emW9XkO0ywO/owYd2On nqquWAJ7yzO2atat7U8JzQLkS4dGTkX7XNUJ9/FIj9dosvwgTpW0jhcAQDM8Zt6zjDuk MltA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MVq0v+EA; 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 d2si21661080oth.267.2019.12.29.09.40.24; Sun, 29 Dec 2019 09:40:36 -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=MVq0v+EA; 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 S1729409AbfL2RdN (ORCPT + 99 others); Sun, 29 Dec 2019 12:33:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:34412 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729390AbfL2RdH (ORCPT ); Sun, 29 Dec 2019 12:33:07 -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 3A780208E4; Sun, 29 Dec 2019 17:33:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577640786; bh=5/itrn6Nr/PixQUzBml95YTj552i/pvao5+j+0U9oCY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MVq0v+EAVSVhRIFXv7De2ebF5L4NxLdVxxuHqgc6RAQK6xy4ETEHaRjJ8h6yZmv0Y 5AhLsMdoPrsUHuFt9/DvIR2RHjw/d6Z5kGhKJuZ6iTjN1lMCz4NTbHoD9iA80YVSje RfjWvtbHyLZmDcupcEimwqqcNZbH+05KegQqBx5A= 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.19 139/219] perf probe: Fix to show calling lines of inlined functions Date: Sun, 29 Dec 2019 18:19:01 +0100 Message-Id: <20191229162529.416335211@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191229162508.458551679@linuxfoundation.org> References: <20191229162508.458551679@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 fc3f3573332d..7ae3106b4e5e 100644 --- a/tools/perf/util/dwarf-aux.c +++ b/tools/perf/util/dwarf-aux.c @@ -768,7 +768,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; @@ -812,13 +812,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