]> err.no Git - linux-2.6/commitdiff
ftrace: selftest protect againt max flip
authorSteven Rostedt <rostedt@goodmis.org>
Mon, 12 May 2008 19:20:56 +0000 (21:20 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Fri, 23 May 2008 19:15:59 +0000 (21:15 +0200)
There is a slight race condition in the selftest where the max update
of the wakeup and irqs/preemption off tests can be doing a max update as
the buffers are being tested. If this happens the system can crash with
a GPF.

This patch adds the max update spinlock around the checking of the
buffers to prevent such a race.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
kernel/trace/trace_selftest.c

index 83e55a2000ccb13e87fd3ebade062384b46704fe..395274e783b34b0fa5c6e26f0eaa9595adf9b4a8 100644 (file)
@@ -82,10 +82,12 @@ trace_test_buffer_cpu(struct trace_array *tr, struct trace_array_cpu *data)
  */
 static int trace_test_buffer(struct trace_array *tr, unsigned long *count)
 {
-       unsigned long cnt = 0;
-       int cpu;
-       int ret = 0;
+       unsigned long flags, cnt = 0;
+       int cpu, ret = 0;
 
+       /* Don't allow flipping of max traces now */
+       raw_local_irq_save(flags);
+       __raw_spin_lock(&ftrace_max_lock);
        for_each_possible_cpu(cpu) {
                if (!head_page(tr->data[cpu]))
                        continue;
@@ -96,6 +98,8 @@ static int trace_test_buffer(struct trace_array *tr, unsigned long *count)
                if (ret)
                        break;
        }
+       __raw_spin_unlock(&ftrace_max_lock);
+       raw_local_irq_restore(flags);
 
        if (count)
                *count = cnt;