ANDROID: sched: add restrict vendor hook to modify load balance behavior

For modifying load balance policy, we add the hook on
find_busiest_group().
It allows us to modify load balance paths.

Bug: 168248326
Signed-off-by: YT Chang <yt.chang@mediatek.com>
Change-Id: I77ec043576139806551b978eb1bdf9f637442dfb
(cherry picked from commit a2ca8408de6183364b4c17f341f06e875bc7a1c1)
(cherry picked from commit 489646b879ede582b6b00803edd3f777aede4d85)
This commit is contained in:
YT Chang 2020-09-03 16:04:01 +08:00 committed by Todd Kjos
parent 42a391fef2
commit 54cf84a595
3 changed files with 12 additions and 1 deletions

View File

@ -62,3 +62,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_printk_store);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_show_regs);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_wq_lockup_pool);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sysrq_crash);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_find_busiest_group);

View File

@ -65,6 +65,11 @@ DECLARE_RESTRICTED_HOOK(android_rvh_set_user_nice,
DECLARE_RESTRICTED_HOOK(android_rvh_setscheduler,
TP_PROTO(struct task_struct *p),
TP_ARGS(p), 1);
struct sched_group;
DECLARE_RESTRICTED_HOOK(android_rvh_find_busiest_group,
TP_PROTO(struct sched_group *busiest, struct rq *dst_rq, int *out_balance),
TP_ARGS(busiest, dst_rq, out_balance), 1);
#else
#define trace_android_rvh_select_task_rq_fair(p, prev_cpu, sd_flag, wake_flags, new_cpu)
#define trace_android_rvh_select_task_rq_rt(p, prev_cpu, sd_flag, wake_flags, new_cpu)
@ -79,6 +84,7 @@ DECLARE_RESTRICTED_HOOK(android_rvh_setscheduler,
#define trace_android_rvh_rtmutex_prepare_setprio(p, pi_task)
#define trace_android_rvh_set_user_nice(p, nice)
#define trace_android_rvh_setscheduler(p)
#define trace_android_rvh_find_busiest_group(busiest, dst_rq, out_balance)
#endif
#endif /* _TRACE_HOOK_SCHED_H */
/* This part must be outside protection */

View File

@ -8736,8 +8736,12 @@ static struct sched_group *find_busiest_group(struct lb_env *env)
if (sched_energy_enabled()) {
struct root_domain *rd = env->dst_rq->rd;
int out_balance = 1;
if (rcu_dereference(rd->pd) && !READ_ONCE(rd->overutilized))
trace_android_rvh_find_busiest_group(sds.busiest, env->dst_rq,
&out_balance);
if (rcu_dereference(rd->pd) && !READ_ONCE(rd->overutilized)
&& out_balance)
goto out_balanced;
}