[Mirror] Some kind of OS: git://git.9front.org/plan9front/plan9front
Find a file
cinap_lenrek 3598b7cf36 kernel: hack processor affinity to allow load sharing
On a multiprocessor, the scheduler can run into
a very unfair distribution of processes to cpus
when there are more long-running processes than cpus.

Say we have a 4 cpu machine and we run 4 long-running
proesses, each cpu will pick up a single process
and each process will get 100% of its fair share.

Everything is good so far.

If we start more long-running processes, all these
processes are going to be picked up by the cpu core
that runs most sporanic / bursty work loads as it
is calling sched() more often.

This results in all the extra long-running prcoesses
to cluster around the same core resulting in very
unfair sharing of load.

The problem is that once a process runs on a cpu,
it stays on that cpu as processor affinity
is never reset.

Process migration only happens when a cpu cannot
find any process to run, given the affinity
constrains, but this can never happen when
the system is under full load and each cpu
always has a low-priority long running
process to run.

How do we fix this?

The idea of this hack is to reset processor
affinity in ready() when its priority changes or,
when it appears to be a long-running process.

That way, we give every cpu a chance to pick
it up and share the load.

This is not a ideal solution of course. Long term,
we should probably have separate runqueues per cpu
and do the balancing explicitely.
2024-07-21 13:44:18 +00:00
386 ape: sync flaot.h macros with u.h 2021-02-08 15:45:11 -08:00
68000 add signed fixed size integer typedefs 2018-05-12 19:19:52 +02:00
68020 ape: sync flaot.h macros with u.h 2021-02-08 15:45:11 -08:00
acme libc, libthread, ape: mark exit functions as _Noreturn and clean up new warnings 2024-01-28 03:36:41 +00:00
adm/timezone libc: correct dst transition times 2024-04-27 02:19:11 +00:00
amd64 libc: change usize to 64-bit for amd64 and arm64, make memory(2) functions use usize 2021-07-25 15:54:22 +00:00
arm ape: sync flaot.h macros with u.h 2021-02-08 15:45:11 -08:00
arm64 libc: change usize to 64-bit for amd64 and arm64, make memory(2) functions use usize 2021-07-25 15:54:22 +00:00
lib /lib/theo: If we can't do it right, we don't do it until we figure out a way to do it right. 2024-05-15 02:00:21 +00:00
mips ape: sync flaot.h macros with u.h 2021-02-08 15:45:11 -08:00
power ape: sync flaot.h macros with u.h 2021-02-08 15:45:11 -08:00
power64 power64: refactor va_arg in u.h to fix warnings 2024-05-12 00:26:37 +00:00
rc history: add support for gefs dumps 2024-07-18 16:49:31 +00:00
sparc ape: sync flaot.h macros with u.h 2021-02-08 15:45:11 -08:00
sparc64 ape: sync flaot.h macros with u.h 2021-02-08 15:45:11 -08:00
spim /spim/include/ape/ureg.h: fixed missing ifndef 2023-03-07 04:26:34 +00:00
sys kernel: hack processor affinity to allow load sharing 2024-07-21 13:44:18 +00:00