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

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 Todd Kjos
parent cb3efba1de
commit 8979a0b16a
3 changed files with 16 additions and 1 deletions

View File

@@ -339,6 +339,14 @@ DECLARE_HOOK(android_vh_map_util_freq,
bool *need_freq_update),
TP_ARGS(util, freq, cap, next_freq, policy, need_freq_update));
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

@@ -2595,6 +2595,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
@@ -8284,7 +8285,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();
@@ -8313,6 +8315,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

@@ -87,3 +87,5 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_find_new_ilb);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_find_energy_efficient_cpu);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sched_pelt_multiplier);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_map_util_freq);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_set_cpus_allowed_comm);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sched_setaffinity_early);