[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <157418260850.12247.4435566464230141839.tip-bot2@tip-bot2>
Date: Tue, 19 Nov 2019 16:56:48 -0000
From: "tip-bot2 for Masami Hiramatsu" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: Masami Hiramatsu <mhiramat@...nel.org>,
Arnaldo Carvalho de Melo <acme@...hat.com>,
Namhyung Kim <namhyung@...nel.org>,
Ravi Bangoria <ravi.bangoria@...ux.ibm.com>,
"Steven Rostedt (VMware)" <rostedt@...dmis.org>,
Tom Zanussi <tom.zanussi@...ux.intel.com>,
Ingo Molnar <mingo@...nel.org>, Borislav Petkov <bp@...en8.de>,
linux-kernel@...r.kernel.org
Subject: [tip: perf/core] perf probe: Do not show non representive lines by
perf-probe -L
The following commit has been merged into the perf/core branch of tip:
Commit-ID: 499144c83d3b7e4f9e83916acfc97bbc3af891dc
Gitweb: https://git.kernel.org/tip/499144c83d3b7e4f9e83916acfc97bbc3af891dc
Author: Masami Hiramatsu <mhiramat@...nel.org>
AuthorDate: Mon, 18 Nov 2019 17:12:10 +09:00
Committer: Arnaldo Carvalho de Melo <acme@...hat.com>
CommitterDate: Mon, 18 Nov 2019 18:59:36 -03:00
perf probe: Do not show non representive lines by perf-probe -L
Since perf probe -L shows non representive lines, it can be mislead
users where user can put probes. This prevents to show such non
representive lines so that user can understand which lines user can
probe.
# perf probe -L kernel_read
<kernel_read@...ild/linux-pvZVvI/linux-5.0.0/fs/read_write.c:0>
0 ssize_t kernel_read(struct file *file, void *buf, size_t count, loff_t *pos)
{
2 mm_segment_t old_fs;
ssize_t result;
old_fs = get_fs();
6 set_fs(get_ds());
/* The cast to a user pointer is valid due to the set_fs() */
8 result = vfs_read(file, (void __user *)buf, count, pos);
9 set_fs(old_fs);
10 return result;
}
EXPORT_SYMBOL(kernel_read);
Committer testing:
Before:
# perf probe -L kernel_read
<kernel_read@...r/src/debug/kernel-5.3.fc30/linux-5.3.8-200.fc30.x86_64/fs/read_write.c:0>
0 ssize_t kernel_read(struct file *file, void *buf, size_t count, loff_t *pos)
1 {
2 mm_segment_t old_fs;
3 ssize_t result;
5 old_fs = get_fs();
6 set_fs(KERNEL_DS);
/* The cast to a user pointer is valid due to the set_fs() */
8 result = vfs_read(file, (void __user *)buf, count, pos);
9 set_fs(old_fs);
10 return result;
}
EXPORT_SYMBOL(kernel_read);
#
See the 1, 3, 5 lines? They shouldn't be there, after this patch:
# perf probe -L kernel_read
<kernel_read@...r/src/debug/kernel-5.3.fc30/linux-5.3.8-200.fc30.x86_64/fs/read_write.c:0>
0 ssize_t kernel_read(struct file *file, void *buf, size_t count, loff_t *pos)
{
2 mm_segment_t old_fs;
ssize_t result;
old_fs = get_fs();
6 set_fs(KERNEL_DS);
/* The cast to a user pointer is valid due to the set_fs() */
8 result = vfs_read(file, (void __user *)buf, count, pos);
9 set_fs(old_fs);
10 return result;
}
EXPORT_SYMBOL(kernel_read);
#
Signed-off-by: Masami Hiramatsu <mhiramat@...nel.org>
Reported-by: Arnaldo Carvalho de Melo <acme@...hat.com>
Tested-by: Arnaldo Carvalho de Melo <acme@...hat.com>
Cc: Namhyung Kim <namhyung@...nel.org>
Cc: Ravi Bangoria <ravi.bangoria@...ux.ibm.com>
Cc: Steven Rostedt (VMware) <rostedt@...dmis.org>
Cc: Tom Zanussi <tom.zanussi@...ux.intel.com>
Link: http://lore.kernel.org/lkml/157406473064.24476.2913278267727587314.stgit@devnote2
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
---
tools/perf/util/probe-finder.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index ef1b320..f12ad50 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -1734,12 +1734,19 @@ static int line_range_walk_cb(const char *fname, int lineno,
void *data)
{
struct line_finder *lf = data;
+ const char *__fname;
+ int __lineno;
int err;
if ((strtailcmp(fname, lf->fname) != 0) ||
(lf->lno_s > lineno || lf->lno_e < lineno))
return 0;
+ /* Make sure this line can be reversable */
+ if (cu_find_lineinfo(&lf->cu_die, addr, &__fname, &__lineno) > 0
+ && (lineno != __lineno || strcmp(fname, __fname)))
+ return 0;
+
err = line_range_add_line(fname, lineno, lf->lr);
if (err < 0 && err != -EEXIST)
return err;
Powered by blists - more mailing lists