Commit Graph

1604 Commits

Author SHA1 Message Date
Daniel Hodges
25e1642bbc
scx_layered: Fix stats typo
Small typo fix

Signed-off-by: Daniel Hodges <hodges.daniel.scott@gmail.com>
2024-09-05 14:12:28 -04:00
Tejun Heo
161790f32b
Merge pull request #606 from sched-ext/htejun/misc
meson: Remove unused meson.build and add targeted builds for libs
2024-09-04 09:57:29 -10:00
Tejun Heo
708aaaafb9 meson: Update rust/meson.build
Targeted build is now available for libraries too.
2024-09-04 06:49:55 -10:00
Tejun Heo
f010eda5c0 meson: Remove scheds/rust/*/meson.build
These aren't used since 43950c65 ("build: Use workspace to group rust
sub-projects"). Drop them.
2024-09-04 06:40:17 -10:00
Tejun Heo
4513dfbe4b
Merge pull request #565 from CachyOS/feature/scx-loader
scx_loader: Add scheduler loader via system DBUS interface
2024-09-04 06:34:59 -10:00
Andrea Righi
fe81ccb5bc
Merge pull request #604 from sched-ext/ci-parallel-build
ci: allow parallel builds with meson
2024-09-04 10:28:48 +02:00
Andrea Righi
b9d4ddebc9 ci: allow parallel builds with meson
Now that we have a sane build environment with meson we don't need to
force sequential builds anymore (--jobs=1) and we can just run regular
builds without having to worry about excessive parallelization.

See commit 43950c6 ("build: Use workspace to group rust sub-projects").

Signed-off-by: Andrea Righi <andrea.righi@linux.dev>
2024-09-04 08:57:24 +02:00
Andrea Righi
b34358b0d3
Merge pull request #603 from sched-ext/rustland-core-fix-kthread-stall
scx_rustland_core: fix pcpu kthread stall
2024-09-04 08:29:01 +02:00
Andrea Righi
9ff337a406
Merge pull request #602 from sched-ext/ci-bump-vng-memory
ci: bump up virtme-ng memory size from 1GB to 2GB
2024-09-04 08:28:52 +02:00
Andrea Righi
c3cab45f6a scx_rustland_core: bump up version to 2.0.1
Bump up scx_rustland_core version to include this critical fix that
allows to prevent scheduler stalls:

 94a3594 ("scx_rustland_core: always dispatch per-cpu kthreads directly")

Signed-off-by: Andrea Righi <andrea.righi@linux.dev>
2024-09-04 08:00:25 +02:00
Andrea Righi
94a359434f scx_rustland_core: always dispatch per-cpu kthreads directly
Do not send per-CPU kthreads to the user-space scheduler, but always
dispatch them directly from BPF.

In specific environments, sending critical per-CPU kthreads to the
user-space scheduler can lead to potential stalls. This occurs because
the user-space scheduler might be blocked by an action that these
per-CPU kthreads need to perform, but they cannot complete their action
if the scheduler needs to schedule them, hence the deadlock.

To prevent this deadlock, always dispatch the per-CPU kthreads directly
from the BPF component, ensuring that the user-space scheduler does not
get blocked by these events.

Fixes: c0a2cfb ("scx_rustland_core: always schedule per-CPU kthreads to user-space")
Signed-off-by: Andrea Righi <andrea.righi@linux.dev>
2024-09-04 07:56:58 +02:00
Andrea Righi
ac0cfa32de ci: bump up virtme-ng memory size from 1GB to 2GB
Recently, we have triggered some OOM conditions during stress tests,
particularly with the user-space schedulers. To avoid this issue and
prevent false positives, increase the memory size of the virtme-ng
instance from the default 1GB to 2GB.

Signed-off-by: Andrea Righi <andrea.righi@linux.dev>
2024-09-03 22:46:38 +02:00
Daniel Hodges
9c5717577f
Merge pull request #601 from hodgesds/namespace-helpers
scx_helpers: Add pid namespace helpers
2024-09-03 14:38:26 -04:00
Daniel Hodges
8f4e9e5e3b scx_helpers: Add pid namespace helpers
Add pid namespace helpers for translating namespace pids.

Signed-off-by: Daniel Hodges <hodges.daniel.scott@gmail.com>
2024-09-03 11:21:32 -07:00
Andrea Righi
7dede2d4d7
Merge pull request #599 from sched-ext/scx-rustland-interactive
scx_rustland: aggressively prioritize interactive tasks
2024-09-02 17:43:33 +02:00
Andrea Righi
d0fb29a0f7 scx_rustland: aggressively prioritize interactive tasks
scx_rustland was originally designed as a PoC to showcase the benefits
of implementing specialized schedulers via sched_ext, focusing on a very
specific use case: prioritize game responsiveness regardless of what
runs in the background.

Its original design was subsequently modified to better serve as a
general-purpose scheduler, balancing the prioritization of interactive
tasks with CPU-intensive ones to prevent over-prioritization.

With scx_bpfland serving as a more "general-purpose" scheduler, it makes
sense to revisit scx_rustland's original goal and make it  much more
aggressive at prioritizing interactive tasks, determined in function of
their average amount of context switches.

This change makes scx_rustland again a really good PoC to showcase the
benefits of having specialized schedulers, by focusing only at a very
specific use case: provide a high and stable frames-per-second (fps)
while a kernel build is running in the background.

= Results =

 - Test: Run a WebGL application [1] while building the kernel (make -j32)
 - Hardware: 8-cores Intel 11th Gen Intel(R) Core(TM) i7-1195G7 @ 2.90GHz

  +----------------------+--------+--------+
  |      Scheduler       | avg fps|  stdev |
  +----------------------+--------+--------+
  |               EEVDF  |   28   |  4.00  |
  | scx_rustland-before  |   43   |  1.25  |
  |  scx_rustland-after  |   60   |  0.25  |
  +----------------------+--------+--------+

[1] https://webglsamples.org/aquarium/aquarium.html

Signed-off-by: Andrea Righi <andrea.righi@linux.dev>
2024-09-02 15:53:35 +02:00
Andrea Righi
4fd1ae031b
Merge pull request #573 from sirlucjan/drop-journald
scx_stats: Drop sched-ext namespace
2024-09-02 14:30:28 +02:00
Changwoo Min
172fe1efc6
Merge pull request #597 from multics69/lavd-turbo-tuning2
scx_lavd: misc updates (verifier, README, monitor option name, and micro-optimization)
2024-09-02 18:00:26 +09:00
Changwoo Min
0108b83050 scx_lavd: make the old verifier happy (bpf_cpumask_set_cpu)
An old BPF verifier does not allow calling bpf_cpumask_set_cpu() in the
BPF syscall context, so we defer actual bpf_cpumask_set_cpu() to the
timer handler, update_sys_stat(), to workaround the problem.

Signed-off-by: Changwoo Min <changwoo@igalia.com>
2024-09-02 18:00:12 +09:00
Changwoo Min
3bc2fd4977 scx_lavd: update README
Signed-off-by: Changwoo Min <changwoo@igalia.com>
2024-09-02 18:00:12 +09:00
Changwoo Min
afbebaeed6 scx_lavd: check a core type of previous cpu at pick_idle_cpu()
If a task is performance-critical, pick_idle_cpu() checks if the
previous core is a big core or not. If not, don't try to run on previous
core since a performance-critical task is better to run on a big core.

Signed-off-by: Changwoo Min <changwoo@igalia.com>
2024-09-01 17:28:16 +09:00
Changwoo Min
f2122c4197
Merge pull request #595 from multics69/lavd-turbo-tuning
scx_lavd: improve  the autopilot mode
2024-09-01 16:24:41 +09:00
Andrea Righi
1595445a63
Merge pull request #594 from sched-ext/scx-rustland-core-version-2
scx_rustland_core: bump up major version to 2.0.0
2024-09-01 08:57:32 +02:00
Andrea Righi
bf26d60802
Merge pull request #593 from sched-ext/bpfland-fix-local-kthread
scx_bpfland: directly dispatch only per-cpu kthreads with local_kthreads
2024-09-01 08:57:17 +02:00
Changwoo Min
5ca4501139 scx_lavd: dynamically decide autopilot's low watermark
A single threshold for a low watermark does not work well across systems
with various numbers of cores and core types. Instead of using a single
low watermark value, we dynamically decide the low watermark: 1) until
one little core is fully utilized or 2) until two big cores are fully
utilized. This works better across systems.

Signed-off-by: Changwoo Min <changwoo@igalia.com>
2024-09-01 12:46:57 +09:00
Andrea Righi
0aa71c832b scx_rustland_core: bump up major version to 2.0.0
The scx_rustland_core API has been redesigned recently, breaking the
compatibility with the past.

Considering that Rust crates should update their major version when the
previous API becomes incompatible [1], bump up the version to 2.0.0.

[1] https://semver.org/

Signed-off-by: Andrea Righi <andrea.righi@linux.dev>
2024-08-31 23:23:26 +02:00
Andrea Righi
2cbf252019 scx_bpfland: directly dispatch only per-cpu kthreads with local_kthreads
We want to directly dispatch only kthreads when local_kthreads is
enabled, not all tasks that can run on a single CPU.

Fixes: 7cc1846 ("scx_bpfland: always rely on prev_cpu with single-CPU tasks")
Signed-off-by: Andrea Righi <andrea.righi@linux.dev>
2024-08-31 16:35:54 +02:00
Changwoo Min
4a7b806dd2 scx_lavd: when no_freq_scaling, always set to the max freq
When the no_freq_scaling changes during runtime in the autopilot mode,
the last target freq set would not be 1024. So the performance mode
enabled by the autopilot mode would not run in the best profile. Hence,
we set the target freq to 1024 always when no_freq_scaling is set.

Signed-off-by: Changwoo Min <changwoo@igalia.com>
2024-08-31 18:22:33 +09:00
Daniel Hodges
63a2eecce8
Merge pull request #592 from hodgesds/layered-ts-fixes
scx_layered: Fix layer timeslice not being applied
2024-08-30 15:34:57 -04:00
Daniel Hodges
e04b612688 scx_layered: Fix layer timeslice not being applied
Fix a small bug where the layer timeslice is not applied.

Signed-off-by: Daniel Hodges <hodges.daniel.scott@gmail.com>
2024-08-30 11:53:42 -07:00
Piotr Gorski
cd8b73a48c
Add examples of scx_stats for rusty, rustland, bpfland and lavd
Signed-off-by: Piotr Gorski <lucjan.lucjanov@gmail.com>
2024-08-30 19:54:53 +02:00
Changwoo Min
4d8bf870a1
Merge pull request #591 from multics69/lavd-turbo3
scx_lavd: introduce "autopilot" mode and misc. optimization & bug fix
2024-08-31 02:14:35 +09:00
Andrea Righi
18d0b74f9b
Merge pull request #590 from sched-ext/rustland-scx-stats
scx_rustland: convert to scx_stats
2024-08-30 19:10:15 +02:00
Piotr Gorski
e14dae7270
Update README.md
Signed-off-by: Piotr Gorski <lucjan.lucjanov@gmail.com>
2024-08-30 18:54:52 +02:00
Andrea Righi
f782467eaf scx_rustland: convert to scx_stats
This allows scx_rustland to avoid generating excessive logs for
statistics while still allowing detailed monitoring on demand.

Signed-off-by: Andrea Righi <andrea.righi@linux.dev>
2024-08-30 18:32:32 +02:00
Changwoo Min
9091dd983b scx_lavd: add "--autopilot" mode
Add "--autopilot" option and mode. In the autopilot mode, the scheduler
dynamically changes its power mode according to system's load (cpu
utilization). When the cpu utilization is low enough (say <=5%), it
switches to the powersave mode since there is nothing to process fast so
powersaving is the primary goal. When the utilization is moderate (say
>5%, <=30%), it runs in balanced mode. When the utilization is high
enough (say >30%), it runs in performance mode.

Note that it only changes scheduler's power mode but it does not change
system's energy profile.

Signed-off-by: Changwoo Min <changwoo@igalia.com>
2024-08-31 01:14:33 +09:00
Changwoo Min
5ecaa9ebe2 scx_lavd: improve the accuracy of cpu utilization calculation
When a cpu is idle for a whole interval, its idle time does not
correctlyh adds up so the utilization of such cpu tends to be higher
than the actual utilization. Now it is fixedk, so cpu utilization
becomes more accurate.

Signed-off-by: Changwoo Min <changwoo@igalia.com>
2024-08-31 01:14:33 +09:00
Changwoo Min
2f8cc0d60f scx_lavd: rename the "--auto" opetion to "--autopower" to be clear
Signed-off-by: Changwoo Min <changwoo@igalia.com>
2024-08-31 01:14:33 +09:00
Changwoo Min
815f1263b2 scx_lavd: reinitialize active cpumask when power mode changes
When the power mode changes back to performance mode, we should
active/overflow cpumask to its initial state -- all big cores are in
active cpumask and all little cores are in overflow cpumask. Otherwise,
the active/overflow cpumasks will be used in the perfformance mode.

Signed-off-by: Changwoo Min <changwoo@igalia.com>
2024-08-31 01:14:33 +09:00
Changwoo Min
afb8c78a09 scx_lavd: print power mode change in the auto mode
Signed-off-by: Changwoo Min <changwoo@igalia.com>
2024-08-31 01:14:33 +09:00
Changwoo Min
a89a56dba4 scx_lavd: add a fastpath in ops.select_cpu() for a sharply pinned task
If a task can be run only on a single cpu, we don't need to go through
all the steps in ops.select_cpu(). Instread, we simply check if a task
is still pinned on the prev_cpu and go.

Signed-off-by: Changwoo Min <changwoo@igalia.com>
2024-08-31 01:14:33 +09:00
Andrea Righi
b54fc202b8
Merge pull request #583 from sched-ext/bpfland-fix-pcpu-direct-dispatch
scx_bpfland: always rely on prev_cpu with single-CPU tasks
2024-08-30 18:12:59 +02:00
Andrea Righi
7cc18460b9 scx_bpfland: always rely on prev_cpu with single-CPU tasks
When selecting an idle for tasks that can only run on a single CPU,
always check if the previously used CPU is sill usable, instead of
trying to figure out the single allowed CPU looking at the task's
cpumask.

Apparently, single-CPU tasks can report a prev_cpu that is not in the
allowed cpumask when they rapidly change affinity.

This could lead to stalls, because we may end up dispatching the kthread
to a per-CPU DSQ that is not compatible with its allowed cpumask.

Example:

kworker/u32:2[173797] triggered exit kind 1026:
  runnable task stall (kworker/2:1[70] failed to run for 7.552s)
...
  R kworker/2:1[70] -7552ms
      scx_state/flags=3/0x9 dsq_flags=0x1 ops_state/qseq=0/0
      sticky/holding_cpu=-1/-1 dsq_id=0x8 dsq_vtime=234483011369
      cpus=04

In this case kworker/2 can only run on CPU #2 (cpus=0x4), but it's
dispatched to dsq_id=0x8, that can only be consumed by CPU 8 => stall.

To prevent this, do not try to figure out the best idle CPU for tasks
that are changing affinity and just dispatch them to a global DSQ
(either priority or regular, depending on its interactive state).

Moreover, introduce an explicit error check in dispatch_direct_cpu() to
improve detection of similar issues in the future, and drop
lookup_task_ctx() in favor of try_lookup_task_ctx(), since we can now
safely handle all the cases where the task context is not found.

Signed-off-by: Andrea Righi <andrea.righi@linux.dev>
2024-08-30 09:45:58 +02:00
Changwoo Min
3e2e78a9ec
Merge pull request #584 from multics69/lavd-turbo2
scx_lavd: automatically determine power mode and more
2024-08-30 08:56:16 +09:00
Daniel Hodges
47184e9d19
Merge pull request #582 from hodgesds/layered-growth-interface
scx_layered: Add layer growth config
2024-08-29 18:49:59 -04:00
Vladislav Nepogodin
4d770e1f84
scx_loader: Add scheduler loader via system DBUS interface 2024-08-30 00:56:27 +04:00
Daniel Hodges
36e81f81d7
Merge pull request #585 from hodgesds/topo-node-cores
scx_utils: Add cores helper to node topology
2024-08-29 14:07:38 -04:00
Daniel Hodges
0c8dc43239
Merge pull request #586 from hodgesds/versitat-fixes
ci: Remove veristat diff workflow
2024-08-29 14:06:39 -04:00
Daniel Hodges
a3ae127194 ci: Remove veristat diff workflow
The veristat diff action isn't working properly so remove it for now.
Instead, run veristat (non diff mode) as part of the build-scheds
workflow. This should still provide some useful data for BPF program
related stats.

Signed-off-by: Daniel Hodges <hodges.daniel.scott@gmail.com>
2024-08-29 05:50:06 -07:00
Daniel Hodges
f0c9a3932d scx_utils: Add cores helper to node topology
Add a helper for getting the cores per node.

Signed-off-by: Daniel Hodges <hodges.daniel.scott@gmail.com>
2024-08-29 05:21:56 -07:00