ANDROID: sched: add em_cpu_energy vendor hook

We add a vendor hook for util to freq calculation in schedutil,
so we need to do corresponding change for energy calculation.

android_vh_em_cpu_energy
	adjust energy calculation

Bug: 178047619

Signed-off-by: Yun Hsiang <yun.hsiang@mediatek.com>
Change-Id: Iae772cf07881602eea3f27aeb75fba753e7c2635
This commit is contained in:
Yun Hsiang 2021-01-14 13:47:38 +08:00 committed by Todd Kjos
parent 54aa07b616
commit 18b294fa4c
3 changed files with 14 additions and 1 deletions

View File

@ -132,3 +132,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ftrace_dump_buffer);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_allow_domain_state);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_map_util_freq);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_report_bug);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_em_cpu_energy);

View File

@ -227,6 +227,13 @@ DECLARE_HOOK(android_vh_map_util_freq,
unsigned long cap, unsigned long *next_freq),
TP_ARGS(util, freq, cap, next_freq));
struct em_perf_domain;
DECLARE_HOOK(android_vh_em_cpu_energy,
TP_PROTO(struct em_perf_domain *pd,
unsigned long max_util, unsigned long sum_util,
unsigned long *energy),
TP_ARGS(pd, max_util, sum_util, energy));
/* macro versions of hooks are no longer required */
#endif /* _TRACE_HOOK_SCHED_H */

View File

@ -6509,6 +6509,7 @@ compute_energy(struct task_struct *p, int dst_cpu, struct perf_domain *pd)
struct cpumask *pd_mask = perf_domain_span(pd);
unsigned long cpu_cap = arch_scale_cpu_capacity(cpumask_first(pd_mask));
unsigned long max_util = 0, sum_util = 0;
unsigned long energy = 0;
int cpu;
/*
@ -6545,7 +6546,11 @@ compute_energy(struct task_struct *p, int dst_cpu, struct perf_domain *pd)
max_util = max(max_util, cpu_util);
}
return em_cpu_energy(pd->em_pd, max_util, sum_util);
trace_android_vh_em_cpu_energy(pd->em_pd, max_util, sum_util, &energy);
if (!energy)
energy = em_cpu_energy(pd->em_pd, max_util, sum_util);
return energy;
}
/*