login
Login
/
Register
Search
Search this site:
Forums
News
Blogs
Features
Site
Home
»
Mailing list archives
»
linux-kernel
»
2009
»
April
»
16
Re: [PATCH 2/5] tracing/events: add startup tests for events
view
thread
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
[view in full thread]
From: Frederic Weisbecker
Subject:
Re: [PATCH 2/5] tracing/events: add startup tests for events
Date: Thursday, April 16, 2009 - 9:02 am
On Wed, Apr 15, 2009 at 10:18:32PM -0400, Steven Rostedt wrote:
quoted text
> From: Steven Rostedt <srostedt@redhat.com> > > As events start to become popular, and the new way to add tracing > infrastructure into ftrace, it is important to catch any problems > that might happen with a mistake in the TRACE_EVENT macro. > > This patch introduces a startup self test on the registered trace > events. Note, it can only do a generic test, any type of testing that > needs more involement is needed to be implemented by the tracepoint > creators. > > The test goes down one by one enabling a trace point and running > some random tasks (random in the sense that I just made them up). > Those tasks are creating threads, grabbing mutexes and spinlocks > and using workqueues. > > After testing each event individually, it does the same test after > enabling each system of trace points. Like sched, irq, lockdep. > > Then finally it enables all tracepoints and performs the tasks again. > The output to the console on bootup will look like this when everything > works: > > Running tests on trace events: > Testing event kfree_skb: OK > Testing event kmalloc: OK > Testing event kmem_cache_alloc: OK > Testing event kmalloc_node: OK > Testing event kmem_cache_alloc_node: OK > Testing event kfree: OK > Testing event kmem_cache_free: OK > Testing event irq_handler_exit: OK > Testing event irq_handler_entry: OK > Testing event softirq_entry: OK > Testing event softirq_exit: OK > Testing event lock_acquire: OK > Testing event lock_release: OK > Testing event sched_kthread_stop: OK > Testing event sched_kthread_stop_ret: OK > Testing event sched_wait_task: OK > Testing event sched_wakeup: OK > Testing event sched_wakeup_new: OK > Testing event sched_switch: OK > Testing event sched_migrate_task: OK > Testing event sched_process_free: OK > Testing event sched_process_exit: OK > Testing event sched_process_wait: OK > Testing event sched_process_fork: OK > Testing event sched_signal_send: OK > Running tests on trace event systems: > Testing event system skb: OK > Testing event system kmem: OK > Testing event system irq: OK > Testing event system lockdep: OK > Testing event system sched: OK > Running tests on all trace events: > Testing all events: OK
Wow, that's very nice. I'm just adding kernel-testers in Cc, they might be interested. Frederic.
quoted text
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org> > --- > kernel/trace/trace_events.c | 176 +++++++++++++++++++++++++++++++++++++++++++ > 1 files changed, 176 insertions(+), 0 deletions(-) > > diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c > index 6591d83..6d5b1bd 100644 > --- a/kernel/trace/trace_events.c > +++ b/kernel/trace/trace_events.c > @@ -8,6 +8,9 @@ > * > */ > > +#include <linux/workqueue.h> > +#include <linux/spinlock.h> > +#include <linux/kthread.h> > #include <linux/debugfs.h> > #include <linux/uaccess.h> > #include <linux/module.h> > @@ -920,3 +923,176 @@ static __init int event_trace_init(void) > return 0; > } > fs_initcall(event_trace_init); > + > +#ifdef CONFIG_FTRACE_STARTUP_TEST > + > +static DEFINE_SPINLOCK(test_spinlock); > +static DEFINE_SPINLOCK(test_spinlock_irq); > +static DEFINE_MUTEX(test_mutex); > + > +static __init void test_work(struct work_struct *dummy) > +{ > + spin_lock(&test_spinlock); > + spin_lock_irq(&test_spinlock_irq); > + udelay(1); > + spin_unlock_irq(&test_spinlock_irq); > + spin_unlock(&test_spinlock); > + > + mutex_lock(&test_mutex); > + msleep(1); > + mutex_unlock(&test_mutex); > +} > + > +static __init int event_test_thread(void *unused) > +{ > + void *test_malloc; > + > + test_malloc = kmalloc(1234, GFP_KERNEL); > + if (!test_malloc) > + pr_info("failed to kmalloc\n"); > + > + schedule_on_each_cpu(test_work); > + > + kfree(test_malloc); > + > + while (!kthread_should_stop()) > + ; > + > + return 0; > +} > + > +/* > + * Do various things that may trigger events. > + */ > +static __init void event_test_stuff(void) > +{ > + struct task_struct *test_thread; > + > + test_thread = kthread_run(event_test_thread, NULL, "test-events"); > + msleep(1); > + kthread_stop(test_thread); > +} > + > +/* > + * For every trace event defined, we will test each trace point separately, > + * and then by groups, and finally all trace points. > + */ > +static __init int event_trace_self_tests(void) > +{ > + struct ftrace_event_call *call; > + struct event_subsystem *system; > + char *sysname; > + int ret; > + > + pr_info("Running tests on trace events:\n"); > + > + list_for_each_entry(call, &ftrace_events, list) { > + > + /* Only test those that have a regfunc */ > + if (!call->regfunc) > + continue; > + > + pr_info("Testing event %s: ", call->name); > + > + /* > + * If an event is already enabled, someone is using > + * it and the self test should not be on. > + */ > + if (call->enabled) { > + pr_warning("Enabled event during self test!\n"); > + WARN_ON_ONCE(1); > + continue; > + } > + > + call->enabled = 1; > + call->regfunc(); > + > + event_test_stuff(); > + > + call->unregfunc(); > + call->enabled = 0; > + > + pr_cont("OK\n"); > + } > + > + /* Now test at the sub system level */ > + > + pr_info("Running tests on trace event systems:\n"); > + > + list_for_each_entry(system, &event_subsystems, list) { > + > + /* the ftrace system is special, skip it */ > + if (strcmp(system->name, "ftrace") == 0) > + continue; > + > + pr_info("Testing event system %s: ", system->name); > + > + /* ftrace_set_clr_event can modify the name passed in. */ > + sysname = kstrdup(system->name, GFP_KERNEL); > + if (WARN_ON(!sysname)) { > + pr_warning("Can't allocate memory, giving up!\n"); > + return 0; > + } > + ret = ftrace_set_clr_event(sysname, 1); > + kfree(sysname); > + if (WARN_ON_ONCE(ret)) { > + pr_warning("error enabling system %s\n", > + system->name); > + continue; > + } > + > + event_test_stuff(); > + > + sysname = kstrdup(system->name, GFP_KERNEL); > + if (WARN_ON(!sysname)) { > + pr_warning("Can't allocate memory, giving up!\n"); > + return 0; > + } > + ret = ftrace_set_clr_event(sysname, 0); > + kfree(sysname); > + > + if (WARN_ON_ONCE(ret)) > + pr_warning("error disabling system %s\n", > + system->name); > + > + pr_cont("OK\n"); > + } > + > + /* Test with all events enabled */ > + > + pr_info("Running tests on all trace events:\n"); > + pr_info("Testing all events: "); > + > + sysname = kmalloc(4, GFP_KERNEL); > + if (WARN_ON(!sysname)) { > + pr_warning("Can't allocate memory, giving up!\n"); > + return 0; > + } > + memcpy(sysname, "*:*", 4); > + ret = ftrace_set_clr_event(sysname, 1); > + if (WARN_ON_ONCE(ret)) { > + kfree(sysname); > + pr_warning("error enabling all events\n"); > + return 0; > + } > + > + event_test_stuff(); > + > + /* reset sysname */ > + memcpy(sysname, "*:*", 4); > + ret = ftrace_set_clr_event(sysname, 0); > + kfree(sysname); > + > + if (WARN_ON_ONCE(ret)) { > + pr_warning("error disabling all events\n"); > + return 0; > + } > + > + pr_cont("OK\n"); > + > + return 0; > +} > + > +late_initcall(event_trace_self_tests); > + > +#endif > -- > 1.6.2.1 > > --
--
unsubscribe notice
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to
majordomo@vger.kernel.org
More majordomo info at
http://vger.kernel.org/majordomo-info.html
Please read the FAQ at
http://www.tux.org/lkml/
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
Messages in current thread:
[PATCH 0/5] [GIT PULL] updates for tip
, Steven Rostedt
, (Wed Apr 15, 7:18 pm)
[PATCH 1/5] ftrace: use module notifier for function tracer
, Steven Rostedt
, (Wed Apr 15, 7:18 pm)
[PATCH 2/5] tracing/events: add startup tests for events
, Steven Rostedt
, (Wed Apr 15, 7:18 pm)
[PATCH 3/5] tracing/events: add rcu locking around trace e ...
, Steven Rostedt
, (Wed Apr 15, 7:18 pm)
[PATCH 4/5] tracing/events/ring-buffer: expose format of r ...
, Steven Rostedt
, (Wed Apr 15, 7:18 pm)
[PATCH 5/5] tracing: add saved_cmdlines file to show cache ...
, Steven Rostedt
, (Wed Apr 15, 7:18 pm)
[PATCH] tracing: add #include <linux/delay.h> to fix build ...
, Ingo Molnar
, (Thu Apr 16, 1:39 am)
Re: [PATCH 0/5] [GIT PULL] updates for tip
, Ingo Molnar
, (Thu Apr 16, 2:51 am)
Re: [PATCH 0/5] [GIT PULL] updates for tip
, Ingo Molnar
, (Thu Apr 16, 2:53 am)
Re: [PATCH 0/5] [GIT PULL] updates for tip
, Steven Rostedt
, (Thu Apr 16, 6:52 am)
Re: [PATCH] tracing: add #include <linux/delay.h> to fix b ...
, Steven Rostedt
, (Thu Apr 16, 7:08 am)
Re: [PATCH 1/5] ftrace: use module notifier for function t ...
, Frederic Weisbecker
, (Thu Apr 16, 8:36 am)
Re: [PATCH 2/5] tracing/events: add startup tests for events
, Frederic Weisbecker
, (Thu Apr 16, 8:41 am)
Re: [PATCH 2/5] tracing/events: add startup tests for events
, Steven Rostedt
, (Thu Apr 16, 8:51 am)
Re: [PATCH 1/5] ftrace: use module notifier for function t ...
, Steven Rostedt
, (Thu Apr 16, 8:53 am)
Re: [PATCH 5/5] tracing: add saved_cmdlines file to show c ...
, Frederic Weisbecker
, (Thu Apr 16, 8:54 am)
Re: [PATCH 5/5] tracing: add saved_cmdlines file to show c ...
, Steven Rostedt
, (Thu Apr 16, 8:58 am)
Re: [PATCH 2/5] tracing/events: add startup tests for events
, Frederic Weisbecker
, (Thu Apr 16, 9:02 am)
Re: [PATCH 5/5] tracing: add saved_cmdlines file to show c ...
, Frederic Weisbecker
, (Thu Apr 16, 9:05 am)
Re: [PATCH 0/5] [GIT PULL] updates for tip
, Ingo Molnar
, (Thu Apr 16, 9:12 am)
Re: [PATCH 0/5] [GIT PULL] updates for tip
, Steven Rostedt
, (Thu Apr 16, 9:22 am)
Re: [PATCH 0/5] [GIT PULL] updates for tip
, Ingo Molnar
, (Thu Apr 16, 9:30 am)
Re: [PATCH 0/5] [GIT PULL] updates for tip
, Ingo Molnar
, (Thu Apr 16, 5:29 pm)
Re: [PATCH] tracing: add #include <linux/delay.h> to fix b ...
, Ingo Molnar
, (Thu Apr 16, 5:30 pm)
Re: [PATCH 1/5] ftrace: use module notifier for function t ...
, Steven Rostedt
, (Fri Apr 17, 4:44 am)
Re: [PATCH 3/5] tracing/events: add rcu locking around tra ...
, Steven Rostedt
, (Fri Apr 17, 7:08 am)
Re: [PATCH 3/5] tracing/events: add rcu locking around tra ...
, Jeremy Fitzhardinge
, (Fri Apr 17, 8:20 am)
Re: [PATCH 3/5] tracing/events: add rcu locking around tra ...
, Steven Rostedt
, (Fri Apr 17, 8:42 am)
Re: [PATCH 3/5] tracing/events: add rcu locking around tra ...
, Theodore Tso
, (Fri Apr 17, 9:18 am)
Re: [PATCH 3/5] tracing/events: add rcu locking around tra ...
, Jeremy Fitzhardinge
, (Fri Apr 17, 9:32 am)
Re: [PATCH 3/5] tracing/events: add rcu locking around tra ...
, Steven Rostedt
, (Fri Apr 17, 9:41 am)
Re: [PATCH 3/5] tracing/events: add rcu locking around tra ...
, Jeremy Fitzhardinge
, (Fri Apr 17, 4:53 pm)
Re: [PATCH 1/5] ftrace: use module notifier for function t ...
, Rusty Russell
, (Sun Apr 19, 4:25 am)
Re: [PATCH 1/5] ftrace: use module notifier for function t ...
, Steven Rostedt
, (Mon Apr 20, 6:57 am)
Re: [PATCH 1/5] ftrace: use module notifier for function t ...
, Rusty Russell
, (Mon Apr 20, 10:15 pm)
Re: [PATCH 1/5] ftrace: use module notifier for function t ...
, Steven Rostedt
, (Tue Apr 21, 6:13 am)
Re: [PATCH 1/5] ftrace: use module notifier for function t ...
, Ingo Molnar
, (Tue Apr 21, 6:58 am)
Re: [PATCH 1/5] ftrace: use module notifier for function t ...
, Tim Abbott
, (Tue Apr 21, 10:51 am)
Re: [PATCH 1/5] ftrace: use module notifier for function t ...
, Steven Rostedt
, (Tue Apr 21, 11:17 am)
Re: [PATCH 1/5] ftrace: use module notifier for function t ...
, Tim Abbott
, (Tue Apr 21, 11:47 am)
Re: [PATCH 1/5] ftrace: use module notifier for function t ...
, Ingo Molnar
, (Wed Apr 22, 2:16 am)
Re: [PATCH 1/5] ftrace: use module notifier for function t ...
, Tim Abbott
, (Wed Apr 22, 3:20 pm)
Re: [PATCH 1/5] ftrace: use module notifier for function t ...
, Masami Hiramatsu
, (Wed Apr 22, 3:57 pm)
Re: [PATCH 1/5] ftrace: use module notifier for function t ...
, Anders Kaseorg
, (Thu Apr 23, 12:40 pm)
Re: [PATCH 1/5] ftrace: use module notifier for function t ...
, Mathieu Desnoyers
, (Thu Apr 23, 12:57 pm)
Re: [PATCH 1/5] ftrace: use module notifier for function t ...
, Masami Hiramatsu
, (Thu Apr 23, 1:06 pm)
Re: [PATCH 1/5] ftrace: use module notifier for function t ...
, Tim Abbott
, (Thu Apr 23, 3:31 pm)
Re: [PATCH 1/5] ftrace: use module notifier for function t ...
, Masami Hiramatsu
, (Thu Apr 23, 8:11 pm)
Re: [PATCH 3/5] tracing/events: add rcu locking around tra ...
, Steven Rostedt
, (Wed May 6, 7:10 pm)
Re: [PATCH 3/5] tracing/events: add rcu locking around tra ...
, Ingo Molnar
, (Thu May 7, 4:32 am)
Re: [PATCH 3/5] tracing/events: add rcu locking around tra ...
, Steven Rostedt
, (Thu May 7, 6:10 am)
Navigation
Mailing list archives
Recent posts
Popular discussions
linux-kernel
:
Mel Gorman
Re: [PATCH 1/4] vmstat: remove zone->lock from walk_zones_in_node
Guenter Roeck
Re: [lm-sensors] Location for thermal drivers
David Woodhouse
Re: RFC: Moving firmware blobs out of the kernel.
Siddha, Suresh B
Re: [PATCH 2.6.21 review I] [11/25] x86: default to physical mode on hotplug CPU k...
Peter Zijlstra
Re: [patch 4/6] mm: merge populate and nopage into fault (fixes nonlinear)
git-commits-head
:
Linux Kernel Mailing List
[MIPS] Fix potential latency problem due to non-atomic cpu_wait.
Linux Kernel Mailing List
USB: rename USB_SPEED_VARIABLE to USB_SPEED_WIRELESS
Linux Kernel Mailing List
lib/vsprintf.c: fix bug omitting minus sign of numbers (module_param)
Linux Kernel Mailing List
[Bluetooth] Initiate authentication during connection establishment
Linux Kernel Mailing List
[POWERPC] 4xx: Add ppc40x_defconfig
linux-netdev
:
MERCEDES
Your mail id has won 950,000.00 in the MERCEDES Benz Online Promo.for claims send:
David Miller
Re: [PATCH] xen/netfront: do not mark packets of length < MSS as GSO
David Miller
Re: skb_segment() questions
Shan Wei
[RFC PATCH net-next 2/5]IPv6:netfilter: Send an ICMPv6 "Fragment Reassembly Timeou...
Stanislaw Gruszka
[PATCH 1/4] bnx2x: use smp_mb() to keep ordering of read write operations
git
:
Nicolas Sebrecht
git-svn died of signal 11 (was "3 failures on test t9100 (svn)")
Junio C Hamano
Re: [PATCH 2/2] Add url.<base>.pushInsteadOf: URL rewriting for push only
Martin Langhoff
Re: [PATCH] GIT commit statistics.
Alexandre Julliard
[PATCH] gitweb: Put back shortlog instead of graphiclog in the project list.
Josh Triplett
[PATCH 2/2] Add url.<base>.pushInsteadOf: URL rewriting for push only
openbsd-misc
:
Taisto Qvist XX
Re: AMD GEODE LX-800 just works with kernel from install42.iso and kernelpanics wi...
Nico Meijer
Re: gOS Develop Kit with VIA pc-1 Processor Platform VIA C7-D
Andreas Bihlmaier
Re: jetway board sensors (Fintek F71805F)
admin
Drive a 2009 car from R799p/m
Antti Harri
Re: how to create a sha256 hash
Colocation donated by:
Syndicate