]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ftrace: fix wakeups
authorIngo Molnar <mingo@elte.hu>
Mon, 12 May 2008 19:20:52 +0000 (21:20 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Fri, 23 May 2008 19:05:02 +0000 (21:05 +0200)
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
include/linux/sched.h
kernel/sched.c
kernel/trace/trace.c

index 652d380ae5631b363d5868c609ea7098fe6798f4..a3970b5637579ba05e581cb141ed3b5389970d02 100644 (file)
@@ -246,6 +246,8 @@ extern asmlinkage void schedule_tail(struct task_struct *prev);
 extern void init_idle(struct task_struct *idle, int cpu);
 extern void init_idle_bootup_task(struct task_struct *idle);
 
+extern int runqueue_is_locked(void);
+
 extern cpumask_t nohz_cpu_mask;
 #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ)
 extern int select_nohz_load_balancer(int cpu);
index 673b588b713bcf5deefbaf8d5bd526d7416b4a57..9ca4a2e6a236ffd98749771338384839cdefab28 100644 (file)
@@ -642,6 +642,24 @@ static inline void update_rq_clock(struct rq *rq)
 # define const_debug static const
 #endif
 
+/**
+ * runqueue_is_locked
+ *
+ * Returns true if the current cpu runqueue is locked.
+ * This interface allows printk to be called with the runqueue lock
+ * held and know whether or not it is OK to wake up the klogd.
+ */
+int runqueue_is_locked(void)
+{
+       int cpu = get_cpu();
+       struct rq *rq = cpu_rq(cpu);
+       int ret;
+
+       ret = spin_is_locked(&rq->lock);
+       put_cpu();
+       return ret;
+}
+
 /*
  * Debugging: various feature bits
  */
index 65173b14b914502e6c03ca086bbc86b3b7d07275..2ca9d66aa74ef7b352b9706a6e36c94e4122c7fb 100644 (file)
@@ -70,12 +70,13 @@ static DECLARE_WAIT_QUEUE_HEAD(trace_wait);
 
 unsigned long trace_flags = TRACE_ITER_PRINT_PARENT;
 
-/*
- * FIXME: where should this be called?
- */
 void trace_wake_up(void)
 {
-       if (!(trace_flags & TRACE_ITER_BLOCK))
+       /*
+        * The runqueue_is_locked() can fail, but this is the best we
+        * have for now:
+        */
+       if (!(trace_flags & TRACE_ITER_BLOCK) && !runqueue_is_locked())
                wake_up(&trace_wait);
 }
 
@@ -657,6 +658,8 @@ trace_function(struct trace_array *tr, struct trace_array_cpu *data,
        entry->fn.ip            = ip;
        entry->fn.parent_ip     = parent_ip;
        spin_unlock_irqrestore(&data->lock, irq_flags);
+
+       trace_wake_up();
 }
 
 void
@@ -686,6 +689,8 @@ __trace_special(void *__tr, void *__data,
        entry->special.arg2     = arg2;
        entry->special.arg3     = arg3;
        spin_unlock_irqrestore(&data->lock, irq_flags);
+
+       trace_wake_up();
 }
 
 #endif
@@ -759,6 +764,8 @@ tracing_sched_wakeup_trace(struct trace_array *tr,
        entry->ctx.next_prio    = wakee->prio;
        __trace_stack(tr, data, flags, 5);
        spin_unlock_irqrestore(&data->lock, irq_flags);
+
+       trace_wake_up();
 }
 
 #ifdef CONFIG_FTRACE