ANDROID: sched: Add vendor hook for cpu distribution functions

Vendor may have the need to implement their cpu distribution functions.

Bug: 233279911
Signed-off-by: chungkai <chungkai@google.com>
Change-Id: I46f4be9570819d170d6e0bd82cf3a2cac68c96ef
This commit is contained in:
chungkai
2022-05-26 06:15:27 +00:00
committed by Todd Kjos
parent a08f978392
commit 19e41a3404
3 changed files with 14 additions and 4 deletions

View File

@@ -401,3 +401,4 @@ 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_pci_d3_sleep);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_update_rq_clock_pelt);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_cpumask_any_and_distribute);

View File

@@ -337,6 +337,11 @@ DECLARE_HOOK(android_vh_sched_setaffinity_early,
TP_PROTO(struct task_struct *p, const struct cpumask *new_mask, int *retval),
TP_ARGS(p, new_mask, retval));
DECLARE_RESTRICTED_HOOK(android_rvh_cpumask_any_and_distribute,
TP_PROTO(struct task_struct *p, const struct cpumask *cpu_valid_mask ,
const struct cpumask *new_mask, int *dest_cpu),
TP_ARGS(p, cpu_valid_mask, new_mask, dest_cpu), 1);
DECLARE_HOOK(android_vh_free_task,
TP_PROTO(struct task_struct *p),
TP_ARGS(p));

View File

@@ -1984,7 +1984,7 @@ static int __set_cpus_allowed_ptr_locked(struct task_struct *p,
{
const struct cpumask *cpu_valid_mask = cpu_active_mask;
const struct cpumask *cpu_allowed_mask = task_cpu_possible_mask(p);
unsigned int dest_cpu;
unsigned int dest_cpu = nr_cpu_ids;
int ret = 0;
update_rq_clock(rq);
@@ -2016,10 +2016,14 @@ static int __set_cpus_allowed_ptr_locked(struct task_struct *p,
* for groups of tasks (ie. cpuset), so that load balancing is not
* immediately required to distribute the tasks within their new mask.
*/
dest_cpu = cpumask_any_and_distribute(cpu_valid_mask, new_mask);
trace_android_rvh_cpumask_any_and_distribute(p, cpu_valid_mask, new_mask, &dest_cpu);
if (dest_cpu >= nr_cpu_ids) {
ret = -EINVAL;
goto out;
dest_cpu = cpumask_any_and_distribute(cpu_valid_mask, new_mask);
if (dest_cpu >= nr_cpu_ids) {
ret = -EINVAL;
goto out;
}
}
do_set_cpus_allowed(p, new_mask);