From: Naveen N. Rao <hidden> Date: 2017-06-29 13:36:55
Add a kprobes test to ensure that we are able to add a probe on a
module function using 'p <mod>:<func>' format, without having to
specify a probe name.
Suggested-by: Masami Hiramatsu <mhiramat@kernel.org>
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Naveen N. Rao <redacted>
---
.../testing/selftests/ftrace/test.d/kprobe/probe_module.tc | 14 ++++++++++++++
1 file changed, 14 insertions(+)
create mode 100644 tools/testing/selftests/ftrace/test.d/kprobe/probe_module.tc
From: Naveen N. Rao <hidden> Date: 2017-06-29 13:36:59
KPROBES_ON_FTRACE is only available on powerpc64le. Update comment to
clarify this.
Also, we should use an offset of 8 to ensure that the probe does not
fall on ftrace location. The current offset of 4 will fall before the
function local entry point and won't fire, while an offset of 12 or 16
will fall on ftrace location. Offset 8 is currently guaranteed to not be
the ftrace location.
Signed-off-by: Naveen N. Rao <redacted>
---
tools/testing/selftests/ftrace/test.d/kprobe/multiple_kprobes.tc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
@@ -2,10 +2,10 @@ # description: Register/unregister many kprobe events # ftrace fentry skip size depends on the machine architecture.-# Currently HAVE_KPROBES_ON_FTRACE defined on x86 and powerpc+# Currently HAVE_KPROBES_ON_FTRACE defined on x86 and powerpc64le case `uname -m` in x86_64|i[3456]86) OFFS=5;;- ppc*) OFFS=4;;+ ppc64le) OFFS=8;; *) OFFS=0;; esac
From: Naveen N. Rao <hidden> Date: 2017-06-29 13:37:12
From: Masami Hiramatsu <mhiramat@kernel.org>
Add a testcase for kprobe event naming. This testcase
checks whether the kprobe events can automatically ganerate
its event name on normal function and dot-suffixed function.
Also it checks whether the kprobe events can correctly
define new event with given event name and group name.
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
[Updated tests to use vfs_read and symbols with '.isra.',
added check for kprobe_events and a command to clear it on exit]
Signed-off-by: Naveen N. Rao <redacted>
---
.../ftrace/test.d/kprobe/kprobe_eventname.tc | 32 ++++++++++++++++++++++
1 file changed, 32 insertions(+)
create mode 100644 tools/testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc
From: Naveen N. Rao <hidden> Date: 2017-06-29 13:37:33
When we derive event names, convert some expected symbols (such as ':'
used to specify module:name and '.' present in some symbols) into
underscores so that the event name is not rejected.
Before this patch:
# echo 'p kobject_example:foo_store' > kprobe_events
trace_kprobe: Failed to allocate trace_probe.(-22)
-sh: write error: Invalid argument
After this patch:
# echo 'p kobject_example:foo_store' > kprobe_events
# cat kprobe_events
p:kprobes/p_kobject_example_foo_store_0 kobject_example:foo_store
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Naveen N. Rao <redacted>
---
kernel/trace/trace_kprobe.c | 9 +++++++++
1 file changed, 9 insertions(+)
On Thu, 29 Jun 2017 19:05:37 +0530
"Naveen N. Rao" [off-list ref] wrote:
quoted hunk
Add a kprobes test to ensure that we are able to add a probe on a
module function using 'p <mod>:<func>' format, without having to
specify a probe name.
Suggested-by: Masami Hiramatsu <mhiramat@kernel.org>
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Naveen N. Rao <redacted>
---
.../testing/selftests/ftrace/test.d/kprobe/probe_module.tc | 14 ++++++++++++++
1 file changed, 14 insertions(+)
create mode 100644 tools/testing/selftests/ftrace/test.d/kprobe/probe_module.tc
Could you also add below case?
echo p:probe_$MOD/$FUNC $MOD/$FUNC > kprobe_events
This is for "new event with name on module" case, your one is for "new event without name on module (automatic name generation)"
We should have different test case, because those kicks slightly different parts in kprobe tracer.
Thank you,
On Thu, 29 Jun 2017 19:05:38 +0530
"Naveen N. Rao" [off-list ref] wrote:
KPROBES_ON_FTRACE is only available on powerpc64le. Update comment to
clarify this.
Also, we should use an offset of 8 to ensure that the probe does not
fall on ftrace location. The current offset of 4 will fall before the
function local entry point and won't fire, while an offset of 12 or 16
will fall on ftrace location. Offset 8 is currently guaranteed to not be
the ftrace location.
OK, looks good to me.
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Thanks!
@@ -2,10 +2,10 @@ # description: Register/unregister many kprobe events # ftrace fentry skip size depends on the machine architecture.-# Currently HAVE_KPROBES_ON_FTRACE defined on x86 and powerpc+# Currently HAVE_KPROBES_ON_FTRACE defined on x86 and powerpc64le case `uname -m` in x86_64|i[3456]86) OFFS=5;;- ppc*) OFFS=4;;+ ppc64le) OFFS=8;; *) OFFS=0;; esac
On Thu, 29 Jun 2017 19:05:39 +0530
"Naveen N. Rao" [off-list ref] wrote:
quoted hunk
From: Masami Hiramatsu <mhiramat@kernel.org>
Add a testcase for kprobe event naming. This testcase
checks whether the kprobe events can automatically ganerate
its event name on normal function and dot-suffixed function.
Also it checks whether the kprobe events can correctly
define new event with given event name and group name.
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
[Updated tests to use vfs_read and symbols with '.isra.',
added check for kprobe_events and a command to clear it on exit]
Signed-off-by: Naveen N. Rao <redacted>
---
.../ftrace/test.d/kprobe/kprobe_eventname.tc | 32 ++++++++++++++++++++++
1 file changed, 32 insertions(+)
create mode 100644 tools/testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc
@@ -0,0 +1,32 @@+#!/bin/sh+# description: Kprobe event auto/manual naming++[ -f kprobe_events ] || exit_unsupported # this is configurable++disable_events+echo > kprobe_events++:;: "Add an event on function without name" ;:++FUNC=`grep " [tT] .*vfs_read$" /proc/kallsyms | tail -n 1 | cut -f 3 -d " "`+echo p $FUNC > kprobe_events+FUNC_NAME=`echo $FUNC | tr ".:" "_"`+test -d events/kprobes/p_${FUNC_NAME}_0 || exit_failure++:;: "Add an event on function with new name" ;:++echo p:event1 $FUNC > kprobe_events+test -d events/kprobes/event1 || exit_failure++:;: "Add an event on function with new name and group" ;:++echo p:kprobes2/event2 $FUNC > kprobe_events+test -d events/kprobes2/event2 || exit_failure++:;: "Add an event on dot function without name" ;:++FUNC=`grep -m 10 " [tT] .*\.isra\..*$" /proc/kallsyms | tail -n 1 | cut -f 3 -d " "`
Since in some case we may not be able to find the function(e.g. build with old gcc or not optimized), we should check this is exist. I suggested to return UNRESOLVED for that case instead of FAIL, as below.
FUNC=`grep -m 10 " [tT] .*\.isra\..*$" /proc/kallsyms | tail -n 1 | cut -f 3 -d " "` || exit_unresolved
Thank you,
On Thu, 29 Jun 2017 19:05:37 +0530
"Naveen N. Rao" [off-list ref] wrote:
quoted
Add a kprobes test to ensure that we are able to add a probe on a
module function using 'p <mod>:<func>' format, without having to
specify a probe name.
Suggested-by: Masami Hiramatsu <mhiramat@kernel.org>
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Naveen N. Rao <redacted>
---
.../testing/selftests/ftrace/test.d/kprobe/probe_module.tc | 14 ++++++++++++++
1 file changed, 14 insertions(+)
create mode 100644 tools/testing/selftests/ftrace/test.d/kprobe/probe_module.tc
Could you also add below case?
echo p:probe_$MOD/$FUNC $MOD/$FUNC > kprobe_events
Oops, it should be something like
echo "p:test_${MOD}_${FUNC} $MOD/$FUNC" > kprobe_events
since we would like to avoid adding new group name for it.
(Adding new group name should be a separated one.)
Thank you,
This is for "new event with name on module" case, your one is for "new event without name on module (automatic name generation)"
We should have different test case, because those kicks slightly different parts in kprobe tracer.
Thank you,
On Thu, 29 Jun 2017 19:05:37 +0530
"Naveen N. Rao" [off-list ref] wrote:
quoted
Add a kprobes test to ensure that we are able to add a probe on a
module function using 'p <mod>:<func>' format, without having to
specify a probe name.
Suggested-by: Masami Hiramatsu <mhiramat@kernel.org>
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Naveen N. Rao <redacted>
---
.../testing/selftests/ftrace/test.d/kprobe/probe_module.tc | 14 ++++++++++++++
1 file changed, 14 insertions(+)
create mode 100644 tools/testing/selftests/ftrace/test.d/kprobe/probe_module.tc
Could you also add below case?
echo p:probe_$MOD/$FUNC $MOD/$FUNC > kprobe_events
Oops, it should be something like
echo "p:test_${MOD}_${FUNC} $MOD/$FUNC" > kprobe_events
since we would like to avoid adding new group name for it.
(Adding new group name should be a separated one.)
Thank you,
quoted
This is for "new event with name on module" case, your one is for "new event without name on module (automatic name generation)"
We should have different test case, because those kicks slightly different parts in kprobe tracer.
Sure. Will make changes to the two tests here and re-spin.
Thanks,
Naveen