ANDROID: sched: add vendor hooks to handle scheduling priority

Add hooks to collect scheduling information and apply vendor's
tuning when task's scheduling priority is changed

Bug: 163431711

Signed-off-by: JianMin Liu <jian-min.liu@mediatek.com>
Change-Id: Ic85835852690d0060666107d9108560f5023496b
This commit is contained in:
JianMin Liu
2020-08-10 23:15:09 +08:00
committed by Todd Kjos
parent 9a81ce5c71
commit f39f3ac200
3 changed files with 36 additions and 0 deletions

View File

@@ -25,6 +25,11 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_enqueue_task);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_dequeue_task);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_can_migrate_task);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_find_lowest_rq);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_rtmutex_prepare_setprio);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_prepare_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_setscheduler);
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_set_priority);

View File

@@ -45,6 +45,26 @@ DECLARE_RESTRICTED_HOOK(android_rvh_find_lowest_rq,
TP_PROTO(struct task_struct *p, struct cpumask *local_cpu_mask,
int *lowest_cpu),
TP_ARGS(p, local_cpu_mask, lowest_cpu), 1);
DECLARE_RESTRICTED_HOOK(android_rvh_prepare_prio_fork,
TP_PROTO(struct task_struct *p),
TP_ARGS(p), 1);
DECLARE_RESTRICTED_HOOK(android_rvh_finish_prio_fork,
TP_PROTO(struct task_struct *p),
TP_ARGS(p), 1);
DECLARE_RESTRICTED_HOOK(android_rvh_rtmutex_prepare_setprio,
TP_PROTO(struct task_struct *p, struct task_struct *pi_task),
TP_ARGS(p, pi_task), 1);
DECLARE_RESTRICTED_HOOK(android_rvh_set_user_nice,
TP_PROTO(struct task_struct *p, long *nice),
TP_ARGS(p, nice), 1);
DECLARE_RESTRICTED_HOOK(android_rvh_setscheduler,
TP_PROTO(struct task_struct *p),
TP_ARGS(p), 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)
@@ -54,6 +74,11 @@ DECLARE_RESTRICTED_HOOK(android_rvh_find_lowest_rq,
#define trace_android_rvh_dequeue_task(rq, p)
#define trace_android_rvh_can_migrate_task(p, dst_cpu, can_migrate)
#define trace_android_rvh_find_lowest_rq(p, local_cpu_mask, lowest_cpu)
#define trace_android_rvh_prepare_prio_fork(p)
#define trace_android_rvh_finish_prio_fork(p)
#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)
#endif
#endif /* _TRACE_HOOK_SCHED_H */
/* This part must be outside protection */

View File

@@ -3251,6 +3251,7 @@ int sched_fork(unsigned long clone_flags, struct task_struct *p)
* Make sure we do not leak PI boosting priority to the child.
*/
p->prio = current->normal_prio;
trace_android_rvh_prepare_prio_fork(p);
uclamp_fork(p);
@@ -3283,6 +3284,7 @@ int sched_fork(unsigned long clone_flags, struct task_struct *p)
p->sched_class = &fair_sched_class;
init_entity_runnable_average(&p->se);
trace_android_rvh_finish_prio_fork(p);
/*
* The child is not yet in the pid-hash so no cgroup attach races,
@@ -4851,6 +4853,7 @@ void rt_mutex_setprio(struct task_struct *p, struct task_struct *pi_task)
struct rq_flags rf;
struct rq *rq;
trace_android_rvh_rtmutex_prepare_setprio(p, pi_task);
/* XXX used to be waiter->prio, not waiter->task->prio */
prio = __rt_effective_prio(pi_task, p->normal_prio);
@@ -4982,6 +4985,7 @@ void set_user_nice(struct task_struct *p, long nice)
*/
rq = task_rq_lock(p, &rf);
update_rq_clock(rq);
trace_android_rvh_set_user_nice(p, &nice);
/*
* The RT priorities are set via sched_setscheduler(), but we still
@@ -5204,6 +5208,8 @@ static void __setscheduler(struct rq *rq, struct task_struct *p,
p->sched_class = &rt_sched_class;
else
p->sched_class = &fair_sched_class;
trace_android_rvh_setscheduler(p);
}
/*