ANDROID: vendor_hooks: Add hooks for scheduler

Add hooks to support oem's scheduler feature.

Bug: 200103201
Change-Id: I31023844b20923bed1ca216831e7a2431e9ab0c9
Signed-off-by: xieliujie <xieliujie@oppo.com>
Signed-off-by: Ashay Jaiswal <quic_ashayj@quicinc.com>
This commit is contained in:
xieliujie 2021-03-11 15:29:38 +08:00 committed by Todd Kjos
parent 99545883fb
commit 09e27d4f36
5 changed files with 38 additions and 4 deletions

View File

@ -151,3 +151,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_timer_calc_index);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_allow_domain_state);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cpuidle_psci_enter);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cpuidle_psci_exit);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_check_preempt_tick);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_check_preempt_wakeup_ignore);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_replace_next_task_fair);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_build_sched_domains);

View File

@ -1480,7 +1480,7 @@ struct task_struct {
int mce_count;
#endif
ANDROID_VENDOR_DATA_ARRAY(1, 64);
ANDROID_OEM_DATA_ARRAY(1, 2);
ANDROID_OEM_DATA_ARRAY(1, 6);
#ifdef CONFIG_KRETPROBES
struct llist_head kretprobe_instances;

View File

@ -174,8 +174,8 @@ DECLARE_RESTRICTED_HOOK(android_rvh_account_irq,
struct sched_entity;
DECLARE_RESTRICTED_HOOK(android_rvh_place_entity,
TP_PROTO(struct sched_entity *se, u64 vruntime),
TP_ARGS(se, vruntime), 1);
TP_PROTO(struct cfs_rq *cfs_rq, struct sched_entity *se, int initial, u64 vruntime),
TP_ARGS(cfs_rq, se, initial, vruntime), 1);
DECLARE_RESTRICTED_HOOK(android_rvh_build_perf_domains,
TP_PROTO(bool *eas_check),
@ -225,6 +225,21 @@ DECLARE_HOOK(android_vh_em_cpu_energy,
unsigned long max_util, unsigned long sum_util,
unsigned long *energy),
TP_ARGS(pd, max_util, sum_util, energy));
DECLARE_HOOK(android_vh_build_sched_domains,
TP_PROTO(bool has_asym),
TP_ARGS(has_asym));
DECLARE_RESTRICTED_HOOK(android_rvh_check_preempt_tick,
TP_PROTO(struct task_struct *p, unsigned long *ideal_runtime, bool *skip_preempt),
TP_ARGS(p, ideal_runtime, skip_preempt), 1);
DECLARE_RESTRICTED_HOOK(android_rvh_check_preempt_wakeup_ignore,
TP_PROTO(struct task_struct *p, bool *ignore),
TP_ARGS(p, ignore), 1);
DECLARE_RESTRICTED_HOOK(android_rvh_replace_next_task_fair,
TP_PROTO(struct rq *rq, struct task_struct **p, struct sched_entity **se,
bool *repick, bool simple),
TP_ARGS(rq, p, se, repick, simple), 1);
#endif /* _TRACE_HOOK_SCHED_H */
/* This part must be outside protection */
#include <trace/define_trace.h>

View File

@ -4223,11 +4223,11 @@ place_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int initial)
thresh >>= 1;
vruntime -= thresh;
trace_android_rvh_place_entity(se, vruntime);
}
/* ensure we never gain time by being placed backwards. */
se->vruntime = max_vruntime(se->vruntime, vruntime);
trace_android_rvh_place_entity(cfs_rq, se, initial, vruntime);
}
static void check_enqueue_throttle(struct cfs_rq *cfs_rq);
@ -4451,9 +4451,13 @@ check_preempt_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr)
unsigned long ideal_runtime, delta_exec;
struct sched_entity *se;
s64 delta;
bool skip_preempt = false;
ideal_runtime = sched_slice(cfs_rq, curr);
delta_exec = curr->sum_exec_runtime - curr->prev_sum_exec_runtime;
trace_android_rvh_check_preempt_tick(current, &ideal_runtime, &skip_preempt);
if (skip_preempt)
return;
if (delta_exec > ideal_runtime) {
resched_curr(rq_of(cfs_rq));
/*
@ -7204,9 +7208,13 @@ static void check_preempt_wakeup(struct rq *rq, struct task_struct *p, int wake_
int scale = cfs_rq->nr_running >= sched_nr_latency;
int next_buddy_marked = 0;
int cse_is_idle, pse_is_idle;
bool ignore = false;
if (unlikely(se == pse))
return;
trace_android_rvh_check_preempt_wakeup_ignore(curr, &ignore);
if (ignore)
return;
/*
* This is possible from callers such as attach_tasks(), in which we
@ -7333,6 +7341,7 @@ pick_next_task_fair(struct rq *rq, struct task_struct *prev, struct rq_flags *rf
struct sched_entity *se;
struct task_struct *p;
int new_tasks;
bool repick = false;
again:
if (!sched_fair_runnable(rq))
@ -7386,6 +7395,7 @@ pick_next_task_fair(struct rq *rq, struct task_struct *prev, struct rq_flags *rf
} while (cfs_rq);
p = task_of(se);
trace_android_rvh_replace_next_task_fair(rq, &p, &se, &repick, false);
/*
* Since we haven't yet done put_prev_entity and if the selected task
@ -7419,6 +7429,10 @@ pick_next_task_fair(struct rq *rq, struct task_struct *prev, struct rq_flags *rf
if (prev)
put_prev_task(rq, prev);
trace_android_rvh_replace_next_task_fair(rq, &p, &se, &repick, true);
if (repick)
goto done;
do {
se = pick_next_entity(cfs_rq, NULL);
set_next_entity(cfs_rq, se);

View File

@ -2249,6 +2249,7 @@ build_sched_domains(const struct cpumask *cpu_map, struct sched_domain_attr *att
pr_info("root domain span: %*pbl (max cpu_capacity = %lu)\n",
cpumask_pr_args(cpu_map), rq->rd->max_cpu_capacity);
}
trace_android_vh_build_sched_domains(has_asym);
ret = 0;
error: