diff --git a/drivers/cpuidle/Kconfig b/drivers/cpuidle/Kconfig index 88727b7c0d59..1449b854f2d4 100644 --- a/drivers/cpuidle/Kconfig +++ b/drivers/cpuidle/Kconfig @@ -24,6 +24,15 @@ config CPU_IDLE_GOV_LADDER config CPU_IDLE_GOV_MENU bool "Menu governor (for tickless system)" +config QGKI_MENU_GOV_DEBUG + bool "Trace menu governor decisions" + depends on QGKI && CPU_IDLE_GOV_MENU && FTRACE + help + Trace menu governor decisions to help understand the system + state. The predicted sleep time, latency requirement for the + CPU and the idle state chosen based on the parameters are all + logged in the trace. + config CPU_IDLE_GOV_TEO bool "Timer events oriented (TEO) governor (for tickless systems)" help diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c index e5a5d0c8d66b..78981135d11d 100644 --- a/drivers/cpuidle/governors/menu.c +++ b/drivers/cpuidle/governors/menu.c @@ -18,6 +18,9 @@ #include #include #include +#ifdef CONFIG_QGKI_MENU_GOV_DEBUG +#include +#endif /* * Please note when changing the tuning values: @@ -277,6 +280,9 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev, { struct menu_device *data = this_cpu_ptr(&menu_devices); int latency_req = cpuidle_governor_latency_req(dev->cpu); +#ifdef CONFIG_QGKI_MENU_GOV_DEBUG + int qos = latency_req; +#endif int i; int idx; unsigned int interactivity_req; @@ -305,6 +311,9 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev, * polling one. */ *stop_tick = !(drv->states[0].flags & CPUIDLE_FLAG_POLLING); +#ifdef CONFIG_QGKI_MENU_GOV_DEBUG + trace_cpuidle_select(dev->cpu, 0, 0, *stop_tick, 0); +#endif return 0; } @@ -393,6 +402,11 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev, s->target_residency <= ktime_to_us(delta_next)) idx = i; +#ifdef CONFIG_QGKI_MENU_GOV_DEBUG + trace_cpuidle_select(dev->cpu, predicted_us, qos, + *stop_tick, idx); +#endif + return idx; } if (s->exit_latency > latency_req) @@ -433,6 +447,9 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev, } } +#ifdef CONFIG_QGKI_MENU_GOV_DEBUG + trace_cpuidle_select(dev->cpu, predicted_us, qos, *stop_tick, idx); +#endif return idx; } diff --git a/include/trace/events/power.h b/include/trace/events/power.h index c57e32f48da3..5b3e77be7bfa 100644 --- a/include/trace/events/power.h +++ b/include/trace/events/power.h @@ -40,6 +40,36 @@ DEFINE_EVENT(cpu, cpu_idle, TP_ARGS(state, cpu_id) ); +#ifdef CONFIG_QGKI_MENU_GOV_DEBUG +TRACE_EVENT(cpuidle_select, + + TP_PROTO(int cpu, long residency, unsigned int latency, bool tick, + int idx), + + TP_ARGS(cpu, residency, latency, tick, idx), + + TP_STRUCT__entry( + __field(int, cpu) + __field(long, residency) + __field(u32, latency) + __field(bool, tick) + __field(int, idx) + ), + + TP_fast_assign( + __entry->cpu = cpu; + __entry->residency = residency; + __entry->latency = latency; + __entry->tick = tick; + __entry->idx = idx; + ), + + TP_printk("cpu: %d residency: %lld latency: %d tick: %d idx: %d", + __entry->cpu, __entry->residency, __entry->latency, + __entry->tick, __entry->idx) +); +#endif + TRACE_EVENT(powernv_throttle, TP_PROTO(int chip_id, const char *reason, int pmax),