* This code is licenced under the GPL.
  */
 
+#include "linux/percpu-defs.h"
 #include <linux/clockchips.h>
 #include <linux/kernel.h>
 #include <linux/mutex.h>
 
                                /* Shallower states are enabled, so update. */
                                dev->states_usage[entered_state].above++;
+                               trace_cpu_idle_miss(dev->cpu, entered_state, false);
                                break;
                        }
                } else if (diff > delay) {
                                 * Update if a deeper state would have been a
                                 * better match for the observed idle duration.
                                 */
-                               if (diff - delay >= drv->states[i].target_residency_ns)
+                               if (diff - delay >= drv->states[i].target_residency_ns) {
                                        dev->states_usage[entered_state].below++;
+                                       trace_cpu_idle_miss(dev->cpu, entered_state, true);
+                               }
 
                                break;
                        }
 
        TP_ARGS(state, cpu_id)
 );
 
+TRACE_EVENT(cpu_idle_miss,
+
+       TP_PROTO(unsigned int cpu_id, unsigned int state, bool below),
+
+       TP_ARGS(cpu_id, state, below),
+
+       TP_STRUCT__entry(
+               __field(u32,            cpu_id)
+               __field(u32,            state)
+               __field(bool,           below)
+       ),
+
+       TP_fast_assign(
+               __entry->cpu_id = cpu_id;
+               __entry->state = state;
+               __entry->below = below;
+       ),
+
+       TP_printk("cpu_id=%lu state=%lu type=%s", (unsigned long)__entry->cpu_id,
+               (unsigned long)__entry->state, (__entry->below)?"below":"above")
+);
+
 TRACE_EVENT(powernv_throttle,
 
        TP_PROTO(int chip_id, const char *reason, int pmax),