ANDROID: sched: Add vendor hooks for cpu affinity.

Add vendor hooks for CPU affinity to support OEM's tuning policy, where
we can block or unblock a certain type of application's CPU affinity.

Bug: 183674818
Bug: 283222331

Signed-off-by: lijianzhong <lijianzhong@xiaomi.com>
Change-Id: I3402abec4d9faa08f564409bfb8db8d7902f3aa2
(cherry picked from commit 7cf9646c245fdc63e2a3c9fad457c11fabdd2dfc)
This commit is contained in:
lijianzhong
2021-03-24 15:44:55 +08:00
committed by Qiankun Wang
parent 53a5908faa
commit 555f3fe563
3 changed files with 16 additions and 1 deletions

View File

@@ -436,6 +436,14 @@ DECLARE_RESTRICTED_HOOK(android_rvh_update_rt_rq_load_avg,
TP_PROTO(u64 now, struct rq *rq, struct task_struct *tsk, int running),
TP_ARGS(now, rq, tsk, running), 1);
DECLARE_RESTRICTED_HOOK(android_rvh_set_cpus_allowed_comm,
TP_PROTO(struct task_struct *p, const struct cpumask *new_mask),
TP_ARGS(p, new_mask), 1);
DECLARE_HOOK(android_vh_sched_setaffinity_early,
TP_PROTO(struct task_struct *p, const struct cpumask *new_mask, bool *retval),
TP_ARGS(p, new_mask, retval));
/* macro versions of hooks are no longer required */
#endif /* _TRACE_HOOK_SCHED_H */

View File

@@ -2524,6 +2524,7 @@ void set_cpus_allowed_common(struct task_struct *p, const struct cpumask *new_ma
cpumask_copy(&p->cpus_mask, new_mask);
p->nr_cpus_allowed = cpumask_weight(new_mask);
trace_android_rvh_set_cpus_allowed_comm(p, new_mask);
}
static void
@@ -8205,7 +8206,8 @@ out_free_cpus_allowed:
long sched_setaffinity(pid_t pid, const struct cpumask *in_mask)
{
struct task_struct *p;
int retval;
int retval = 0;
bool skip = false;
rcu_read_lock();
@@ -8234,6 +8236,9 @@ long sched_setaffinity(pid_t pid, const struct cpumask *in_mask)
rcu_read_unlock();
}
trace_android_vh_sched_setaffinity_early(p, in_mask, &skip);
if (skip)
goto out_put_task;
retval = security_task_setscheduler(p);
if (retval)
goto out_put_task;

View File

@@ -107,3 +107,5 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_remove_entity_load_avg);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_update_blocked_fair);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_update_rt_rq_load_avg);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_set_cpus_allowed_by_task);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_set_cpus_allowed_comm);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sched_setaffinity_early);