* [PATCH 0/2] Tests for preempt/irq disabled sections @ 2018-07-11 6:35 Joel Fernandes 2018-07-11 6:35 ` [PATCH 1/2] lib: Add module for testing preemptoff/irqsoff latency tracers Joel Fernandes 2018-07-11 6:35 ` [PATCH 2/2] kselftests: Add tests for the preemptoff and irqsoff tracers Joel Fernandes 0 siblings, 2 replies; 7+ messages in thread From: Joel Fernandes @ 2018-07-11 6:35 UTC (permalink / raw) To: linux-kernel Cc: kernel-team, Joel Fernandes (Google), Boqun Feng, Byungchul Park, Erick Reyes, Ingo Molnar, Julia Cartwright, linux-kselftest, Masami Hiramatsu, Mathieu Desnoyers, Namhyung Kim, Paul McKenney, Peter Zijlstra, Shuah Khan, Steven Rostedt, Thomas Glexiner, Todd Kjos, Tom Zanussi From: "Joel Fernandes (Google)" <joel@joelfernandes.org> Only resending the test module and kselftest patches with minor changes as suggested by Steve. Previous posting of the series is at: https://lkml.org/lkml/2018/6/7/1162 Joel Fernandes (Google) (2): lib: Add module for testing preemptoff/irqsoff latency tracers kselftests: Add tests for the preemptoff and irqsoff tracers kernel/trace/Kconfig | 15 ++++ kernel/trace/Makefile | 1 + kernel/trace/preemptirq_delay_test.c | 72 ++++++++++++++++++ tools/testing/selftests/ftrace/config | 3 + .../test.d/preemptirq/irqsoff_tracer.tc | 73 +++++++++++++++++++ 5 files changed, 164 insertions(+) create mode 100644 kernel/trace/preemptirq_delay_test.c create mode 100644 tools/testing/selftests/ftrace/test.d/preemptirq/irqsoff_tracer.tc -- 2.18.0.203.gfac676dfb9-goog unction incase tracepoints aren't enabled, did that. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/2] lib: Add module for testing preemptoff/irqsoff latency tracers 2018-07-11 6:35 [PATCH 0/2] Tests for preempt/irq disabled sections Joel Fernandes @ 2018-07-11 6:35 ` Joel Fernandes 2018-07-12 21:22 ` Steven Rostedt 2018-07-11 6:35 ` [PATCH 2/2] kselftests: Add tests for the preemptoff and irqsoff tracers Joel Fernandes 1 sibling, 1 reply; 7+ messages in thread From: Joel Fernandes @ 2018-07-11 6:35 UTC (permalink / raw) To: linux-kernel Cc: kernel-team, Joel Fernandes (Google), Andy Shevchenko, Boqun Feng, Byungchul Park, Erick Reyes, Ingo Molnar, Julia Cartwright, linux-kselftest, Masami Hiramatsu, Mathieu Desnoyers, Namhyung Kim, Paul McKenney, Peter Zijlstra, Shuah Khan, Steven Rostedt, Thomas Glexiner, Todd Kjos, Tom Zanussi From: "Joel Fernandes (Google)" <joel@joelfernandes.org> Here we introduce a test module for introducing a long preempt or irq disable delay in the kernel which the preemptoff or irqsoff tracers can detect. This module is to be used only for test purposes and is default disabled. Following is the expected output (only briefly shown) that can be parsed to verify that the tracers are working correctly. We will use this from the kselftests in future patches. For the preemptoff tracer: echo preemptoff > /d/tracing/current_tracer sleep 1 insmod ./preemptirq_delay_test.ko test_mode=preempt delay=500000 sleep 1 bash-4.3# cat /d/tracing/trace preempt -1066 2...2 0us@: preemptirq_delay_run <-preemptirq_delay_run preempt -1066 2...2 500002us : preemptirq_delay_run <-preemptirq_delay_run preempt -1066 2...2 500004us : tracer_preempt_on <-preemptirq_delay_run preempt -1066 2...2 500012us : <stack trace> => kthread => ret_from_fork For the irqsoff tracer: echo irqsoff > /d/tracing/current_tracer sleep 1 insmod ./preemptirq_delay_test.ko test_mode=irq delay=500000 sleep 1 bash-4.3# cat /d/tracing/trace irq dis -1069 1d..1 0us@: preemptirq_delay_run irq dis -1069 1d..1 500001us : preemptirq_delay_run irq dis -1069 1d..1 500002us : tracer_hardirqs_on <-preemptirq_delay_run irq dis -1069 1d..1 500005us : <stack trace> => ret_from_fork Co-developed-by: Erick Reyes <erickreyes@google.com> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org> --- kernel/trace/Kconfig | 15 ++++++ kernel/trace/Makefile | 1 + kernel/trace/preemptirq_delay_test.c | 72 ++++++++++++++++++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 kernel/trace/preemptirq_delay_test.c diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig index 8d51351e3149..eb5ab6b511e2 100644 --- a/kernel/trace/Kconfig +++ b/kernel/trace/Kconfig @@ -699,6 +699,21 @@ config RING_BUFFER_STARTUP_TEST If unsure, say N +config PREEMPTIRQ_DELAY_TEST + tristate "Preempt / IRQ disable delay thread to test latency tracers" + depends on m + help + Select this option to build a test module that can help test latency + tracers by executing a preempt or irq disable section with a user + configurable delay. The module busy waits for the duration of the + critical section. + + For example, the following invocation forces a one-time irq-disabled + critical section for 500us: + modprobe preemptirq_delay_test test_mode=irq delay=500000 + + If unsure, say N + config TRACE_EVAL_MAP_FILE bool "Show eval mappings for trace events" depends on TRACING diff --git a/kernel/trace/Makefile b/kernel/trace/Makefile index 84a0cb222f20..677540bb1b62 100644 --- a/kernel/trace/Makefile +++ b/kernel/trace/Makefile @@ -36,6 +36,7 @@ obj-$(CONFIG_TRACING_MAP) += tracing_map.o obj-$(CONFIG_CONTEXT_SWITCH_TRACER) += trace_sched_switch.o obj-$(CONFIG_FUNCTION_TRACER) += trace_functions.o obj-$(CONFIG_PREEMPTIRQ_TRACEPOINTS) += trace_preemptirq.o +obj-$(CONFIG_PREEMPTIRQ_DELAY_TEST) += preemptirq_delay_test.o obj-$(CONFIG_IRQSOFF_TRACER) += trace_irqsoff.o obj-$(CONFIG_PREEMPT_TRACER) += trace_irqsoff.o obj-$(CONFIG_SCHED_TRACER) += trace_sched_wakeup.o diff --git a/kernel/trace/preemptirq_delay_test.c b/kernel/trace/preemptirq_delay_test.c new file mode 100644 index 000000000000..c97a026c0720 --- /dev/null +++ b/kernel/trace/preemptirq_delay_test.c @@ -0,0 +1,72 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Preempt / IRQ disable delay thread to test latency tracers + * + * Copyright (C) 2018 Joel Fernandes (Google) <joel@joelfernandes.org> + */ + +#include <linux/delay.h> +#include <linux/interrupt.h> +#include <linux/irq.h> +#include <linux/kernel.h> +#include <linux/kthread.h> +#include <linux/ktime.h> +#include <linux/module.h> +#include <linux/printk.h> +#include <linux/string.h> + +static ulong delay = 100; +static char test_mode[10] = "irq"; + +module_param_named(delay, delay, ulong, S_IRUGO); +module_param_string(test_mode, test_mode, 10, S_IRUGO); +MODULE_PARM_DESC(delay, "Period in microseconds (100 uS default)"); +MODULE_PARM_DESC(test_mode, "Mode of the test such as preempt or irq (default irq)"); + +static void busy_wait(ulong time) +{ + ktime_t start, end; + start = ktime_get(); + do { + end = ktime_get(); + if (kthread_should_stop()) + break; + } while (ktime_to_ns(ktime_sub(end, start)) < (time * 1000)); +} + +int preemptirq_delay_run(void *data) +{ + unsigned long flags; + + if (!strcmp(test_mode, "irq")) { + local_irq_save(flags); + busy_wait(delay); + local_irq_restore(flags); + } else if (!strcmp(test_mode, "preempt")) { + preempt_disable(); + busy_wait(delay); + preempt_enable(); + } + + return 0; +} + +static int __init preemptirq_delay_init(void) +{ + char task_name[50]; + struct task_struct *test_task; + + snprintf(task_name, sizeof(task_name), "%s_test", test_mode); + + test_task = kthread_run(preemptirq_delay_run, NULL, task_name); + return PTR_ERR_OR_ZERO(test_task); +} + +static void __exit preemptirq_delay_exit(void) +{ + return; +} + +module_init(preemptirq_delay_init) +module_exit(preemptirq_delay_exit) +MODULE_LICENSE("GPL v2"); -- 2.18.0.203.gfac676dfb9-goog ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] lib: Add module for testing preemptoff/irqsoff latency tracers 2018-07-11 6:35 ` [PATCH 1/2] lib: Add module for testing preemptoff/irqsoff latency tracers Joel Fernandes @ 2018-07-12 21:22 ` Steven Rostedt 2018-07-12 21:36 ` Joel Fernandes 0 siblings, 1 reply; 7+ messages in thread From: Steven Rostedt @ 2018-07-12 21:22 UTC (permalink / raw) To: Joel Fernandes Cc: linux-kernel, kernel-team, Andy Shevchenko, Boqun Feng, Byungchul Park, Erick Reyes, Ingo Molnar, Julia Cartwright, linux-kselftest, Masami Hiramatsu, Mathieu Desnoyers, Namhyung Kim, Paul McKenney, Peter Zijlstra, Shuah Khan, Thomas Glexiner, Todd Kjos, Tom Zanussi On Tue, 10 Jul 2018 23:35:39 -0700 Joel Fernandes <joel@joelfernandes.org> wrote: > > Co-developed-by: Erick Reyes <erickreyes@google.com> A co-developer needs to add their signed off by. To specify that Erick is a co-author, you could do: [ Erick is a co-developer of this commit ] Signed-off-by: Add Erick's SOB here. > Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org> > --- > kernel/trace/Kconfig | 15 ++++++ > kernel/trace/Makefile | 1 + > kernel/trace/preemptirq_delay_test.c | 72 ++++++++++++++++++++++++++++ > 3 files changed, 88 insertions(+) > create mode 100644 kernel/trace/preemptirq_delay_test.c > > diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig > index 8d51351e3149..eb5ab6b511e2 100644 > --- a/kernel/trace/Kconfig > +++ b/kernel/trace/Kconfig > @@ -699,6 +699,21 @@ config RING_BUFFER_STARTUP_TEST > > If unsure, say N > > +config PREEMPTIRQ_DELAY_TEST > + tristate "Preempt / IRQ disable delay thread to test latency tracers" > + depends on m > + help > + Select this option to build a test module that can help test latency > + tracers by executing a preempt or irq disable section with a user > + configurable delay. The module busy waits for the duration of the > + critical section. > + > + For example, the following invocation forces a one-time irq-disabled > + critical section for 500us: > + modprobe preemptirq_delay_test test_mode=irq delay=500000 > + > + If unsure, say N > + > config TRACE_EVAL_MAP_FILE > bool "Show eval mappings for trace events" > depends on TRACING > diff --git a/kernel/trace/Makefile b/kernel/trace/Makefile > index 84a0cb222f20..677540bb1b62 100644 > --- a/kernel/trace/Makefile > +++ b/kernel/trace/Makefile > @@ -36,6 +36,7 @@ obj-$(CONFIG_TRACING_MAP) += tracing_map.o > obj-$(CONFIG_CONTEXT_SWITCH_TRACER) += trace_sched_switch.o > obj-$(CONFIG_FUNCTION_TRACER) += trace_functions.o > obj-$(CONFIG_PREEMPTIRQ_TRACEPOINTS) += trace_preemptirq.o > +obj-$(CONFIG_PREEMPTIRQ_DELAY_TEST) += preemptirq_delay_test.o > obj-$(CONFIG_IRQSOFF_TRACER) += trace_irqsoff.o > obj-$(CONFIG_PREEMPT_TRACER) += trace_irqsoff.o > obj-$(CONFIG_SCHED_TRACER) += trace_sched_wakeup.o > diff --git a/kernel/trace/preemptirq_delay_test.c b/kernel/trace/preemptirq_delay_test.c > new file mode 100644 > index 000000000000..c97a026c0720 > --- /dev/null > +++ b/kernel/trace/preemptirq_delay_test.c > @@ -0,0 +1,72 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Preempt / IRQ disable delay thread to test latency tracers > + * > + * Copyright (C) 2018 Joel Fernandes (Google) <joel@joelfernandes.org> > + */ > + > +#include <linux/delay.h> > +#include <linux/interrupt.h> > +#include <linux/irq.h> > +#include <linux/kernel.h> > +#include <linux/kthread.h> > +#include <linux/ktime.h> > +#include <linux/module.h> > +#include <linux/printk.h> > +#include <linux/string.h> > + > +static ulong delay = 100; > +static char test_mode[10] = "irq"; > + > +module_param_named(delay, delay, ulong, S_IRUGO); > +module_param_string(test_mode, test_mode, 10, S_IRUGO); > +MODULE_PARM_DESC(delay, "Period in microseconds (100 uS default)"); > +MODULE_PARM_DESC(test_mode, "Mode of the test such as preempt or irq (default irq)"); > + > +static void busy_wait(ulong time) > +{ > + ktime_t start, end; > + start = ktime_get(); > + do { > + end = ktime_get(); > + if (kthread_should_stop()) > + break; > + } while (ktime_to_ns(ktime_sub(end, start)) < (time * 1000)); > +} > + > +int preemptirq_delay_run(void *data) > +{ > + unsigned long flags; > + > + if (!strcmp(test_mode, "irq")) { > + local_irq_save(flags); > + busy_wait(delay); > + local_irq_restore(flags); > + } else if (!strcmp(test_mode, "preempt")) { > + preempt_disable(); > + busy_wait(delay); > + preempt_enable(); > + } > + > + return 0; > +} > + > +static int __init preemptirq_delay_init(void) > +{ > + char task_name[50]; > + struct task_struct *test_task; > + > + snprintf(task_name, sizeof(task_name), "%s_test", test_mode); > + > + test_task = kthread_run(preemptirq_delay_run, NULL, task_name); > + return PTR_ERR_OR_ZERO(test_task); > +} > + > +static void __exit preemptirq_delay_exit(void) > +{ > + return; > +} > + > +module_init(preemptirq_delay_init) > +module_exit(preemptirq_delay_exit) > +MODULE_LICENSE("GPL v2"); ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] lib: Add module for testing preemptoff/irqsoff latency tracers 2018-07-12 21:22 ` Steven Rostedt @ 2018-07-12 21:36 ` Joel Fernandes 2018-07-12 23:02 ` Steven Rostedt 0 siblings, 1 reply; 7+ messages in thread From: Joel Fernandes @ 2018-07-12 21:36 UTC (permalink / raw) To: Steven Rostedt Cc: linux-kernel, kernel-team, Andy Shevchenko, Boqun Feng, Byungchul Park, Erick Reyes, Ingo Molnar, Julia Cartwright, linux-kselftest, Masami Hiramatsu, Mathieu Desnoyers, Namhyung Kim, Paul McKenney, Peter Zijlstra, Shuah Khan, Thomas Glexiner, Todd Kjos, Tom Zanussi On Thu, Jul 12, 2018 at 05:22:32PM -0400, Steven Rostedt wrote: > On Tue, 10 Jul 2018 23:35:39 -0700 > Joel Fernandes <joel@joelfernandes.org> wrote: > > > > > Co-developed-by: Erick Reyes <erickreyes@google.com> > > A co-developer needs to add their signed off by. To specify that Erick > is a co-author, you could do: > > [ Erick is a co-developer of this commit ] > Signed-off-by: Add Erick's SOB here. Sure, I added this below. Hope its easy for you to apply, if not let me know and I can send it again separately. thanks. ------------>8---------------- From: "Joel Fernandes (Google)" <joel@joelfernandes.org> Subject: [PATCH 1/2] lib: Add module for testing preemptoff/irqsoff latency tracers Here we introduce a test module for introducing a long preempt or irq disable delay in the kernel which the preemptoff or irqsoff tracers can detect. This module is to be used only for test purposes and is default disabled. Following is the expected output (only briefly shown) that can be parsed to verify that the tracers are working correctly. We will use this from the kselftests in future patches. For the preemptoff tracer: echo preemptoff > /d/tracing/current_tracer sleep 1 insmod ./preemptirq_delay_test.ko test_mode=preempt delay=500000 sleep 1 bash-4.3# cat /d/tracing/trace preempt -1066 2...2 0us@: preemptirq_delay_run <-preemptirq_delay_run preempt -1066 2...2 500002us : preemptirq_delay_run <-preemptirq_delay_run preempt -1066 2...2 500004us : tracer_preempt_on <-preemptirq_delay_run preempt -1066 2...2 500012us : <stack trace> => kthread => ret_from_fork For the irqsoff tracer: echo irqsoff > /d/tracing/current_tracer sleep 1 insmod ./preemptirq_delay_test.ko test_mode=irq delay=500000 sleep 1 bash-4.3# cat /d/tracing/trace irq dis -1069 1d..1 0us@: preemptirq_delay_run irq dis -1069 1d..1 500001us : preemptirq_delay_run irq dis -1069 1d..1 500002us : tracer_hardirqs_on <-preemptirq_delay_run irq dis -1069 1d..1 500005us : <stack trace> => ret_from_fork Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> [ Erick is a co-developer of this commit ] Signed-off-by: Erick Reyes <erickreyes@google.com> Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org> --- kernel/trace/Kconfig | 15 ++++++ kernel/trace/Makefile | 1 + kernel/trace/preemptirq_delay_test.c | 72 ++++++++++++++++++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 kernel/trace/preemptirq_delay_test.c diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig index 8d51351e3149..eb5ab6b511e2 100644 --- a/kernel/trace/Kconfig +++ b/kernel/trace/Kconfig @@ -699,6 +699,21 @@ config RING_BUFFER_STARTUP_TEST If unsure, say N +config PREEMPTIRQ_DELAY_TEST + tristate "Preempt / IRQ disable delay thread to test latency tracers" + depends on m + help + Select this option to build a test module that can help test latency + tracers by executing a preempt or irq disable section with a user + configurable delay. The module busy waits for the duration of the + critical section. + + For example, the following invocation forces a one-time irq-disabled + critical section for 500us: + modprobe preemptirq_delay_test test_mode=irq delay=500000 + + If unsure, say N + config TRACE_EVAL_MAP_FILE bool "Show eval mappings for trace events" depends on TRACING diff --git a/kernel/trace/Makefile b/kernel/trace/Makefile index 84a0cb222f20..677540bb1b62 100644 --- a/kernel/trace/Makefile +++ b/kernel/trace/Makefile @@ -36,6 +36,7 @@ obj-$(CONFIG_TRACING_MAP) += tracing_map.o obj-$(CONFIG_CONTEXT_SWITCH_TRACER) += trace_sched_switch.o obj-$(CONFIG_FUNCTION_TRACER) += trace_functions.o obj-$(CONFIG_PREEMPTIRQ_TRACEPOINTS) += trace_preemptirq.o +obj-$(CONFIG_PREEMPTIRQ_DELAY_TEST) += preemptirq_delay_test.o obj-$(CONFIG_IRQSOFF_TRACER) += trace_irqsoff.o obj-$(CONFIG_PREEMPT_TRACER) += trace_irqsoff.o obj-$(CONFIG_SCHED_TRACER) += trace_sched_wakeup.o diff --git a/kernel/trace/preemptirq_delay_test.c b/kernel/trace/preemptirq_delay_test.c new file mode 100644 index 000000000000..c97a026c0720 --- /dev/null +++ b/kernel/trace/preemptirq_delay_test.c @@ -0,0 +1,72 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Preempt / IRQ disable delay thread to test latency tracers + * + * Copyright (C) 2018 Joel Fernandes (Google) <joel@joelfernandes.org> + */ + +#include <linux/delay.h> +#include <linux/interrupt.h> +#include <linux/irq.h> +#include <linux/kernel.h> +#include <linux/kthread.h> +#include <linux/ktime.h> +#include <linux/module.h> +#include <linux/printk.h> +#include <linux/string.h> + +static ulong delay = 100; +static char test_mode[10] = "irq"; + +module_param_named(delay, delay, ulong, S_IRUGO); +module_param_string(test_mode, test_mode, 10, S_IRUGO); +MODULE_PARM_DESC(delay, "Period in microseconds (100 uS default)"); +MODULE_PARM_DESC(test_mode, "Mode of the test such as preempt or irq (default irq)"); + +static void busy_wait(ulong time) +{ + ktime_t start, end; + start = ktime_get(); + do { + end = ktime_get(); + if (kthread_should_stop()) + break; + } while (ktime_to_ns(ktime_sub(end, start)) < (time * 1000)); +} + +int preemptirq_delay_run(void *data) +{ + unsigned long flags; + + if (!strcmp(test_mode, "irq")) { + local_irq_save(flags); + busy_wait(delay); + local_irq_restore(flags); + } else if (!strcmp(test_mode, "preempt")) { + preempt_disable(); + busy_wait(delay); + preempt_enable(); + } + + return 0; +} + +static int __init preemptirq_delay_init(void) +{ + char task_name[50]; + struct task_struct *test_task; + + snprintf(task_name, sizeof(task_name), "%s_test", test_mode); + + test_task = kthread_run(preemptirq_delay_run, NULL, task_name); + return PTR_ERR_OR_ZERO(test_task); +} + +static void __exit preemptirq_delay_exit(void) +{ + return; +} + +module_init(preemptirq_delay_init) +module_exit(preemptirq_delay_exit) +MODULE_LICENSE("GPL v2"); -- 2.18.0.203.gfac676dfb9-goog ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] lib: Add module for testing preemptoff/irqsoff latency tracers 2018-07-12 21:36 ` Joel Fernandes @ 2018-07-12 23:02 ` Steven Rostedt 0 siblings, 0 replies; 7+ messages in thread From: Steven Rostedt @ 2018-07-12 23:02 UTC (permalink / raw) To: Joel Fernandes Cc: linux-kernel, kernel-team, Andy Shevchenko, Boqun Feng, Byungchul Park, Erick Reyes, Ingo Molnar, Julia Cartwright, linux-kselftest, Masami Hiramatsu, Mathieu Desnoyers, Namhyung Kim, Paul McKenney, Peter Zijlstra, Shuah Khan, Thomas Glexiner, Todd Kjos, Tom Zanussi On Thu, 12 Jul 2018 14:36:11 -0700 Joel Fernandes <joel@joelfernandes.org> wrote: > Sure, I added this below. Hope its easy for you to apply, if not let me know > and I can send it again separately. thanks. Thanks, I added this in my queue. -- Steve ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/2] kselftests: Add tests for the preemptoff and irqsoff tracers 2018-07-11 6:35 [PATCH 0/2] Tests for preempt/irq disabled sections Joel Fernandes 2018-07-11 6:35 ` [PATCH 1/2] lib: Add module for testing preemptoff/irqsoff latency tracers Joel Fernandes @ 2018-07-11 6:35 ` Joel Fernandes 2018-07-12 23:04 ` Steven Rostedt 1 sibling, 1 reply; 7+ messages in thread From: Joel Fernandes @ 2018-07-11 6:35 UTC (permalink / raw) To: linux-kernel Cc: kernel-team, Joel Fernandes (Google), Boqun Feng, Byungchul Park, Erick Reyes, Ingo Molnar, Julia Cartwright, linux-kselftest, Masami Hiramatsu, Mathieu Desnoyers, Namhyung Kim, Paul McKenney, Peter Zijlstra, Shuah Khan, Steven Rostedt, Thomas Glexiner, Todd Kjos, Tom Zanussi From: "Joel Fernandes (Google)" <joel@joelfernandes.org> Here we add unit tests for the preemptoff and irqsoff tracer by using a kernel module introduced previously to trigger long preempt or irq disabled sections in the kernel. Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org> Acked-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org> --- tools/testing/selftests/ftrace/config | 3 + .../test.d/preemptirq/irqsoff_tracer.tc | 73 +++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/preemptirq/irqsoff_tracer.tc diff --git a/tools/testing/selftests/ftrace/config b/tools/testing/selftests/ftrace/config index b01924c71c09..07db5ab09cc7 100644 --- a/tools/testing/selftests/ftrace/config +++ b/tools/testing/selftests/ftrace/config @@ -4,3 +4,6 @@ CONFIG_FUNCTION_PROFILER=y CONFIG_TRACER_SNAPSHOT=y CONFIG_STACK_TRACER=y CONFIG_HIST_TRIGGERS=y +CONFIG_PREEMPT_TRACER=y +CONFIG_IRQSOFF_TRACER=y +CONFIG_PREEMPTIRQ_DELAY_TEST=m diff --git a/tools/testing/selftests/ftrace/test.d/preemptirq/irqsoff_tracer.tc b/tools/testing/selftests/ftrace/test.d/preemptirq/irqsoff_tracer.tc new file mode 100644 index 000000000000..cbd174334a48 --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/preemptirq/irqsoff_tracer.tc @@ -0,0 +1,73 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: test for the preemptirqsoff tracer + +MOD=preemptirq_delay_test + +fail() { + reset_tracer + rmmod $MOD || true + exit_fail +} + +unsup() { #msg + reset_tracer + rmmod $MOD || true + echo $1 + exit_unsupported +} + +modprobe $MOD || unsup "$MOD module not available" +rmmod $MOD + +grep -q "preemptoff" available_tracers || unsup "preemptoff tracer not enabled" +grep -q "irqsoff" available_tracers || unsup "irqsoff tracer not enabled" + +reset_tracer + +# Simulate preemptoff section for half a second couple of times +echo preemptoff > current_tracer +sleep 1 +modprobe $MOD test_mode=preempt delay=500000 || fail +rmmod $MOD || fail +modprobe $MOD test_mode=preempt delay=500000 || fail +rmmod $MOD || fail +modprobe $MOD test_mode=preempt delay=500000 || fail +rmmod $MOD || fail + +cat trace + +# Confirm which tracer +grep -q "tracer: preemptoff" trace || fail + +# Check the end of the section +egrep -q "5.....us : <stack trace>" trace || fail + +# Check for 500ms of latency +egrep -q "latency: 5..... us" trace || fail + +reset_tracer + +# Simulate irqsoff section for half a second couple of times +echo irqsoff > current_tracer +sleep 1 +modprobe $MOD test_mode=irq delay=500000 || fail +rmmod $MOD || fail +modprobe $MOD test_mode=irq delay=500000 || fail +rmmod $MOD || fail +modprobe $MOD test_mode=irq delay=500000 || fail +rmmod $MOD || fail + +cat trace + +# Confirm which tracer +grep -q "tracer: irqsoff" trace || fail + +# Check the end of the section +egrep -q "5.....us : <stack trace>" trace || fail + +# Check for 500ms of latency +egrep -q "latency: 5..... us" trace || fail + +reset_tracer +exit 0 -- 2.18.0.203.gfac676dfb9-goog ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] kselftests: Add tests for the preemptoff and irqsoff tracers 2018-07-11 6:35 ` [PATCH 2/2] kselftests: Add tests for the preemptoff and irqsoff tracers Joel Fernandes @ 2018-07-12 23:04 ` Steven Rostedt 0 siblings, 0 replies; 7+ messages in thread From: Steven Rostedt @ 2018-07-12 23:04 UTC (permalink / raw) To: Joel Fernandes Cc: linux-kernel, kernel-team, Boqun Feng, Byungchul Park, Erick Reyes, Ingo Molnar, Julia Cartwright, linux-kselftest, Masami Hiramatsu, Mathieu Desnoyers, Namhyung Kim, Paul McKenney, Peter Zijlstra, Shuah Khan, Thomas Glexiner, Todd Kjos, Tom Zanussi On Tue, 10 Jul 2018 23:35:40 -0700 Joel Fernandes <joel@joelfernandes.org> wrote: > From: "Joel Fernandes (Google)" <joel@joelfernandes.org> > > Here we add unit tests for the preemptoff and irqsoff tracer by using a > kernel module introduced previously to trigger long preempt or irq > disabled sections in the kernel. > > Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org> > Acked-by: Masami Hiramatsu <mhiramat@kernel.org> > Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org> > --- > I added this to my queue too. If you are curious to see what's currently in my queue, I just pushed my queue to my tree: git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git ftrace/core Beware, that branch can and will rebase often. -- Steve ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2018-07-12 23:04 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2018-07-11 6:35 [PATCH 0/2] Tests for preempt/irq disabled sections Joel Fernandes 2018-07-11 6:35 ` [PATCH 1/2] lib: Add module for testing preemptoff/irqsoff latency tracers Joel Fernandes 2018-07-12 21:22 ` Steven Rostedt 2018-07-12 21:36 ` Joel Fernandes 2018-07-12 23:02 ` Steven Rostedt 2018-07-11 6:35 ` [PATCH 2/2] kselftests: Add tests for the preemptoff and irqsoff tracers Joel Fernandes 2018-07-12 23:04 ` Steven Rostedt
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®