* [PATCH v3 0/4] A fix and a few new tests for kprobe tracer
@ 2017-07-07 18:57 Naveen N. Rao
2017-07-07 18:57 ` [PATCH v3 1/4] trace/kprobes: Sanitize derived event names Naveen N. Rao
` (4 more replies)
0 siblings, 5 replies; 8+ messages in thread
From: Naveen N. Rao @ 2017-07-07 18:57 UTC (permalink / raw)
To: Steven Rostedt
Cc: Masami Hiramatsu, Ananth N Mavinakayanahalli, Michael Ellerman,
Shuah Khan, linux-kernel
v2:
https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1434048.html
Changes since v2:
- Update tests to include additional scenarios and better error
checking.
Thanks,
Naveen
Masami Hiramatsu (1):
selftests/ftrace: Add a testcase for kprobe event naming
Naveen N. Rao (3):
trace/kprobes: Sanitize derived event names
selftests/ftrace: Update multiple kprobes test for powerpc
selftests/ftrace: Add a test to probe module functions
kernel/trace/trace_kprobe.c | 9 ++++++
.../ftrace/test.d/kprobe/kprobe_eventname.tc | 36 ++++++++++++++++++++++
.../ftrace/test.d/kprobe/kprobe_module.tc | 28 +++++++++++++++++
.../ftrace/test.d/kprobe/multiple_kprobes.tc | 4 +--
4 files changed, 75 insertions(+), 2 deletions(-)
create mode 100644 tools/testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc
create mode 100644 tools/testing/selftests/ftrace/test.d/kprobe/kprobe_module.tc
--
2.13.2
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v3 1/4] trace/kprobes: Sanitize derived event names
2017-07-07 18:57 [PATCH v3 0/4] A fix and a few new tests for kprobe tracer Naveen N. Rao
@ 2017-07-07 18:57 ` Naveen N. Rao
2017-07-07 18:57 ` [PATCH v3 2/4] selftests/ftrace: Update multiple kprobes test for powerpc Naveen N. Rao
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Naveen N. Rao @ 2017-07-07 18:57 UTC (permalink / raw)
To: Steven Rostedt
Cc: Masami Hiramatsu, Ananth N Mavinakayanahalli, Michael Ellerman,
Shuah Khan, linux-kernel
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 <naveen.n.rao@linux.vnet.ibm.com>
---
kernel/trace/trace_kprobe.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index c129fca6ec99..44fd819aa33d 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -598,6 +598,14 @@ static struct notifier_block trace_kprobe_module_nb = {
.priority = 1 /* Invoked after kprobe module callback */
};
+/* Convert certain expected symbols into '_' when generating event names */
+static inline void sanitize_event_name(char *name)
+{
+ while (*name++ != '\0')
+ if (*name == ':' || *name == '.')
+ *name = '_';
+}
+
static int create_trace_kprobe(int argc, char **argv)
{
/*
@@ -740,6 +748,7 @@ static int create_trace_kprobe(int argc, char **argv)
else
snprintf(buf, MAX_EVENT_NAME_LEN, "%c_0x%p",
is_return ? 'r' : 'p', addr);
+ sanitize_event_name(buf);
event = buf;
}
tk = alloc_trace_kprobe(group, event, addr, symbol, offset, maxactive,
--
2.13.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v3 2/4] selftests/ftrace: Update multiple kprobes test for powerpc
2017-07-07 18:57 [PATCH v3 0/4] A fix and a few new tests for kprobe tracer Naveen N. Rao
2017-07-07 18:57 ` [PATCH v3 1/4] trace/kprobes: Sanitize derived event names Naveen N. Rao
@ 2017-07-07 18:57 ` Naveen N. Rao
2017-07-07 18:57 ` [PATCH v3 3/4] selftests/ftrace: Add a test to probe module functions Naveen N. Rao
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Naveen N. Rao @ 2017-07-07 18:57 UTC (permalink / raw)
To: Steven Rostedt
Cc: Masami Hiramatsu, Ananth N Mavinakayanahalli, Michael Ellerman,
Shuah Khan, linux-kernel
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.
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
---
tools/testing/selftests/ftrace/test.d/kprobe/multiple_kprobes.tc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/multiple_kprobes.tc b/tools/testing/selftests/ftrace/test.d/kprobe/multiple_kprobes.tc
index f4d1ff785d67..2a1cb9908746 100644
--- a/tools/testing/selftests/ftrace/test.d/kprobe/multiple_kprobes.tc
+++ b/tools/testing/selftests/ftrace/test.d/kprobe/multiple_kprobes.tc
@@ -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
--
2.13.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v3 3/4] selftests/ftrace: Add a test to probe module functions
2017-07-07 18:57 [PATCH v3 0/4] A fix and a few new tests for kprobe tracer Naveen N. Rao
2017-07-07 18:57 ` [PATCH v3 1/4] trace/kprobes: Sanitize derived event names Naveen N. Rao
2017-07-07 18:57 ` [PATCH v3 2/4] selftests/ftrace: Update multiple kprobes test for powerpc Naveen N. Rao
@ 2017-07-07 18:57 ` Naveen N. Rao
2017-07-07 18:57 ` [PATCH v3 4/4] selftests/ftrace: Add a testcase for kprobe event naming Naveen N. Rao
2017-07-09 11:48 ` [PATCH v3 0/4] A fix and a few new tests for kprobe tracer Steven Rostedt
4 siblings, 0 replies; 8+ messages in thread
From: Naveen N. Rao @ 2017-07-07 18:57 UTC (permalink / raw)
To: Steven Rostedt
Cc: Masami Hiramatsu, Ananth N Mavinakayanahalli, Michael Ellerman,
Shuah Khan, linux-kernel
Add a kprobes test to ensure that we are able to add a probe on a
module function using 'p <mod>:<func>' format, with/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 <naveen.n.rao@linux.vnet.ibm.com>
---
.../ftrace/test.d/kprobe/kprobe_module.tc | 28 ++++++++++++++++++++++
1 file changed, 28 insertions(+)
create mode 100644 tools/testing/selftests/ftrace/test.d/kprobe/kprobe_module.tc
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_module.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_module.tc
new file mode 100644
index 000000000000..6d634e4b7680
--- /dev/null
+++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_module.tc
@@ -0,0 +1,28 @@
+#!/bin/sh
+# description: Kprobe dynamic event - probing module
+
+[ -f kprobe_events ] || exit_unsupported # this is configurable
+
+disable_events
+echo > kprobe_events
+
+:;: "Add an event on a module function without specifying event name" ;:
+
+MOD=`lsmod | head -n 2 | tail -n 1 | cut -f1 -d" "`
+FUNC=`grep -m 1 ".* t .*\\[$MOD\\]" /proc/kallsyms | xargs | cut -f3 -d" "`
+[ "x" != "x$MOD" -a "y" != "y$FUNC" ] || exit_unresolved
+echo "p $MOD:$FUNC" > kprobe_events
+PROBE_NAME=`echo $MOD:$FUNC | tr ".:" "_"`
+test -d events/kprobes/p_${PROBE_NAME}_0 || exit_failure
+
+:;: "Add an event on a module function with new event name" ;:
+
+echo "p:event1 $MOD:$FUNC" > kprobe_events
+test -d events/kprobes/event1 || exit_failure
+
+:;: "Add an event on a module function with new event and group name" ;:
+
+echo "p:kprobes1/event1 $MOD:$FUNC" > kprobe_events
+test -d events/kprobes1/event1 || exit_failure
+
+echo > kprobe_events
--
2.13.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v3 4/4] selftests/ftrace: Add a testcase for kprobe event naming
2017-07-07 18:57 [PATCH v3 0/4] A fix and a few new tests for kprobe tracer Naveen N. Rao
` (2 preceding siblings ...)
2017-07-07 18:57 ` [PATCH v3 3/4] selftests/ftrace: Add a test to probe module functions Naveen N. Rao
@ 2017-07-07 18:57 ` Naveen N. Rao
2017-07-09 11:48 ` [PATCH v3 0/4] A fix and a few new tests for kprobe tracer Steven Rostedt
4 siblings, 0 replies; 8+ messages in thread
From: Naveen N. Rao @ 2017-07-07 18:57 UTC (permalink / raw)
To: Steven Rostedt
Cc: Masami Hiramatsu, Ananth N Mavinakayanahalli, Michael Ellerman,
Shuah Khan, linux-kernel
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,
various additional checks and tests]
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
---
.../ftrace/test.d/kprobe/kprobe_eventname.tc | 36 ++++++++++++++++++++++
1 file changed, 36 insertions(+)
create mode 100644 tools/testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc
new file mode 100644
index 000000000000..b9302cc82c12
--- /dev/null
+++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc
@@ -0,0 +1,36 @@
+#!/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 " "`
+[ "x" != "x$FUNC" ] || exit_unresolved
+echo "p $FUNC" > kprobe_events
+PROBE_NAME=`echo $FUNC | tr ".:" "_"`
+test -d events/kprobes/p_${PROBE_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 " "`
+[ "x" != "x$FUNC" ] || exit_unresolved
+echo "p $FUNC" > kprobe_events
+EVENT=`grep $FUNC kprobe_events | cut -f 1 -d " " | cut -f 2 -d:`
+[ "x" != "x$EVENT" ] || exit_failure
+test -d events/$EVENT || exit_failure
+
+echo > kprobe_events
--
2.13.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v3 0/4] A fix and a few new tests for kprobe tracer
2017-07-07 18:57 [PATCH v3 0/4] A fix and a few new tests for kprobe tracer Naveen N. Rao
` (3 preceding siblings ...)
2017-07-07 18:57 ` [PATCH v3 4/4] selftests/ftrace: Add a testcase for kprobe event naming Naveen N. Rao
@ 2017-07-09 11:48 ` Steven Rostedt
2017-07-24 15:58 ` Shuah Khan
4 siblings, 1 reply; 8+ messages in thread
From: Steven Rostedt @ 2017-07-09 11:48 UTC (permalink / raw)
To: Naveen N. Rao
Cc: Masami Hiramatsu, Ananth N Mavinakayanahalli, Michael Ellerman,
Shuah Khan, linux-kernel
On Sat, 8 Jul 2017 00:27:29 +0530
"Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> wrote:
> v2:
> https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1434048.html
>
> Changes since v2:
> - Update tests to include additional scenarios and better error
> checking.
>
I pulled these into my branch and started testing them now.
-- Steve
> Thanks,
> Naveen
>
>
> Masami Hiramatsu (1):
> selftests/ftrace: Add a testcase for kprobe event naming
>
> Naveen N. Rao (3):
> trace/kprobes: Sanitize derived event names
> selftests/ftrace: Update multiple kprobes test for powerpc
> selftests/ftrace: Add a test to probe module functions
>
> kernel/trace/trace_kprobe.c | 9 ++++++
> .../ftrace/test.d/kprobe/kprobe_eventname.tc | 36 ++++++++++++++++++++++
> .../ftrace/test.d/kprobe/kprobe_module.tc | 28 +++++++++++++++++
> .../ftrace/test.d/kprobe/multiple_kprobes.tc | 4 +--
> 4 files changed, 75 insertions(+), 2 deletions(-)
> create mode 100644 tools/testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc
> create mode 100644 tools/testing/selftests/ftrace/test.d/kprobe/kprobe_module.tc
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3 0/4] A fix and a few new tests for kprobe tracer
2017-07-09 11:48 ` [PATCH v3 0/4] A fix and a few new tests for kprobe tracer Steven Rostedt
@ 2017-07-24 15:58 ` Shuah Khan
2017-07-26 21:22 ` Steven Rostedt
0 siblings, 1 reply; 8+ messages in thread
From: Shuah Khan @ 2017-07-24 15:58 UTC (permalink / raw)
To: Steven Rostedt, Naveen N. Rao
Cc: Masami Hiramatsu, Ananth N Mavinakayanahalli, Michael Ellerman,
linux-kernel, Shuah Khan, Shuah Khan
On 07/09/2017 05:48 AM, Steven Rostedt wrote:
> On Sat, 8 Jul 2017 00:27:29 +0530
> "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> wrote:
>
>> v2:
>> https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1434048.html
>>
>> Changes since v2:
>> - Update tests to include additional scenarios and better error
>> checking.
>>
>
> I pulled these into my branch and started testing them now.
>
> -- Steve
Hi Steve,
Here is my ack for selftests in this series.
Acked-by: Shuah Khan <shuahkh@osg.samsung.com>
thanks,
-- Shuah
>
>> Thanks,
>> Naveen
>>
>>
>> Masami Hiramatsu (1):
>> selftests/ftrace: Add a testcase for kprobe event naming
>>
>> Naveen N. Rao (3):
>> trace/kprobes: Sanitize derived event names
>> selftests/ftrace: Update multiple kprobes test for powerpc
>> selftests/ftrace: Add a test to probe module functions
>>
>> kernel/trace/trace_kprobe.c | 9 ++++++
>> .../ftrace/test.d/kprobe/kprobe_eventname.tc | 36 ++++++++++++++++++++++
>> .../ftrace/test.d/kprobe/kprobe_module.tc | 28 +++++++++++++++++
>> .../ftrace/test.d/kprobe/multiple_kprobes.tc | 4 +--
>> 4 files changed, 75 insertions(+), 2 deletions(-)
>> create mode 100644 tools/testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc
>> create mode 100644 tools/testing/selftests/ftrace/test.d/kprobe/kprobe_module.tc
>>
>
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3 0/4] A fix and a few new tests for kprobe tracer
2017-07-24 15:58 ` Shuah Khan
@ 2017-07-26 21:22 ` Steven Rostedt
0 siblings, 0 replies; 8+ messages in thread
From: Steven Rostedt @ 2017-07-26 21:22 UTC (permalink / raw)
To: Shuah Khan
Cc: Naveen N. Rao, Masami Hiramatsu, Ananth N Mavinakayanahalli,
Michael Ellerman, linux-kernel, Shuah Khan
On Mon, 24 Jul 2017 09:58:04 -0600
Shuah Khan <shuah@kernel.org> wrote:
> On 07/09/2017 05:48 AM, Steven Rostedt wrote:
> > On Sat, 8 Jul 2017 00:27:29 +0530
> > "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> wrote:
> >
> >> v2:
> >> https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1434048.html
> >>
> >> Changes since v2:
> >> - Update tests to include additional scenarios and better error
> >> checking.
> >>
> >
> > I pulled these into my branch and started testing them now.
> >
> > -- Steve
>
> Hi Steve,
>
> Here is my ack for selftests in this series.
>
> Acked-by: Shuah Khan <shuahkh@osg.samsung.com>
>
Thanks! Sorry I already pushed it to Linus. :-/
-- Steve
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2017-07-26 21:22 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-07 18:57 [PATCH v3 0/4] A fix and a few new tests for kprobe tracer Naveen N. Rao
2017-07-07 18:57 ` [PATCH v3 1/4] trace/kprobes: Sanitize derived event names Naveen N. Rao
2017-07-07 18:57 ` [PATCH v3 2/4] selftests/ftrace: Update multiple kprobes test for powerpc Naveen N. Rao
2017-07-07 18:57 ` [PATCH v3 3/4] selftests/ftrace: Add a test to probe module functions Naveen N. Rao
2017-07-07 18:57 ` [PATCH v3 4/4] selftests/ftrace: Add a testcase for kprobe event naming Naveen N. Rao
2017-07-09 11:48 ` [PATCH v3 0/4] A fix and a few new tests for kprobe tracer Steven Rostedt
2017-07-24 15:58 ` Shuah Khan
2017-07-26 21:22 ` Steven Rostedt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox