Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp13330433ybl; Sun, 29 Dec 2019 09:27:18 -0800 (PST) X-Google-Smtp-Source: APXvYqxdiDgctcjA2bmPfP7MA4GpPb3wazsTXBYbuNmRKcWLFftUmcNWXms20fhUNVM6ORCa1Eg1 X-Received: by 2002:a9d:d0b:: with SMTP id 11mr71748111oti.287.1577640438649; Sun, 29 Dec 2019 09:27:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577640438; cv=none; d=google.com; s=arc-20160816; b=tRrqZLf1Ejo1Ux2ymGb7edxOPw8JNLycgUSPc4qU46Fe444+0EARQ7tXM9zm7gI1JK DBzMnZwSxr8JE2ElYFB3pAXuQsCHFjTm/sG6Pisl72hw8L3bMDxRjWlGDJ7ISEmz8Wc+ kdDkuzVo9CsS5f/RsfBDr5W0vUO08RNz6osJ/iWz6ZSlv9e5hnMCODsbXmrc0r+u/wV+ 5otE2beKjX4VUD3wKfV5UcRzejCrMbGN9hiKCGhV/K+ze8T2N1s/jK6Iab7848HDDfaD toDkDg+I0R3d9cSVIH2aW26paQu8wVWYz8wyT+DspJWoZVFfK+vFZZuhxpsAcRECpobz TQXQ== 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=DBiI0Sf0mPa4ZkGgTudK3p1u76+xK0mTywuzrYpxzU0=; b=kiLteqPeTxfYfCLdUc01UuELG3X938QV08PTnlKycvRQ0/YmHX1W1mABZbFi6wBcho P3lzlZPQAC/ccQCwPT2NQKuJcyPOdHUl21B5tzxR3conCJFREQFjnAqTW70H/AqnLdDM fUEEI0InDdLtji2hAqzxoB7yxUzmoGJrGk0MSQ/Yc0iZgBRLsnTPALKiPLPVvTu50Soe XOHxC33MAM/C9pGhwAnV/eQx5CIdpfuDO1DtbA2szH01jCHBuAkCSo1mvZynNgAVNIod igONfXMV1JLBURFJjvnUHOhfioRq8sJmZ+I1r9EEoAXrRQBozFkSSC5hVfFrtzhOajhX b3ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZN8SASND; 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 l3si18598465otq.40.2019.12.29.09.27.07; Sun, 29 Dec 2019 09:27:18 -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=ZN8SASND; 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 S1727907AbfL2RZO (ORCPT + 99 others); Sun, 29 Dec 2019 12:25:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:44624 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727387AbfL2RZJ (ORCPT ); Sun, 29 Dec 2019 12:25:09 -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 D7D7E207FD; Sun, 29 Dec 2019 17:25:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577640308; bh=y5E1enobJJncizylPwSWEaxF0UHoh5KeJIaMrNuHgTo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZN8SASNDAVeQFNe1S8nGQkad32KgXzy8a/1b8ZO5LHg/AXdcURV7ZKT1ElFXJr4Z9 pnWrlIC2Tp9J15P5hXzJCMttxguRvh3/J8kT4kAPB5CqHIu5VvrMUgK8cfLCD2/z2F qMc7ILO7ZHhME18q+uHfv+/YTkY6tcWUxVzLyLzM= 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.14 104/161] perf probe: Fix to show calling lines of inlined functions Date: Sun, 29 Dec 2019 18:19:12 +0100 Message-Id: <20191229162427.907222475@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191229162355.500086350@linuxfoundation.org> References: <20191229162355.500086350@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 0a5de865563c..49f9c65f1a9c 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