Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a7e0bc8f authored by Yun Hsiang's avatar Yun Hsiang Committed by Todd Kjos
Browse files

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: default avatarYun Hsiang <yun.hsiang@mediatek.com>
Change-Id: I054740a7f60301d5a3b085bfa540d52853f5eec5
(cherry picked from commit e209b3b88d9772ecd782d71c1ae7c5425dd20289)
parent f553ed04
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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);
+6 −1
Original line number Diff line number Diff line
@@ -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,6 +34,8 @@ void arch_set_freq_scale(struct cpumask *cpus, unsigned long cur_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){
		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;
}
+27 −0
Original line number Diff line number Diff line
/* 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>