diff mbox series

[v2,22/32] selftests/ftrace: Add ringbuffer size changing testcase

Message ID 153443757416.23257.9284862385646039929.stgit@devbox (mailing list archive)
State Superseded
Headers show
Series selftests/ftrace: Improve ftracetest with coverage check | expand

Commit Message

Masami Hiramatsu (Google) Aug. 16, 2018, 4:39 p.m. UTC
Add a testcase for changing ringbuffer size. This tests
not only ringbuffer size but also tests the imbalance
per-cpu buffer size change too.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
 .../ftrace/test.d/00basic/ringbuffer_size.tc       |   21 ++++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100644 tools/testing/selftests/ftrace/test.d/00basic/ringbuffer_size.tc

Comments

Steven Rostedt Aug. 24, 2018, 11:18 p.m. UTC | #1
On Fri, 17 Aug 2018 01:39:34 +0900
Masami Hiramatsu <mhiramat@kernel.org> wrote:

> Add a testcase for changing ringbuffer size. This tests
> not only ringbuffer size but also tests the imbalance
> per-cpu buffer size change too.
> 
> Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>

I'm fine with this, but one day I need to port over some of my other
tests. I have a test that stresses the ring buffer size (basically
checks to see if it can cause an oom). I need to port that to
selftests. But for now...

Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

But, one more thing..

> ---
>  .../ftrace/test.d/00basic/ringbuffer_size.tc       |   21 ++++++++++++++++++++
>  1 file changed, 21 insertions(+)
>  create mode 100644 tools/testing/selftests/ftrace/test.d/00basic/ringbuffer_size.tc
> 
> diff --git a/tools/testing/selftests/ftrace/test.d/00basic/ringbuffer_size.tc b/tools/testing/selftests/ftrace/test.d/00basic/ringbuffer_size.tc
> new file mode 100644
> index 000000000000..9224f33b3194
> --- /dev/null
> +++ b/tools/testing/selftests/ftrace/test.d/00basic/ringbuffer_size.tc
> @@ -0,0 +1,21 @@
> +#!/bin/sh
> +# SPDX-License-Identifier: GPL-2.0
> +# description: Change the ringbuffer size

Should add:

 # flags: instance

As this works for instances as well.

-- Steve

> +
> +rb_size_test() {
> +ORIG=`cat buffer_size_kb`
> +
> +expr $ORIG / 2 > buffer_size_kb
> +
> +expr $ORIG \* 2 > buffer_size_kb
> +
> +echo $ORIG > buffer_size_kb
> +}
> +
> +rb_size_test
> +
> +: "If per-cpu buffer is supported, imbalance it"
> +if [ -d per_cpu/cpu0 ]; then
> +  cd per_cpu/cpu0
> +  rb_size_test
> +fi
Masami Hiramatsu (Google) Aug. 30, 2018, 7:12 a.m. UTC | #2
On Fri, 24 Aug 2018 19:18:36 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:

> On Fri, 17 Aug 2018 01:39:34 +0900
> Masami Hiramatsu <mhiramat@kernel.org> wrote:
> 
> > Add a testcase for changing ringbuffer size. This tests
> > not only ringbuffer size but also tests the imbalance
> > per-cpu buffer size change too.
> > 
> > Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
> 
> I'm fine with this, but one day I need to port over some of my other
> tests. I have a test that stresses the ring buffer size (basically
> checks to see if it can cause an oom). I need to port that to
> selftests. But for now...

Hmm, such stress test is not good for kselftest, since it can cause
oom and kill some test process. Maybe we should have such stresstest
framework (which allows test to crash kernel)

> 
> Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> 
> But, one more thing..
> 
> > ---
> >  .../ftrace/test.d/00basic/ringbuffer_size.tc       |   21 ++++++++++++++++++++
> >  1 file changed, 21 insertions(+)
> >  create mode 100644 tools/testing/selftests/ftrace/test.d/00basic/ringbuffer_size.tc
> > 
> > diff --git a/tools/testing/selftests/ftrace/test.d/00basic/ringbuffer_size.tc b/tools/testing/selftests/ftrace/test.d/00basic/ringbuffer_size.tc
> > new file mode 100644
> > index 000000000000..9224f33b3194
> > --- /dev/null
> > +++ b/tools/testing/selftests/ftrace/test.d/00basic/ringbuffer_size.tc
> > @@ -0,0 +1,21 @@
> > +#!/bin/sh
> > +# SPDX-License-Identifier: GPL-2.0
> > +# description: Change the ringbuffer size
> 
> Should add:
> 
>  # flags: instance

OK, I'll add it.

Thank you!

> 
> As this works for instances as well.
> 
> -- Steve
> 
> > +
> > +rb_size_test() {
> > +ORIG=`cat buffer_size_kb`
> > +
> > +expr $ORIG / 2 > buffer_size_kb
> > +
> > +expr $ORIG \* 2 > buffer_size_kb
> > +
> > +echo $ORIG > buffer_size_kb
> > +}
> > +
> > +rb_size_test
> > +
> > +: "If per-cpu buffer is supported, imbalance it"
> > +if [ -d per_cpu/cpu0 ]; then
> > +  cd per_cpu/cpu0
> > +  rb_size_test
> > +fi
>
Steven Rostedt Aug. 30, 2018, 3:50 p.m. UTC | #3
On Thu, 30 Aug 2018 16:12:18 +0900
Masami Hiramatsu <mhiramat@kernel.org> wrote:

> > I'm fine with this, but one day I need to port over some of my other
> > tests. I have a test that stresses the ring buffer size (basically
> > checks to see if it can cause an oom). I need to port that to
> > selftests. But for now...  
> 
> Hmm, such stress test is not good for kselftest, since it can cause
> oom and kill some test process. Maybe we should have such stresstest
> framework (which allows test to crash kernel)

The point of the test is to make sure that it doesn't kill
everything :-)  The ring buffer code is suppose to detect that it will
cause an OOM, and if it does that's considered a failure.

Just like any other test, if it fails, it can crash the kernel. But the
ring buffer code is suppose to be able to keep the kernel from crashing
(including triggering OOM) if the buffer size is stressed.

Maybe I'll port that over today :-/


-- Steve
Masami Hiramatsu (Google) Aug. 30, 2018, 11:35 p.m. UTC | #4
On Thu, 30 Aug 2018 11:50:55 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:

> On Thu, 30 Aug 2018 16:12:18 +0900
> Masami Hiramatsu <mhiramat@kernel.org> wrote:
> 
> > > I'm fine with this, but one day I need to port over some of my other
> > > tests. I have a test that stresses the ring buffer size (basically
> > > checks to see if it can cause an oom). I need to port that to
> > > selftests. But for now...  
> > 
> > Hmm, such stress test is not good for kselftest, since it can cause
> > oom and kill some test process. Maybe we should have such stresstest
> > framework (which allows test to crash kernel)
> 
> The point of the test is to make sure that it doesn't kill
> everything :-)  The ring buffer code is suppose to detect that it will
> cause an OOM, and if it does that's considered a failure.

Ah, OK, so the test itself must not cause OOM. That's reasonable. :)

> 
> Just like any other test, if it fails, it can crash the kernel. But the
> ring buffer code is suppose to be able to keep the kernel from crashing
> (including triggering OOM) if the buffer size is stressed.
> 
> Maybe I'll port that over today :-/

Looking forward it!

Thank you,

> 
> 
> -- Steve
Steven Rostedt Aug. 30, 2018, 11:40 p.m. UTC | #5
On Fri, 31 Aug 2018 08:35:28 +0900
Masami Hiramatsu <mhiramat@kernel.org> wrote:

> On Thu, 30 Aug 2018 11:50:55 -0400
> Steven Rostedt <rostedt@goodmis.org> wrote:
> 
> > On Thu, 30 Aug 2018 16:12:18 +0900
> > Masami Hiramatsu <mhiramat@kernel.org> wrote:
> >   
> > > > I'm fine with this, but one day I need to port over some of my other
> > > > tests. I have a test that stresses the ring buffer size (basically
> > > > checks to see if it can cause an oom). I need to port that to
> > > > selftests. But for now...    
> > > 
> > > Hmm, such stress test is not good for kselftest, since it can cause
> > > oom and kill some test process. Maybe we should have such stresstest
> > > framework (which allows test to crash kernel)  
> > 
> > The point of the test is to make sure that it doesn't kill
> > everything :-)  The ring buffer code is suppose to detect that it will
> > cause an OOM, and if it does that's considered a failure.  
> 
> Ah, OK, so the test itself must not cause OOM. That's reasonable. :)
> 
> > 
> > Just like any other test, if it fails, it can crash the kernel. But the
> > ring buffer code is suppose to be able to keep the kernel from crashing
> > (including triggering OOM) if the buffer size is stressed.
> > 
> > Maybe I'll port that over today :-/  
> 
> Looking forward it!
> 

Unfortunately, I didn't get to it, and will be on PTO for the next 4
days. Perhaps next week.

-- Steve
diff mbox series

Patch

diff --git a/tools/testing/selftests/ftrace/test.d/00basic/ringbuffer_size.tc b/tools/testing/selftests/ftrace/test.d/00basic/ringbuffer_size.tc
new file mode 100644
index 000000000000..9224f33b3194
--- /dev/null
+++ b/tools/testing/selftests/ftrace/test.d/00basic/ringbuffer_size.tc
@@ -0,0 +1,21 @@ 
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+# description: Change the ringbuffer size
+
+rb_size_test() {
+ORIG=`cat buffer_size_kb`
+
+expr $ORIG / 2 > buffer_size_kb
+
+expr $ORIG \* 2 > buffer_size_kb
+
+echo $ORIG > buffer_size_kb
+}
+
+rb_size_test
+
+: "If per-cpu buffer is supported, imbalance it"
+if [ -d per_cpu/cpu0 ]; then
+  cd per_cpu/cpu0
+  rb_size_test
+fi