ANDROID: sched: add vendor hook to modify affinity

We add vendor hook at __set_cpus_allowed_ptr for modifying the affinity
mask

Bug: 381776407

Change-Id: I5ed4aee3ec12e0d097fd92118ae4bb1325a77533
Signed-off-by: ryan.xiao <ryan.xiao@mediatek.com>
This commit is contained in:
ryan.xiao authored and Treehugger Robot committed 2025-12-04 18:07:01 -08:00
1 parent a4a94617e6
commit 093b79759e
3 files changed
+10 -1

No files matched your search

+6
View File
@@ -339,6 +339,12 @@ struct sched_dl_entity;
DECLARE_HOOK(android_vh_dump_dl_server,
TP_PROTO(struct sched_dl_entity *dl_se, struct task_struct *p),
TP_ARGS(dl_se, p));
struct affinity_context;
DECLARE_RESTRICTED_HOOK(android_rvh_set_cpus_allowed_ptr,
TP_PROTO(struct task_struct *p, struct affinity_context *ctx, bool *skip_user_ptr),
TP_ARGS(p, ctx, skip_user_ptr), 1);
/* macro versions of hooks are no longer required */
#endif /* _TRACE_HOOK_SCHED_H */
+3 -1
View File
@@ -3203,13 +3203,15 @@ int __set_cpus_allowed_ptr(struct task_struct *p, struct affinity_context *ctx)
{
struct rq_flags rf;
struct rq *rq;
bool skip_user_ptr = false;
trace_android_rvh_set_cpus_allowed_ptr(p, ctx, &skip_user_ptr);
rq = task_rq_lock(p, &rf);
/*
* Masking should be skipped if SCA_USER or any of the SCA_MIGRATE_*
* flags are set.
*/
if (p->user_cpus_ptr &&
if (!skip_user_ptr && p->user_cpus_ptr &&
!(ctx->flags & (SCA_USER | SCA_MIGRATE_ENABLE | SCA_MIGRATE_DISABLE)) &&
cpumask_and(rq->scratch_mask, ctx->new_mask, p->user_cpus_ptr))
ctx->new_mask = rq->scratch_mask;
+1
View File
@@ -89,3 +89,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_update_load_avg_se);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_update_load_avg_cfs_rq);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_update_rt_rq_load_avg_internal);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_dump_dl_server);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_set_cpus_allowed_ptr);