ANDROID: sched/cpuset: Add vendor hook to change tasks affinity
Vendors might want to change tasks affinity settings when they are moving from one cpuset into the other. Add vendor hook to give control to vendor to implement what they need. Bug: 174125747 Change-Id: Icee0405be0bca432002dae4a26ebe945082ce052 Signed-off-by: Satya Durga Srinivasu Prabhala <satyap@codeaurora.org>
This commit is contained in:
parent
f34f38632f
commit
4d1ac6a160
@ -85,3 +85,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_set_sugov_sched_attr);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_set_iowait);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_set_sugov_update);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_sched_setaffinity);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_update_cpus_allowed);
|
||||
|
@ -119,6 +119,11 @@ DECLARE_RESTRICTED_HOOK(android_rvh_set_sugov_update,
|
||||
DECLARE_RESTRICTED_HOOK(android_rvh_sched_setaffinity,
|
||||
TP_PROTO(struct task_struct *p, const struct cpumask *in_mask, int *retval),
|
||||
TP_ARGS(p, in_mask, retval), 1);
|
||||
|
||||
DECLARE_RESTRICTED_HOOK(android_rvh_update_cpus_allowed,
|
||||
TP_PROTO(struct task_struct *p, cpumask_var_t cpus_requested,
|
||||
const struct cpumask *new_mask, int *ret),
|
||||
TP_ARGS(p, cpus_requested, new_mask, ret), 1);
|
||||
#else
|
||||
#define trace_android_rvh_select_task_rq_fair(p, prev_cpu, sd_flag, wake_flags, new_cpu)
|
||||
#define trace_android_rvh_select_task_rq_rt(p, prev_cpu, sd_flag, wake_flags, new_cpu)
|
||||
@ -145,6 +150,7 @@ DECLARE_RESTRICTED_HOOK(android_rvh_sched_setaffinity,
|
||||
#define trace_android_rvh_set_iowait(p, should_iowait_boost)
|
||||
#define trace_android_rvh_set_sugov_update(sg_policy, next_freq, should_update)
|
||||
#define trace_android_rvh_sched_setaffinity(p, in_mask, retval)
|
||||
#define trace_android_rvh_update_cpus_allowed(p, cpus_requested, new_mask, ret)
|
||||
#endif
|
||||
#endif /* _TRACE_HOOK_SCHED_H */
|
||||
/* This part must be outside protection */
|
||||
|
@ -66,6 +66,8 @@
|
||||
#include <linux/cgroup.h>
|
||||
#include <linux/wait.h>
|
||||
|
||||
#include <trace/hooks/sched.h>
|
||||
|
||||
DEFINE_STATIC_KEY_FALSE(cpusets_pre_enable_key);
|
||||
DEFINE_STATIC_KEY_FALSE(cpusets_enabled_key);
|
||||
|
||||
@ -1021,6 +1023,18 @@ void rebuild_sched_domains(void)
|
||||
put_online_cpus();
|
||||
}
|
||||
|
||||
static int update_cpus_allowed(struct cpuset *cs, struct task_struct *p,
|
||||
const struct cpumask *new_mask)
|
||||
{
|
||||
int ret = -EINVAL;
|
||||
|
||||
trace_android_rvh_update_cpus_allowed(p, cs->cpus_requested, new_mask, &ret);
|
||||
if (!ret)
|
||||
return ret;
|
||||
|
||||
return set_cpus_allowed_ptr(p, new_mask);
|
||||
}
|
||||
|
||||
/**
|
||||
* update_tasks_cpumask - Update the cpumasks of tasks in the cpuset.
|
||||
* @cs: the cpuset in which each task's cpus_allowed mask needs to be changed
|
||||
@ -1036,7 +1050,7 @@ static void update_tasks_cpumask(struct cpuset *cs)
|
||||
|
||||
css_task_iter_start(&cs->css, 0, &it);
|
||||
while ((task = css_task_iter_next(&it)))
|
||||
set_cpus_allowed_ptr(task, cs->effective_cpus);
|
||||
update_cpus_allowed(cs, task, cs->effective_cpus);
|
||||
css_task_iter_end(&it);
|
||||
}
|
||||
|
||||
@ -2188,7 +2202,7 @@ static void cpuset_attach(struct cgroup_taskset *tset)
|
||||
* can_attach beforehand should guarantee that this doesn't
|
||||
* fail. TODO: have a better way to handle failure here
|
||||
*/
|
||||
WARN_ON_ONCE(set_cpus_allowed_ptr(task, cpus_attach));
|
||||
WARN_ON_ONCE(update_cpus_allowed(cs, task, cpus_attach));
|
||||
|
||||
cpuset_change_task_nodemask(task, &cpuset_attach_nodemask_to);
|
||||
cpuset_update_task_spread_flag(cs, task);
|
||||
|
Loading…
Reference in New Issue
Block a user