linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selftests/ftrace: Select an existing function in kprobe_eventname test
@ 2019-03-22 19:09 Steven Rostedt
  2019-03-23 12:03 ` Masami Hiramatsu
  2019-07-08 19:10 ` Thadeu Lima de Souza Cascardo
  0 siblings, 2 replies; 6+ messages in thread
From: Steven Rostedt @ 2019-03-22 19:09 UTC (permalink / raw)
  To: LKML; +Cc: Masami Hiramatsu, Shuah Khan, Ingo Molnar, Andrew Morton

From: Steven Rostedt (VMware) <rostedt@goodmis.org>

Running the ftrace selftests on the latest kernel caused the
kprobe_eventname test to fail. It was due to the test that searches for
a function with at "dot" in the name and adding a probe to that.
Unfortunately, for this test, it picked:

 optimize_nops.isra.2.cold.4

Which happens to be marked as "__init", which means it no longer exists
in the kernel! (kallsyms keeps those function names around for tracing
purposes)

As only functions that still exist are in the
available_filter_functions file, as they are removed when the functions
are freed at boot or module exit, have the test search for a function
with ".isra." in the name as well as being in the
available_filter_functions (if the file exists).

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc
index 3fb70e01b1fe..3ff236719b6e 100644
--- a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc
+++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc
@@ -24,7 +24,21 @@ 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 " "`
+find_dot_func() {
+	if [ ! -f available_filter_functions ]; then
+		grep -m 10 " [tT] .*\.isra\..*$" /proc/kallsyms | tail -n 1 | cut -f 3 -d " "
+		return;
+	fi
+
+	grep " [tT] .*\.isra\..*" /proc/kallsyms | cut -f 3 -d " " | while read f; do
+		if grep -s $f available_filter_functions; then
+			echo $f
+			break
+		fi
+	done
+}
+
+FUNC=`find_dot_func | tail -n 1`
 [ "x" != "x$FUNC" ] || exit_unresolved
 echo "p $FUNC" > kprobe_events
 EVENT=`grep $FUNC kprobe_events | cut -f 1 -d " " | cut -f 2 -d:`

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] selftests/ftrace: Select an existing function in kprobe_eventname test
  2019-03-22 19:09 [PATCH] selftests/ftrace: Select an existing function in kprobe_eventname test Steven Rostedt
@ 2019-03-23 12:03 ` Masami Hiramatsu
  2019-07-08 19:10 ` Thadeu Lima de Souza Cascardo
  1 sibling, 0 replies; 6+ messages in thread
From: Masami Hiramatsu @ 2019-03-23 12:03 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: LKML, Masami Hiramatsu, Shuah Khan, Ingo Molnar, Andrew Morton

On Fri, 22 Mar 2019 15:09:23 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:

> From: Steven Rostedt (VMware) <rostedt@goodmis.org>
> 
> Running the ftrace selftests on the latest kernel caused the
> kprobe_eventname test to fail. It was due to the test that searches for
> a function with at "dot" in the name and adding a probe to that.
> Unfortunately, for this test, it picked:
> 
>  optimize_nops.isra.2.cold.4
> 
> Which happens to be marked as "__init", which means it no longer exists
> in the kernel! (kallsyms keeps those function names around for tracing
> purposes)
> 
> As only functions that still exist are in the
> available_filter_functions file, as they are removed when the functions
> are freed at boot or module exit, have the test search for a function
> with ".isra." in the name as well as being in the
> available_filter_functions (if the file exists).

OK, this looks good to me.

Acked-by: Masami Hiramatsu <mhiramat@kernel.org>

Thank you,

> 
> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> ---
> diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc
> index 3fb70e01b1fe..3ff236719b6e 100644
> --- a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc
> +++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc
> @@ -24,7 +24,21 @@ 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 " "`
> +find_dot_func() {
> +	if [ ! -f available_filter_functions ]; then
> +		grep -m 10 " [tT] .*\.isra\..*$" /proc/kallsyms | tail -n 1 | cut -f 3 -d " "
> +		return;
> +	fi
> +
> +	grep " [tT] .*\.isra\..*" /proc/kallsyms | cut -f 3 -d " " | while read f; do
> +		if grep -s $f available_filter_functions; then
> +			echo $f
> +			break
> +		fi
> +	done
> +}
> +
> +FUNC=`find_dot_func | tail -n 1`
>  [ "x" != "x$FUNC" ] || exit_unresolved
>  echo "p $FUNC" > kprobe_events
>  EVENT=`grep $FUNC kprobe_events | cut -f 1 -d " " | cut -f 2 -d:`


-- 
Masami Hiramatsu <mhiramat@kernel.org>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] selftests/ftrace: Select an existing function in kprobe_eventname test
  2019-03-22 19:09 [PATCH] selftests/ftrace: Select an existing function in kprobe_eventname test Steven Rostedt
  2019-03-23 12:03 ` Masami Hiramatsu
@ 2019-07-08 19:10 ` Thadeu Lima de Souza Cascardo
  2019-07-08 19:22   ` Steven Rostedt
  1 sibling, 1 reply; 6+ messages in thread
From: Thadeu Lima de Souza Cascardo @ 2019-07-08 19:10 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: LKML, Masami Hiramatsu, Shuah Khan, Ingo Molnar, Andrew Morton

On Fri, Mar 22, 2019 at 03:09:23PM -0400, Steven Rostedt wrote:
> From: Steven Rostedt (VMware) <rostedt@goodmis.org>
> 
> Running the ftrace selftests on the latest kernel caused the
> kprobe_eventname test to fail. It was due to the test that searches for
> a function with at "dot" in the name and adding a probe to that.
> Unfortunately, for this test, it picked:
> 
>  optimize_nops.isra.2.cold.4
> 
> Which happens to be marked as "__init", which means it no longer exists
> in the kernel! (kallsyms keeps those function names around for tracing
> purposes)
> 
> As only functions that still exist are in the
> available_filter_functions file, as they are removed when the functions
> are freed at boot or module exit, have the test search for a function
> with ".isra." in the name as well as being in the
> available_filter_functions (if the file exists).
> 

This fixes a similar problem for me.

Tested-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>

> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> ---
> diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc
> index 3fb70e01b1fe..3ff236719b6e 100644
> --- a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc
> +++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc
> @@ -24,7 +24,21 @@ 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 " "`
> +find_dot_func() {
> +	if [ ! -f available_filter_functions ]; then
> +		grep -m 10 " [tT] .*\.isra\..*$" /proc/kallsyms | tail -n 1 | cut -f 3 -d " "
> +		return;
> +	fi
> +
> +	grep " [tT] .*\.isra\..*" /proc/kallsyms | cut -f 3 -d " " | while read f; do
> +		if grep -s $f available_filter_functions; then
> +			echo $f
> +			break
> +		fi
> +	done
> +}
> +
> +FUNC=`find_dot_func | tail -n 1`
>  [ "x" != "x$FUNC" ] || exit_unresolved
>  echo "p $FUNC" > kprobe_events
>  EVENT=`grep $FUNC kprobe_events | cut -f 1 -d " " | cut -f 2 -d:`

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] selftests/ftrace: Select an existing function in kprobe_eventname test
  2019-07-08 19:10 ` Thadeu Lima de Souza Cascardo
@ 2019-07-08 19:22   ` Steven Rostedt
  2019-07-09 12:44     ` Masami Hiramatsu
  0 siblings, 1 reply; 6+ messages in thread
From: Steven Rostedt @ 2019-07-08 19:22 UTC (permalink / raw)
  To: Thadeu Lima de Souza Cascardo
  Cc: LKML, Masami Hiramatsu, Shuah Khan, Ingo Molnar, Andrew Morton

On Mon, 8 Jul 2019 16:10:29 -0300
Thadeu Lima de Souza Cascardo <cascardo@canonical.com> wrote:

> On Fri, Mar 22, 2019 at 03:09:23PM -0400, Steven Rostedt wrote:
> > From: Steven Rostedt (VMware) <rostedt@goodmis.org>
> > 
> > Running the ftrace selftests on the latest kernel caused the
> > kprobe_eventname test to fail. It was due to the test that searches for
> > a function with at "dot" in the name and adding a probe to that.
> > Unfortunately, for this test, it picked:
> > 
> >  optimize_nops.isra.2.cold.4
> > 
> > Which happens to be marked as "__init", which means it no longer exists
> > in the kernel! (kallsyms keeps those function names around for tracing
> > purposes)
> > 
> > As only functions that still exist are in the
> > available_filter_functions file, as they are removed when the functions
> > are freed at boot or module exit, have the test search for a function
> > with ".isra." in the name as well as being in the
> > available_filter_functions (if the file exists).
> >   
> 
> This fixes a similar problem for me.
> 
> Tested-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>

Masami, can you ack this, and Shuah, can you take it?

Thanks!

-- Steve

> 
> > Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> > ---
> > diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc
> > index 3fb70e01b1fe..3ff236719b6e 100644
> > --- a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc
> > +++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc
> > @@ -24,7 +24,21 @@ 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 " "`
> > +find_dot_func() {
> > +	if [ ! -f available_filter_functions ]; then
> > +		grep -m 10 " [tT] .*\.isra\..*$" /proc/kallsyms | tail -n 1 | cut -f 3 -d " "
> > +		return;
> > +	fi
> > +
> > +	grep " [tT] .*\.isra\..*" /proc/kallsyms | cut -f 3 -d " " | while read f; do
> > +		if grep -s $f available_filter_functions; then
> > +			echo $f
> > +			break
> > +		fi
> > +	done
> > +}
> > +
> > +FUNC=`find_dot_func | tail -n 1`
> >  [ "x" != "x$FUNC" ] || exit_unresolved
> >  echo "p $FUNC" > kprobe_events
> >  EVENT=`grep $FUNC kprobe_events | cut -f 1 -d " " | cut -f 2 -d:`  


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] selftests/ftrace: Select an existing function in kprobe_eventname test
  2019-07-08 19:22   ` Steven Rostedt
@ 2019-07-09 12:44     ` Masami Hiramatsu
  2019-07-09 14:44       ` Steven Rostedt
  0 siblings, 1 reply; 6+ messages in thread
From: Masami Hiramatsu @ 2019-07-09 12:44 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Thadeu Lima de Souza Cascardo, LKML, Masami Hiramatsu,
	Shuah Khan, Ingo Molnar, Andrew Morton

On Mon, 8 Jul 2019 15:22:14 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:

> On Mon, 8 Jul 2019 16:10:29 -0300
> Thadeu Lima de Souza Cascardo <cascardo@canonical.com> wrote:
> 
> > On Fri, Mar 22, 2019 at 03:09:23PM -0400, Steven Rostedt wrote:
> > > From: Steven Rostedt (VMware) <rostedt@goodmis.org>
> > > 
> > > Running the ftrace selftests on the latest kernel caused the
> > > kprobe_eventname test to fail. It was due to the test that searches for
> > > a function with at "dot" in the name and adding a probe to that.
> > > Unfortunately, for this test, it picked:
> > > 
> > >  optimize_nops.isra.2.cold.4
> > > 
> > > Which happens to be marked as "__init", which means it no longer exists
> > > in the kernel! (kallsyms keeps those function names around for tracing
> > > purposes)

Ouch!

> > > 
> > > As only functions that still exist are in the
> > > available_filter_functions file, as they are removed when the functions
> > > are freed at boot or module exit, have the test search for a function
> > > with ".isra." in the name as well as being in the
> > > available_filter_functions (if the file exists).

Hmm, OK. But I think this eventually fixed in kallsyms, by something like 
having [GONE] or [__init] flag for such symbols.

> > >   
> > 
> > This fixes a similar problem for me.
> > 
> > Tested-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
> 
> Masami, can you ack this, and Shuah, can you take it?

Yeah anyway,

Acked-by: Masami Hiramatsu <mhiramat@kernel.org>

Thank you!

> 
> Thanks!
> 
> -- Steve
> 
> > 
> > > Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> > > ---
> > > diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc
> > > index 3fb70e01b1fe..3ff236719b6e 100644
> > > --- a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc
> > > +++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc
> > > @@ -24,7 +24,21 @@ 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 " "`
> > > +find_dot_func() {
> > > +	if [ ! -f available_filter_functions ]; then
> > > +		grep -m 10 " [tT] .*\.isra\..*$" /proc/kallsyms | tail -n 1 | cut -f 3 -d " "
> > > +		return;
> > > +	fi
> > > +
> > > +	grep " [tT] .*\.isra\..*" /proc/kallsyms | cut -f 3 -d " " | while read f; do
> > > +		if grep -s $f available_filter_functions; then
> > > +			echo $f
> > > +			break
> > > +		fi
> > > +	done
> > > +}
> > > +
> > > +FUNC=`find_dot_func | tail -n 1`
> > >  [ "x" != "x$FUNC" ] || exit_unresolved
> > >  echo "p $FUNC" > kprobe_events
> > >  EVENT=`grep $FUNC kprobe_events | cut -f 1 -d " " | cut -f 2 -d:`  
> 


-- 
Masami Hiramatsu <mhiramat@kernel.org>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] selftests/ftrace: Select an existing function in kprobe_eventname test
  2019-07-09 12:44     ` Masami Hiramatsu
@ 2019-07-09 14:44       ` Steven Rostedt
  0 siblings, 0 replies; 6+ messages in thread
From: Steven Rostedt @ 2019-07-09 14:44 UTC (permalink / raw)
  To: Masami Hiramatsu
  Cc: Thadeu Lima de Souza Cascardo, LKML, Shuah Khan, Ingo Molnar,
	Andrew Morton

On Tue, 9 Jul 2019 21:44:02 +0900
Masami Hiramatsu <mhiramat@kernel.org> wrote:

> > Masami, can you ack this, and Shuah, can you take it?  
> 
> Yeah anyway,
> 
> Acked-by: Masami Hiramatsu <mhiramat@kernel.org>

Thanks Masami,

Shuah, want to take this in your tree?

-- Steve

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-07-09 14:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-22 19:09 [PATCH] selftests/ftrace: Select an existing function in kprobe_eventname test Steven Rostedt
2019-03-23 12:03 ` Masami Hiramatsu
2019-07-08 19:10 ` Thadeu Lima de Souza Cascardo
2019-07-08 19:22   ` Steven Rostedt
2019-07-09 12:44     ` Masami Hiramatsu
2019-07-09 14:44       ` Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).