2
0
mirror of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git synced 2025-09-04 20:19:47 +08:00
linux/kernel/sched
Andrea Righi ddf7233fca sched/ext: Fix invalid task state transitions on class switch
When enabling a sched_ext scheduler, we may trigger invalid task state
transitions, resulting in warnings like the following (which can be
easily reproduced by running the hotplug selftest in a loop):

 sched_ext: Invalid task state transition 0 -> 3 for fish[770]
 WARNING: CPU: 18 PID: 787 at kernel/sched/ext.c:3862 scx_set_task_state+0x7c/0xc0
 ...
 RIP: 0010:scx_set_task_state+0x7c/0xc0
 ...
 Call Trace:
  <TASK>
  scx_enable_task+0x11f/0x2e0
  switching_to_scx+0x24/0x110
  scx_enable.isra.0+0xd14/0x13d0
  bpf_struct_ops_link_create+0x136/0x1a0
  __sys_bpf+0x1edd/0x2c30
  __x64_sys_bpf+0x21/0x30
  do_syscall_64+0xbb/0x370
  entry_SYSCALL_64_after_hwframe+0x77/0x7f

This happens because we skip initialization for tasks that are already
dead (with their usage counter set to zero), but we don't exclude them
during the scheduling class transition phase.

Fix this by also skipping dead tasks during class swiching, preventing
invalid task state transitions.

Fixes: a8532fac7b ("sched_ext: TASK_DEAD tasks must be switched into SCX on ops_enable")
Cc: stable@vger.kernel.org # v6.12+
Signed-off-by: Andrea Righi <arighi@nvidia.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
2025-08-11 06:56:37 -10:00
..
autogroup.c sched: Clean up and standardize #if/#else/#endif markers in sched/autogroup.[ch] 2025-06-13 08:47:14 +02:00
autogroup.h sched: Clean up and standardize #if/#else/#endif markers in sched/autogroup.[ch] 2025-06-13 08:47:14 +02:00
build_policy.c sched/smp: Make SMP unconditional 2025-06-13 08:47:18 +02:00
build_utility.c sched/smp: Make SMP unconditional 2025-06-13 08:47:18 +02:00
clock.c sched: Clean up and standardize #if/#else/#endif markers in sched/clock.c 2025-06-13 08:47:14 +02:00
completion.c sched: Make clangd usable 2025-06-11 11:20:53 +02:00
core_sched.c sched: Make clangd usable 2025-06-11 11:20:53 +02:00
core.c sched_ext: Changes for v6.17 2025-07-31 16:29:46 -07:00
cpuacct.c sched: Make clangd usable 2025-06-11 11:20:53 +02:00
cpudeadline.c sched: Make clangd usable 2025-06-11 11:20:53 +02:00
cpudeadline.h sched/smp: Make SMP unconditional 2025-06-13 08:47:18 +02:00
cpufreq_schedutil.c sched: Clean up and standardize #if/#else/#endif markers in sched/cpufreq_schedutil.c 2025-06-13 08:47:15 +02:00
cpufreq.c sched: Make clangd usable 2025-06-11 11:20:53 +02:00
cpupri.c sched: Make clangd usable 2025-06-11 11:20:53 +02:00
cpupri.h sched/smp: Make SMP unconditional 2025-06-13 08:47:18 +02:00
cputime.c sched: Clean up and standardize #if/#else/#endif markers in sched/cputime.c 2025-06-13 08:47:15 +02:00
deadline.c sched: Fix proxy/current (push,pull)ability 2025-07-14 17:16:33 +02:00
debug.c Merge branch 'tip/sched/urgent' 2025-07-14 17:16:28 +02:00
ext_idle.c sched_ext: Changes for v6.17 2025-07-31 16:29:46 -07:00
ext_idle.h sched_ext: Always use SMP versions in kernel/sched/ext_idle.h 2025-06-13 14:47:59 -10:00
ext.c sched/ext: Fix invalid task state transitions on class switch 2025-08-11 06:56:37 -10:00
ext.h sched_ext: Add support for cgroup bandwidth control interface 2025-06-20 17:03:51 -10:00
fair.c sched: Start blocked_on chain processing in find_proxy_task() 2025-07-14 17:16:33 +02:00
features.h sched/fair: Untangle NEXT_BUDDY and pick_next_task() 2024-12-09 11:48:13 +01:00
idle.c sched/smp: Use the SMP version of the idle scheduling class 2025-06-13 08:47:21 +02:00
isolation.c sched: Make clangd usable 2025-06-11 11:20:53 +02:00
loadavg.c Merge branch 'tip/sched/urgent' 2025-07-14 17:16:28 +02:00
Makefile tracing: Disable branch profiling in noinstr code 2025-03-22 09:49:26 +01:00
membarrier.c sched: Make clangd usable 2025-06-11 11:20:53 +02:00
pelt.c sched: Clean up and standardize #if/#else/#endif markers in sched/pelt.[ch] 2025-06-13 08:47:17 +02:00
pelt.h sched/smp: Make SMP unconditional 2025-06-13 08:47:18 +02:00
psi.c sched/psi: Fix psi_seq initialization 2025-08-04 10:51:22 -07:00
rt.c sched: Fix proxy/current (push,pull)ability 2025-07-14 17:16:33 +02:00
sched-pelt.h sched: Make clangd usable 2025-06-11 11:20:53 +02:00
sched.h sched_ext: Changes for v6.17 2025-07-31 16:29:46 -07:00
smp.h sched: Make clangd usable 2025-06-11 11:20:53 +02:00
stats.c sched/smp: Use the SMP version of schedstats 2025-06-13 08:47:21 +02:00
stats.h sched: Clean up and standardize #if/#else/#endif markers in sched/stats.[ch] 2025-06-13 08:47:17 +02:00
stop_task.c sched/smp: Use the SMP version of the stop-CPU scheduling class 2025-06-13 08:47:21 +02:00
swait.c sched: Make clangd usable 2025-06-11 11:20:53 +02:00
syscalls.c sched/smp: Use the SMP version of the scheduler syscalls 2025-06-13 08:47:21 +02:00
topology.c sched/topology: Remove sched_domain_topology_level::flags 2025-07-14 10:59:35 +02:00
wait_bit.c sched: Make clangd usable 2025-06-11 11:20:53 +02:00
wait.c ARM: 2025-07-30 17:14:01 -07:00