linux/kernel/sched
Tejun Heo 60c27fb59f sched_ext: Implement sched_ext_ops.cpu_online/offline()
Add ops.cpu_online/offline() which are invoked when CPUs come online and
offline respectively. As the enqueue path already automatically bypasses
tasks to the local dsq on a deactivated CPU, BPF schedulers are guaranteed
to see tasks only on CPUs which are between online() and offline().

If the BPF scheduler doesn't implement ops.cpu_online/offline(), the
scheduler is automatically exited with SCX_ECODE_RESTART |
SCX_ECODE_RSN_HOTPLUG. Userspace can implement CPU hotpplug support
trivially by simply reinitializing and reloading the scheduler.

scx_qmap is updated to print out online CPUs on hotplug events. Other
schedulers are updated to restart based on ecode.

v3: - The previous implementation added @reason to
      sched_class.rq_on/offline() to distinguish between CPU hotplug events
      and topology updates. This was buggy and fragile as the methods are
      skipped if the current state equals the target state. Instead, add
      scx_rq_[de]activate() which are directly called from
      sched_cpu_de/activate(). This also allows ops.cpu_on/offline() to
      sleep which can be useful.

    - ops.dispatch() could be called on a CPU that the BPF scheduler was
      told to be offline. The dispatch patch is updated to bypass in such
      cases.

v2: - To accommodate lock ordering change between scx_cgroup_rwsem and
      cpus_read_lock(), CPU hotplug operations are put into its own SCX_OPI
      block and enabled eariler during scx_ope_enable() so that
      cpus_read_lock() can be dropped before acquiring scx_cgroup_rwsem.

    - Auto exit with ECODE added.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-by: David Vernet <dvernet@meta.com>
Acked-by: Josh Don <joshdon@google.com>
Acked-by: Hao Luo <haoluo@google.com>
Acked-by: Barret Rhoden <brho@google.com>
2024-06-18 10:09:20 -10:00
..
autogroup.c scheduler: Remove the now superfluous sentinel elements from ctl_table array 2024-04-24 09:43:54 +02:00
autogroup.h sched/headers: Add header guard to kernel/sched/stats.h and kernel/sched/autogroup.h 2022-02-23 08:22:00 +01:00
build_policy.c sched_ext: Add sysrq-S which disables the BPF scheduler 2024-06-18 10:09:18 -10:00
build_utility.c sched/headers: Remove duplicate header inclusions 2023-10-03 21:27:55 +02:00
clock.c sched: Fix spelling in comments 2024-05-27 17:00:21 +02:00
completion.c sched: add a few helpers to wake up tasks on the current cpu 2023-07-17 16:08:08 -07:00
core_sched.c sched: Fix spelling in comments 2024-05-27 17:00:21 +02:00
core.c sched_ext: Implement sched_ext_ops.cpu_online/offline() 2024-06-18 10:09:20 -10:00
cpuacct.c Merge branch 'sched/fast-headers' into sched/core 2022-03-15 09:05:05 +01:00
cpudeadline.c sched/topology: Consolidate and clean up access to a CPU's max compute capacity 2023-10-09 12:59:48 +02:00
cpudeadline.h
cpufreq_schedutil.c sched/fair: Fix frequency selection for non-invariant case 2024-01-16 10:41:25 +01:00
cpufreq.c sched/headers: Introduce kernel/sched/build_utility.c and build multiple .c files there 2022-02-23 10:58:33 +01:00
cpupri.c sched/rt: Fix live lock between select_fallback_rq() and RT push 2023-09-28 22:58:13 +02:00
cpupri.h
cputime.c sched: Fix spelling in comments 2024-05-27 17:00:21 +02:00
deadline.c sched: Fix spelling in comments 2024-05-27 17:00:21 +02:00
debug.c sched_ext: Implement BPF extensible scheduler class 2024-06-18 10:09:17 -10:00
ext.c sched_ext: Implement sched_ext_ops.cpu_online/offline() 2024-06-18 10:09:20 -10:00
ext.h sched_ext: Implement sched_ext_ops.cpu_online/offline() 2024-06-18 10:09:20 -10:00
fair.c sched: Add normal_policy() 2024-06-18 10:09:17 -10:00
features.h sched/fair: Remove SCHED_FEAT(UTIL_EST_FASTUP, true) 2023-12-23 15:59:56 +01:00
idle.c sched_ext: Add boilerplate for extensible scheduler class 2024-06-18 10:09:17 -10:00
isolation.c sched/isolation: Fix boot crash when maxcpus < first housekeeping CPU 2024-04-28 10:08:21 +02:00
loadavg.c sched: Fix spelling in comments 2024-05-27 17:00:21 +02:00
Makefile sched/headers: Introduce kernel/sched/build_policy.c and build multiple .c files there 2022-02-23 10:58:33 +01:00
membarrier.c RISC-V Patches for the 6.9 Merge Window 2024-03-22 10:41:13 -07:00
pelt.c sched: Fix spelling in comments 2024-05-27 17:00:21 +02:00
pelt.h sched/cpufreq: Rename arch_update_thermal_pressure() => arch_update_hw_pressure() 2024-04-24 12:08:01 +02:00
psi.c sched: Fix spelling in comments 2024-05-27 17:00:21 +02:00
rt.c sched: Fix spelling in comments 2024-05-27 17:00:21 +02:00
sched-pelt.h
sched.h sched_ext: Implement sched_ext_ops.cpu_online/offline() 2024-06-18 10:09:20 -10:00
smp.h sched, smp: Trace smp callback causing an IPI 2023-03-24 11:01:29 +01:00
stats.c sched/debug: Increase SCHEDSTAT_VERSION to 16 2024-03-12 11:03:40 +01:00
stats.h sched: Fix spelling in comments 2024-05-27 17:00:21 +02:00
stop_task.c sched: Unify runtime accounting across classes 2023-11-15 09:57:48 +01:00
swait.c sched: add a few helpers to wake up tasks on the current cpu 2023-07-17 16:08:08 -07:00
syscalls.c sched_ext: Allow BPF schedulers to disallow specific tasks from joining SCHED_EXT 2024-06-18 10:09:18 -10:00
topology.c sched: Fix spelling in comments 2024-05-27 17:00:21 +02:00
wait_bit.c sched: Fix spelling in comments 2024-05-27 17:00:21 +02:00
wait.c sched: remove wait bookmarks 2023-10-18 14:34:18 -07:00