linux-yocto/kernel/sched
Andrea Righi 6a32cbe950 sched/ext: Fix invalid task state transitions on class switch
commit ddf7233fcab6c247379d0928d46cc316ee122229 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-08-28 16:34:31 +02:00
..
autogroup.c sched_ext: Fixes for v6.14-rc2 2025-02-14 11:14:24 -08:00
autogroup.h
build_policy.c
build_utility.c sched/debug: Make CONFIG_SCHED_DEBUG functionality unconditional 2025-03-19 22:20:53 +01:00
clock.c
completion.c
core_sched.c sched/debug: Change SCHED_WARN_ON() to WARN_ON_ONCE() 2025-03-19 22:20:53 +01:00
core.c Revert "sched/numa: add statistics of numa balance task" 2025-07-09 21:07:56 -07:00
cpuacct.c
cpudeadline.c
cpudeadline.h
cpufreq_schedutil.c cpufreq/sched: schedutil: Add helper for governor checks 2025-05-07 21:17:56 +02:00
cpufreq.c
cpupri.c
cpupri.h
cputime.c sched/clock: Don't define sched_clock_irqtime as static key 2025-03-10 14:22:58 +01:00
deadline.c sched/deadline: Fix accounting after global limits change 2025-08-20 18:41:09 +02:00
debug.c Revert "sched/numa: add statistics of numa balance task" 2025-07-09 21:07:56 -07:00
ext_idle.c sched_ext: idle: Handle migration-disabled tasks in idle selection 2025-07-17 08:19:38 -10:00
ext_idle.h sched_ext: idle: Explicitly pass allowed cpumask to scx_select_cpu_dfl() 2025-04-07 07:13:52 -10:00
ext.c sched/ext: Fix invalid task state transitions on class switch 2025-08-28 16:34:31 +02:00
ext.h sched_ext, sched/core: Don't call scx_group_set_weight() prematurely from sched_create_group() 2025-06-17 08:19:55 -10:00
fair.c sched/fair: Bump sd->max_newidle_lb_cost when newidle balance fails 2025-08-20 18:41:10 +02:00
features.h
idle.c
isolation.c sched/isolation: Make use of more than one housekeeping cpu 2025-04-08 20:55:55 +02:00
loadavg.c sched: Change nr_uninterruptible type to unsigned long 2025-07-14 10:59:31 +02:00
Makefile tracing: Disable branch profiling in noinstr code 2025-03-22 09:49:26 +01:00
membarrier.c
pelt.c
pelt.h
psi.c sched/psi: Fix psi_seq initialization 2025-08-15 16:39:21 +02:00
rt.c sched/deadline: Fix accounting after global limits change 2025-08-20 18:41:09 +02:00
sched-pelt.h
sched.h sched: Change nr_uninterruptible type to unsigned long 2025-07-14 10:59:31 +02:00
smp.h
stats.c
stats.h sched/debug: Change SCHED_WARN_ON() to WARN_ON_ONCE() 2025-03-19 22:20:53 +01:00
stop_task.c
swait.c
syscalls.c sched: Bypass bandwitdh checks with runtime disabled RT_GROUP_SCHED 2025-04-08 20:55:54 +02:00
topology.c Power management updates for 6.16-rc1 2025-05-27 16:48:47 -07:00
wait_bit.c
wait.c