linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] [GIT PULL] tracing: Add test that tests the last fix
@ 2017-04-18 16:58 Steven Rostedt
  2017-04-18 16:58 ` [PATCH 1/2] selftests: ftrace: Add a testcase for function PID filter Steven Rostedt
  2017-04-18 16:58 ` [PATCH 2/2] selftests: ftrace: Add check for function-fork before running pid filter test Steven Rostedt
  0 siblings, 2 replies; 3+ messages in thread
From: Steven Rostedt @ 2017-04-18 16:58 UTC (permalink / raw)
  To: linux-kernel
  Cc: Linus Torvalds, Ingo Molnar, Andrew Morton, Namhyung Kim,
	Masami Hiramatsu, Shuah Khan


Linus,

While testing my development branch, without the fix for the pid use
after free bug, the selftest that Namhyung added triggers it. I figured
it would be good to add the test for the bug after the fix, such that
it does not exist without the fix.

I added another patch that lets the test only test part of the pid
filtering, and ignores the function-fork (filtering on children as well)
if the function-fork feature does not exist. This feature is added by
Namhyung just before he added this test. But since the test tests both
with and without the feature, it would be good to let it not fail if
the feature does not exist.

This pull is on top of the fix I just sent:

  "ftrace: Fix function pid filter on instances"

Please pull the latest trace-v4.11-rc5-4 tree, which can be found at:


  git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
trace-v4.11-rc5-4

Tag SHA1: f70cf27fd881e9a2e4a6c339d620d43ceb4693ec
Head SHA1: 9ed19c7695670d00455c1de4682d5c7f14618689


Namhyung Kim (1):
      selftests: ftrace: Add a testcase for function PID filter

Steven Rostedt (VMware) (1):
      selftests: ftrace: Add check for function-fork before running pid filter test

----
 .../ftrace/test.d/ftrace/func-filter-pid.tc        | 117 +++++++++++++++++++++
 1 file changed, 117 insertions(+)
 create mode 100644 tools/testing/selftests/ftrace/test.d/ftrace/func-filter-pid.tc

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

* [PATCH 1/2] selftests: ftrace: Add a testcase for function PID filter
  2017-04-18 16:58 [PATCH 0/2] [GIT PULL] tracing: Add test that tests the last fix Steven Rostedt
@ 2017-04-18 16:58 ` Steven Rostedt
  2017-04-18 16:58 ` [PATCH 2/2] selftests: ftrace: Add check for function-fork before running pid filter test Steven Rostedt
  1 sibling, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2017-04-18 16:58 UTC (permalink / raw)
  To: linux-kernel
  Cc: Linus Torvalds, Ingo Molnar, Andrew Morton, Namhyung Kim,
	Masami Hiramatsu, Shuah Khan

[-- Attachment #1: 0001-selftests-ftrace-Add-a-testcase-for-function-PID-fil.patch --]
[-- Type: text/plain, Size: 3145 bytes --]

From: Namhyung Kim <namhyung@kernel.org>

Like event pid filtering test, add function pid filtering test with the
new "function-fork" option.  It also tests it on an instance directory
so that it can verify the bug related pid filtering on instances.

Link: http://lkml.kernel.org/r/20170417024430.21194-5-namhyung@kernel.org

Cc: Ingo Molnar <mingo@kernel.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Shuah Khan <shuahkh@osg.samsung.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 .../ftrace/test.d/ftrace/func-filter-pid.tc        | 98 ++++++++++++++++++++++
 1 file changed, 98 insertions(+)
 create mode 100644 tools/testing/selftests/ftrace/test.d/ftrace/func-filter-pid.tc

diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/func-filter-pid.tc b/tools/testing/selftests/ftrace/test.d/ftrace/func-filter-pid.tc
new file mode 100644
index 000000000000..cd552f44c3b4
--- /dev/null
+++ b/tools/testing/selftests/ftrace/test.d/ftrace/func-filter-pid.tc
@@ -0,0 +1,98 @@
+#!/bin/sh
+# description: ftrace - function pid filters
+
+# Make sure that function pid matching filter works.
+# Also test it on an instance directory
+
+if ! grep -q function available_tracers; then
+    echo "no function tracer configured"
+    exit_unsupported
+fi
+
+if [ ! -f set_ftrace_pid ]; then
+    echo "set_ftrace_pid not found? Is function tracer not set?"
+    exit_unsupported
+fi
+
+if [ ! -f set_ftrace_filter ]; then
+    echo "set_ftrace_filter not found? Is function tracer not set?"
+    exit_unsupported
+fi
+
+read PID _ < /proc/self/stat
+
+# default value of function-fork option
+orig_value=`grep function-fork trace_options`
+
+do_reset() {
+    reset_tracer
+    clear_trace
+    enable_tracing
+    echo > set_ftrace_filter
+    echo > set_ftrace_pid
+
+    echo $orig_value > trace_options
+}
+
+fail() { # msg
+    do_reset
+    echo $1
+    exit $FAIL
+}
+
+yield() {
+    ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1
+}
+
+do_test() {
+    disable_tracing
+
+    echo do_execve* > set_ftrace_filter
+    echo *do_fork >> set_ftrace_filter
+
+    echo $PID > set_ftrace_pid
+    echo function > current_tracer
+
+    # don't allow children to be traced
+    echo nofunction-fork > trace_options
+
+    enable_tracing
+    yield
+
+    count_pid=`cat trace | grep -v ^# | grep $PID | wc -l`
+    count_other=`cat trace | grep -v ^# | grep -v $PID | wc -l`
+
+    # count_other should be 0
+    if [ $count_pid -eq 0 -o $count_other -ne 0 ]; then
+	fail "PID filtering not working?"
+    fi
+
+    disable_tracing
+    clear_trace
+
+    # allow children to be traced
+    echo function-fork > trace_options
+
+    enable_tracing
+    yield
+
+    count_pid=`cat trace | grep -v ^# | grep $PID | wc -l`
+    count_other=`cat trace | grep -v ^# | grep -v $PID | wc -l`
+
+    # count_other should NOT be 0
+    if [ $count_pid -eq 0 -o $count_other -eq 0 ]; then
+	fail "PID filtering not following fork?"
+    fi
+}
+
+do_test
+
+mkdir instances/foo
+cd instances/foo
+do_test
+cd ../../
+rmdir instances/foo
+
+do_reset
+
+exit 0
-- 
2.10.2

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

* [PATCH 2/2] selftests: ftrace: Add check for function-fork before running pid filter test
  2017-04-18 16:58 [PATCH 0/2] [GIT PULL] tracing: Add test that tests the last fix Steven Rostedt
  2017-04-18 16:58 ` [PATCH 1/2] selftests: ftrace: Add a testcase for function PID filter Steven Rostedt
@ 2017-04-18 16:58 ` Steven Rostedt
  1 sibling, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2017-04-18 16:58 UTC (permalink / raw)
  To: linux-kernel
  Cc: Linus Torvalds, Ingo Molnar, Andrew Morton, Namhyung Kim,
	Masami Hiramatsu, Shuah Khan

[-- Attachment #1: 0002-selftests-ftrace-Add-check-for-function-fork-before-.patch --]
[-- Type: text/plain, Size: 2303 bytes --]

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

Have the func-filter-pid test check for the function-fork option before
testing it. It can still test the pid filtering, but will stop before
testing the function-fork option for children inheriting the pids.
This allows the test to be added before the function-fork feature, but after
a bug fix that triggers one of the bugs the test can cause.

Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Shuah Khan <shuahkh@osg.samsung.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 .../ftrace/test.d/ftrace/func-filter-pid.tc        | 27 ++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/func-filter-pid.tc b/tools/testing/selftests/ftrace/test.d/ftrace/func-filter-pid.tc
index cd552f44c3b4..bab5ff7c607e 100644
--- a/tools/testing/selftests/ftrace/test.d/ftrace/func-filter-pid.tc
+++ b/tools/testing/selftests/ftrace/test.d/ftrace/func-filter-pid.tc
@@ -19,10 +19,19 @@ if [ ! -f set_ftrace_filter ]; then
     exit_unsupported
 fi
 
+do_function_fork=1
+
+if [ ! -f options/function-fork ]; then
+    do_function_fork=0
+    echo "no option for function-fork found. Option will not be tested."
+fi
+
 read PID _ < /proc/self/stat
 
-# default value of function-fork option
-orig_value=`grep function-fork trace_options`
+if [ $do_function_fork -eq 1 ]; then
+    # default value of function-fork option
+    orig_value=`grep function-fork trace_options`
+fi
 
 do_reset() {
     reset_tracer
@@ -31,6 +40,10 @@ do_reset() {
     echo > set_ftrace_filter
     echo > set_ftrace_pid
 
+    if [ $do_function_fork -eq 0 ]; then
+	return
+    fi
+
     echo $orig_value > trace_options
 }
 
@@ -53,8 +66,10 @@ do_test() {
     echo $PID > set_ftrace_pid
     echo function > current_tracer
 
-    # don't allow children to be traced
-    echo nofunction-fork > trace_options
+    if [ $do_function_fork -eq 1 ]; then
+	# don't allow children to be traced
+	echo nofunction-fork > trace_options
+    fi
 
     enable_tracing
     yield
@@ -70,6 +85,10 @@ do_test() {
     disable_tracing
     clear_trace
 
+    if [ $do_function_fork -eq 0 ]; then
+	return
+    fi
+
     # allow children to be traced
     echo function-fork > trace_options
 
-- 
2.10.2

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

end of thread, other threads:[~2017-04-18 17:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-18 16:58 [PATCH 0/2] [GIT PULL] tracing: Add test that tests the last fix Steven Rostedt
2017-04-18 16:58 ` [PATCH 1/2] selftests: ftrace: Add a testcase for function PID filter Steven Rostedt
2017-04-18 16:58 ` [PATCH 2/2] selftests: ftrace: Add check for function-fork before running pid filter test 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).