From 59be6c5a2667cc35ec97184f1d287055620663b4 Mon Sep 17 00:00:00 2001 From: ZhiFeng Gao Date: Sun, 17 Aug 2025 11:16:48 +0800 Subject: [PATCH] ANDROID: Move SCX_OPS_DISABLING VH inside the scx_fork_rwsem section We found a stability issue in current code of scx_ops_disable_workfn founction. When SCX_OPS_DISABLING VH is invoked, system may keeps forking fair tasks. In this circumstances, if scx_ops_disable_workfn is blocked by scx_fork_rwsem, it may never running again because the task who invoking scx_ops_disable_workfn is scx task. So we move the SCX_OPS_DISABLING VH inside scx_fork_rwsem section. This patchset ensures that if the scx task who invoking scx_ops_disable_workfn is blocked by scx_fork_rwsem, the system will not produce fair task. This can avoid the stability issue caused in scx disabling process. Bug: 439095466 Bug: 454747318 Change-Id: I16e67e868d8ba1a7f14309eab64b7d5d781e5ca9 Signed-off-by: ZhiFeng Gao (cherry picked from commit ad3375325ca2ff7356bdea0adec021abc29e23ff) --- kernel/sched/ext.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c index a56fac61ce5b..aae730f457e5 100644 --- a/kernel/sched/ext.c +++ b/kernel/sched/ext.c @@ -4645,7 +4645,6 @@ static void scx_ops_disable_workfn(struct kthread_work *work) default: break; } - trace_android_vh_scx_ops_enable_state(SCX_OPS_DISABLING); /* * Here, every runnable task is guaranteed to make forward progress and @@ -4670,6 +4669,7 @@ static void scx_ops_disable_workfn(struct kthread_work *work) * must be switched out and exited synchronously. */ percpu_down_write(&scx_fork_rwsem); + trace_android_vh_scx_ops_enable_state(SCX_OPS_DISABLING); scx_ops_init_task_enabled = false;