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: 165823138

Signed-off-by: Yun Hsiang <yun.hsiang@mediatek.com>
Change-Id: I054740a7f60301d5a3b085bfa540d52853f5eec5
(cherry picked from commit e209b3b88d9772ecd782d71c1ae7c5425dd20289)
This commit is contained in:
Yun Hsiang 2020-08-13 14:41:46 +08:00 • committed by Todd Kjos
commit a7e0bc8f4c
3 changed files with 35 additions and 1 deletions

View file

@ -15,6 +15,7 @@
#include <trace/hooks/rwsem.h>
#include <trace/hooks/futex.h>
#include <trace/hooks/fpsimd.h>
#include <trace/hooks/topology.h>
/*
* Export tracepoints that act as a bare tracehook (ie: have no trace event
@ -42,6 +43,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rwsem_write_wait_finish);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sched_show_task);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ptype_head);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_kfree_skb);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_arch_set_freq_scale);
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_restore_priority);

View file

@ -20,6 +20,7 @@
#include <linux/percpu.h>
#include <linux/sched.h>
#include <linux/smp.h>
#include <trace/hooks/topology.h>
DEFINE_PER_CPU(unsigned long, freq_scale) = SCHED_CAPACITY_SCALE;
DEFINE_PER_CPU(unsigned long, max_cpu_freq);
@ -33,7 +34,9 @@ void arch_set_freq_scale(struct cpumask *cpus, unsigned long cur_freq,
scale = (cur_freq << SCHED_CAPACITY_SHIFT) / max_freq;
for_each_cpu(i, cpus) {
trace_android_vh_arch_set_freq_scale(cur_freq, max_freq, &scale);
for_each_cpu(i, cpus){
per_cpu(freq_scale, i) = scale;
per_cpu(max_cpu_freq, i) = max_freq;
}
@ -54,6 +57,8 @@ void arch_set_max_freq_scale(struct cpumask *cpus,
scale = (policy_max_freq << SCHED_CAPACITY_SHIFT) / max_freq;
trace_android_vh_arch_set_freq_scale(policy_max_freq, max_freq, &scale);
for_each_cpu(cpu, cpus)
per_cpu(max_freq_scale, cpu) = 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_vh_arch_set_freq_scale(freq, max, scale)
#endif
#endif /* _TRACE_HOOK_TOPOLOGY_H */
/* This part must be outside protection */
#include <trace/define_trace.h>