Commit 3c06e9ad authored by Andrea Righi's avatar Andrea Righi Committed by Greg Kroah-Hartman
Browse files

sched_ext: initialize built-in idle state before ops.init()



commit f0c6eab5 upstream.

A BPF scheduler may want to use the built-in idle cpumasks in ops.init()
before the scheduler is fully initialized, either directly or through a
BPF timer for example.

However, this would result in an error, since the idle state has not
been properly initialized yet.

This can be easily verified by modifying scx_simple to call
scx_bpf_get_idle_cpumask() in ops.init():

$ sudo scx_simple

DEBUG DUMP
===========================================================================

scx_simple[121] triggered exit kind 1024:
  runtime error (built-in idle tracking is disabled)
...

Fix this by properly initializing the idle state before ops.init() is
called. With this change applied:

$ sudo scx_simple
local=2 global=0
local=19 global=11
local=23 global=11
...

Fixes: d73249f8 ("sched_ext: idle: Make idle static keys private")
Signed-off-by: default avatarAndrea Righi <arighi@nvidia.com>
Reviewed-by: default avatarJoel Fernandes <joelagnelf@nvidia.com>
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
[ Backport to 6.12:
  - Original commit doesn't apply cleanly to 6.12 since d73249f8 is
    not present.
  - This backport applies the same logical fix to prevent BPF scheduler
    failures while accessing idle cpumasks from ops.init(). ]
Signed-off-by: default avatarAndrea Righi <arighi@nvidia.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3c0d35b3
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment