Merge branch 'perf-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[safe/jmp/linux-2.6] / kernel / timer.c
index 5c1e49e..c61a794 100644 (file)
@@ -37,7 +37,7 @@
 #include <linux/delay.h>
 #include <linux/tick.h>
 #include <linux/kallsyms.h>
-#include <linux/perf_counter.h>
+#include <linux/perf_event.h>
 #include <linux/sched.h>
 
 #include <asm/uaccess.h>
@@ -46,6 +46,9 @@
 #include <asm/timex.h>
 #include <asm/io.h>
 
+#define CREATE_TRACE_POINTS
+#include <trace/events/timer.h>
+
 u64 jiffies_64 __cacheline_aligned_in_smp = INITIAL_JIFFIES;
 
 EXPORT_SYMBOL(jiffies_64);
@@ -521,6 +524,25 @@ static inline void debug_timer_activate(struct timer_list *timer) { }
 static inline void debug_timer_deactivate(struct timer_list *timer) { }
 #endif
 
+static inline void debug_init(struct timer_list *timer)
+{
+       debug_timer_init(timer);
+       trace_timer_init(timer);
+}
+
+static inline void
+debug_activate(struct timer_list *timer, unsigned long expires)
+{
+       debug_timer_activate(timer);
+       trace_timer_start(timer, expires);
+}
+
+static inline void debug_deactivate(struct timer_list *timer)
+{
+       debug_timer_deactivate(timer);
+       trace_timer_cancel(timer);
+}
+
 static void __init_timer(struct timer_list *timer,
                         const char *name,
                         struct lock_class_key *key)
@@ -549,7 +571,7 @@ void init_timer_key(struct timer_list *timer,
                    const char *name,
                    struct lock_class_key *key)
 {
-       debug_timer_init(timer);
+       debug_init(timer);
        __init_timer(timer, name, key);
 }
 EXPORT_SYMBOL(init_timer_key);
@@ -568,7 +590,7 @@ static inline void detach_timer(struct timer_list *timer,
 {
        struct list_head *entry = &timer->entry;
 
-       debug_timer_deactivate(timer);
+       debug_deactivate(timer);
 
        __list_del(entry->prev, entry->next);
        if (clear_pending)
@@ -632,9 +654,7 @@ __mod_timer(struct timer_list *timer, unsigned long expires,
                        goto out_unlock;
        }
 
-       debug_timer_activate(timer);
-
-       new_base = __get_cpu_var(tvec_bases);
+       debug_activate(timer, expires);
 
        cpu = smp_processor_id();
 
@@ -721,7 +741,7 @@ int mod_timer(struct timer_list *timer, unsigned long expires)
         * networking code - if the timer is re-modified
         * to be the same thing then just return:
         */
-       if (timer->expires == expires && timer_pending(timer))
+       if (timer_pending(timer) && timer->expires == expires)
                return 1;
 
        return __mod_timer(timer, expires, false, TIMER_NOT_PINNED);
@@ -787,7 +807,7 @@ void add_timer_on(struct timer_list *timer, int cpu)
        BUG_ON(timer_pending(timer) || !timer->function);
        spin_lock_irqsave(&base->lock, flags);
        timer_set_base(timer, base);
-       debug_timer_activate(timer);
+       debug_activate(timer, timer->expires);
        if (time_before(timer->expires, base->next_timer) &&
            !tbase_get_deferrable(timer->base))
                base->next_timer = timer->expires;
@@ -1000,7 +1020,9 @@ static inline void __run_timers(struct tvec_base *base)
                                 */
                                lock_map_acquire(&lockdep_map);
 
+                               trace_timer_expire_entry(timer);
                                fn(data);
+                               trace_timer_expire_exit(timer);
 
                                lock_map_release(&lockdep_map);
 
@@ -1023,8 +1045,8 @@ static inline void __run_timers(struct tvec_base *base)
 #ifdef CONFIG_NO_HZ
 /*
  * Find out when the next timer event is due to happen. This
- * is used on S/390 to stop all activity when a cpus is idle.
- * This functions needs to be called disabled.
+ * is used on S/390 to stop all activity when a CPU is idle.
+ * This function needs to be called with interrupts disabled.
  */
 static unsigned long __next_timer_interrupt(struct tvec_base *base)
 {
@@ -1174,9 +1196,9 @@ void update_process_times(int user_tick)
        /* Note: this timer irq context must be accounted for as well. */
        account_process_tick(p, user_tick);
        run_local_timers();
-       if (rcu_pending(cpu))
-               rcu_check_callbacks(cpu, user_tick);
+       rcu_check_callbacks(cpu, user_tick);
        printk_tick();
+       perf_event_do_pending();
        scheduler_tick();
        run_posix_cpu_timers(p);
 }
@@ -1188,8 +1210,6 @@ static void run_timer_softirq(struct softirq_action *h)
 {
        struct tvec_base *base = __get_cpu_var(tvec_bases);
 
-       perf_counter_do_pending();
-
        hrtimer_run_pending();
 
        if (time_after_eq(jiffies, base->timer_jiffies))