ANDROID: sched: add vendor hook for correcting cpu capacity

Current CPU capacity is scaled by frequency
but it will sometime overestimate.
Add vendor hook to adjust cpu capacity.

android_vh_arch_set_freq_scale
	Adjust cpu freq scale for each opp.

Bug: 163935827

Signed-off-by: Yun Hsiang <yun.hsiang@mediatek.com>
Change-Id: I054740a7f60301d5a3b085bfa540d52853f5eec5
This commit is contained in:
Yun Hsiang
2020-08-13 14:41:46 +08:00
committed by Todd Kjos
parent 2935d588b1
commit e209b3b88d
3 changed files with 32 additions and 0 deletions

View File

@@ -15,6 +15,7 @@
#include <trace/hooks/futex.h> #include <trace/hooks/futex.h>
#include <trace/hooks/dtask.h> #include <trace/hooks/dtask.h>
#include <trace/hooks/cpuidle.h> #include <trace/hooks/cpuidle.h>
#include <trace/hooks/topology.h>
/* /*
* Export tracepoints that act as a bare tracehook (ie: have no trace event * Export tracepoints that act as a bare tracehook (ie: have no trace event
@@ -33,6 +34,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_prepare_prio_fork);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_finish_prio_fork); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_finish_prio_fork);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_set_user_nice); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_set_user_nice);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_setscheduler); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_setscheduler);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_arch_set_freq_scale);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_is_fpsimd_save); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_is_fpsimd_save);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_transaction_init); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_transaction_init);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_set_priority); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_set_priority);

View File

@@ -20,6 +20,7 @@
#include <linux/percpu.h> #include <linux/percpu.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/smp.h> #include <linux/smp.h>
#include <trace/hooks/topology.h>
__weak bool arch_freq_counters_available(struct cpumask *cpus) __weak bool arch_freq_counters_available(struct cpumask *cpus)
{ {
@@ -43,6 +44,8 @@ void arch_set_freq_scale(struct cpumask *cpus, unsigned long cur_freq,
scale = (cur_freq << SCHED_CAPACITY_SHIFT) / max_freq; scale = (cur_freq << SCHED_CAPACITY_SHIFT) / max_freq;
trace_android_vh_arch_set_freq_scale(cur_freq, max_freq, &scale);
for_each_cpu(i, cpus) for_each_cpu(i, cpus)
per_cpu(freq_scale, i) = scale; per_cpu(freq_scale, i) = scale;
} }

View File

@@ -0,0 +1,27 @@
/* SPDX-License-Identifier: GPL-2.0 */
#undef TRACE_SYSTEM
#define TRACE_SYSTEM topology
#define TRACE_INCLUDE_PATH trace/hooks
#if !defined(_TRACE_HOOK_TOPOLOGY_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_HOOK_TOPOLOGY_H
#include <linux/tracepoint.h>
#include <trace/hooks/vendor_hooks.h>
#if defined(CONFIG_TRACEPOINTS) && defined(CONFIG_ANDROID_VENDOR_HOOKS)
DECLARE_HOOK(android_vh_arch_set_freq_scale,
TP_PROTO(unsigned long freq, unsigned long max, unsigned long *scale),
TP_ARGS(freq, max, scale));
#else
#define trace_android_rvh_arch_set_freq_scale(freq, max, scale)
#endif
#endif /* _TRACE_HOOK_TOPOLOGY_H */
/* This part must be outside protection */
#include <trace/define_trace.h>