ANDROID: sched: add hook point in do_sched_yield()

When a task yields, it relinquishes the cpu and
scheduler is tasked to find another task.
However our vendor scheduler logic implementation
could return the same task leading to a loop where
the yielded task gets to run back, so add hook point
in do_sched_yield() for vendor can do some work
before task is scheduled.

Bug: 205804537
Change-Id: I6528c3f4b0ee360559ef9c97cb1eb2b2d1357870
Signed-off-by: Tengfei Fan <quic_tengfan@quicinc.com>
Signed-off-by: Sai Harshini Nimmala <quic_snimmala@quicinc.com>
This commit is contained in:
Tengfei Fan
2021-11-22 09:15:36 +08:00
committed by Todd Kjos
parent a1290fe021
commit c0704a1fc8
3 changed files with 7 additions and 0 deletions

View File

@@ -239,6 +239,10 @@ DECLARE_RESTRICTED_HOOK(android_rvh_set_cpus_allowed_by_task,
struct task_struct *p, unsigned int *dest_cpu),
TP_ARGS(cpu_valid_mask, new_mask, p, dest_cpu), 1);
DECLARE_RESTRICTED_HOOK(android_rvh_do_sched_yield,
TP_PROTO(struct rq *rq),
TP_ARGS(rq), 1);
DECLARE_HOOK(android_vh_free_task,
TP_PROTO(struct task_struct *p),
TP_ARGS(p));

View File

@@ -8359,6 +8359,8 @@ static void do_sched_yield(void)
schedstat_inc(rq->yld_count);
current->sched_class->yield_task(rq);
trace_android_rvh_do_sched_yield(rq);
preempt_disable();
rq_unlock_irq(rq, &rf);
sched_preempt_enable_no_resched();

View File

@@ -75,3 +75,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_rto_next_cpu);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_is_cpu_allowed);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_get_nohz_timer_target);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_sched_getaffinity);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_do_sched_yield);