Skip to content

Commit 4425c3e

Browse files
Tengfei FanJian Zhou
authored andcommitted
ANDROID: sched/scx: Add vendor hook to update task's data when switching to scx
Vendor might want to change task's data when they are moved from other sched_class to scx sched_class. Add vendor hook to give control to vendor to implement what they need. The vendor may have its own scheduling algorithm that can coexist with SCX and manages all other scheduler sched_class (except the SCX sched_class). When SCX is enabled, some tasks(such as all fair tasks) are migrated from other sched_class (managed by the vendor's algorithm) to the SCX sched_class. During this migration, it's necessary to reset the vendor scheduler's historical data for these tasks. Otherwise, inconsistencies in the data may cause a panic. This is because, depending on the scenario, some tasks may frequently switch between the SCX sched_class and other sched_class (such as the RT sched_class). If a task switches back from the SCX sched_class to another sched_class while still retaining outdated data from the vendor scheduler, the desynchronization may trigger a panic. Bug: 436479714 Bug: 438048008 Change-Id: Ib148c7a3bfc9a8af6ec76d14f3936850033564e1 Signed-off-by: Tengfei Fan <quic_tengfan@quicinc.com> Signed-off-by: Srinivasarao Pathipati <quic_c_spathi@quicinc.com> (cherry picked from commit f53b32f7290958fe1e4f03a300c8e1f860e8b3f3)
1 parent 2812715 commit 4425c3e

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

include/trace/hooks/sched.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,10 @@ DECLARE_HOOK(android_vh_scx_task_switch_finish,
422422
TP_PROTO(struct task_struct *p, int enable),
423423
TP_ARGS(p, enable));
424424

425+
DECLARE_HOOK(android_vh_switching_to_scx,
426+
TP_PROTO(struct rq *rq, struct task_struct *p),
427+
TP_ARGS(rq, p));
428+
425429
struct sugov_policy;
426430
DECLARE_RESTRICTED_HOOK(android_rvh_set_sugov_update,
427431
TP_PROTO(struct sugov_policy *sg_policy, unsigned int next_freq, bool *should_update),

kernel/sched/ext.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3861,6 +3861,8 @@ static void switching_to_scx(struct rq *rq, struct task_struct *p)
38613861
if (SCX_HAS_OP(set_cpumask))
38623862
SCX_CALL_OP_TASK(SCX_KF_REST, set_cpumask, p,
38633863
(struct cpumask *)p->cpus_ptr);
3864+
3865+
trace_android_vh_switching_to_scx(rq, p);
38643866
}
38653867

38663868
static void switched_from_scx(struct rq *rq, struct task_struct *p)

kernel/sched/vendor_hooks.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_scx_ops_enable_state);
111111
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_scx_enabled);
112112
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_scx_set_cpus_allowed);
113113
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_scx_task_switch_finish);
114+
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_switching_to_scx);
114115
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_set_sugov_update);
115116
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_update_rq_clock_pelt);
116117
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_update_load_avg_blocked_se);

0 commit comments

Comments
 (0)