cpuidle: menu: trace menu governor decisions

Enable debugging of menu governor's choices by tracing at different
points.

Change-Id: Ia72a92cd74b5ae02bd0e504ec66653e680e9df7e
Signed-off-by: Lina Iyer <ilina@codeaurora.org>
This commit is contained in:
Lina Iyer 2020-08-20 13:39:56 -06:00
commit 1f820e142f
3 changed files with 56 additions and 0 deletions

View file

@ -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

View file

@ -18,6 +18,9 @@
#include <linux/sched/loadavg.h>
#include <linux/sched/stat.h>
#include <linux/math64.h>
#ifdef CONFIG_QGKI_MENU_GOV_DEBUG
#include <trace/events/power.h>
#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;
}

View file

@ -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),