Commit Graph

48054 Commits

Author SHA1 Message Date
Pawel Dziepak
d70728f54d kernel/lock: Do not use *_locked() functions when not needed 2013-10-30 03:26:13 +01:00
Pawel Dziepak
d54a9e0a41 kernel: Do not use gSchedulerLock when accesing UID and GID
Reads and writes to uid_t and gid_t are atomic anyway. The only real
problem that may happen here is inconsistent state of triples
effective_{u, g}id, saved_set_{u, g}id, real_{u, g}id, but team locks
protect us against that.
2013-10-30 02:57:45 +01:00
Pawel Dziepak
9c0ff0eed1 kernel: Add cpufreq module for Intel P-states
Since Sandy Bridge managing P-states on Intel processors is much easier
and more powerful than when using previous versions of EIST.
2013-10-30 00:55:03 +01:00
Pawel Dziepak
1e3cf82d85 scheduler: Manage CPU performance 2013-10-30 00:49:24 +01:00
Pawel Dziepak
22d8248267 kernel: Add support and interface for cpufreq modules 2013-10-30 00:48:07 +01:00
Pawel Dziepak
6d96f462dc scheduler: Use load information to migrate threads 2013-10-28 02:44:46 +01:00
Pawel Dziepak
5e2701a2b5 scheduler: Keep track of the load each thread produces 2013-10-28 01:38:54 +01:00
Pawel Dziepak
dc38e6ca87 scheduler: Use core load to distribute threads 2013-10-28 00:39:16 +01:00
Pawel Dziepak
d80cdf504f scheduler: Keep track of core and logical CPU load 2013-10-27 22:39:56 +01:00
Pawel Dziepak
890ba7415c scheduler: Decide whether to cancel thread penalty 2013-10-27 20:05:20 +01:00
Pawel Dziepak
1df2e75540 scheduler: Increase penalty of waiting threads
The fact that thread is waiting doesn't mean that it is nice to the others.
If the thread, indeed, waits for a longer time its penalty will be cancelled
anyway, however if the thread waits for a very short time do not count that
as being nice since lower priority threads didn't have much chance to run.
2013-10-27 18:14:48 +01:00
Pawel Dziepak
45ff530069 scheduler: Be more demanding when cancelling penalties 2013-10-25 04:12:13 +02:00
Pawel Dziepak
9d7e2acf34 scheduler: Update scheduler_set_operation_mode() 2013-10-24 03:24:53 +02:00
Pawel Dziepak
978fc08065 scheduler: Remove support for running different schedulers
Simple scheduler behaves exactly the same as affine scheduler with a
single core. Obviously, affine scheduler is more complicated thus
introduces greater overhead but quite a lot of multicore logic has been
disabled on single core systems in the previous commit.
2013-10-24 02:04:03 +02:00
Pawel Dziepak
e927edd376 scheduler_affine: Disable logic not needed on current topology 2013-10-24 01:33:12 +02:00
Pawel Dziepak
ed8627e535 kernel/util: Fix MinMaxHeap::_GrowHeap() 2013-10-24 00:59:58 +02:00
Pawel Dziepak
7e1ecb9315 kernel: Protect scheduler_set_thread_priority() with lock 2013-10-24 00:59:10 +02:00
Pawel Dziepak
31a75d402f kernel: Protect lock internals with per-lock spinlock 2013-10-24 00:01:18 +02:00
Pawel Dziepak
d6efe8ee75 kernel: Update cpu_ent::active_time atomically 2013-10-23 21:56:14 +02:00
Pawel Dziepak
453bf75027 scheduler_affine: Try not to get overloaded by small tasks 2013-10-23 21:32:27 +02:00
Pawel Dziepak
2df11d8a80 scheduler_affine: Put small tasks on a single core 2013-10-23 01:59:25 +02:00
Pawel Dziepak
4c4994435d kernel/util: Fixes in [MinMax]Heap implementation 2013-10-22 23:56:31 +02:00
Pawel Dziepak
8d471bc3d9 scheduler_affine: Store cores with CPU bound threads separately
This is preparation for small task packing. We want to have as many idle
cores as possible. To achieve that we put all threads on the most heavily
loaded core (so the other ones can become idle). However, we don't really
want to do that if there are CPU bound tasks and if any of the cores
becomes overloaded.
2013-10-22 23:52:40 +02:00
Pawel Dziepak
f823aacf59 scheduler_affine: Remove old code 2013-10-22 01:21:51 +02:00
Pawel Dziepak
2e0ee59462 scheduler_affine: Migrate threads from overloaded cores
* Keep number of CPU bound threads on cores balanced.
 * If possible migrate normal threads from cores with cpu bound ones to
   the less busy cores.
2013-10-22 01:18:03 +02:00
Pawel Dziepak
7aba623f52 scheduler_affine: Balance number of threads assigned to CPUs
When the thread cannot be run immediately assign it to the core with
lowest number of CPU bound threads and assigned threads.
2013-10-21 21:39:40 +02:00
Pawel Dziepak
5cf9b69b49 kernel/util: Minor improvements in Heap and MinMaxHeap
* [MinMax]Heap::ModifyKey(): Do not attempt to move node if the key
   actually hasn't changed.
 * Allow allocating initial array at construction.
2013-10-21 21:24:05 +02:00
Pawel Dziepak
afe1735d7d scheduler_affine: Expire old cache affinities
Performance mode:
 If there have been a lot of activity on the core since the thread went
 sleep its data in cache probably has been overwritten.

Power saving mode:
 If the thread went to sleep a long time ago either there has been a
 lot of activity on its core or the core has been idle and it may
 be more efficient to wake another one.
2013-10-21 19:19:28 +02:00
Pawel Dziepak
7ea42e7add kernel: Remove invoke_scheduler_if_idle 2013-10-21 02:38:57 +02:00
Pawel Dziepak
ea79da9500 kernel: Remove support for thread_queue 2013-10-21 02:30:20 +02:00
Pawel Dziepak
74192fd984 scheduler_affine: Fix compilation warning 2013-10-21 02:21:14 +02:00
Pawel Dziepak
84812e6033 scheduler_affine: Correctly assign CPUs to idle threads 2013-10-21 02:20:09 +02:00
Pawel Dziepak
cd8d4e39fd kernel: Introduce scheduler modes of operation 2013-10-21 02:17:00 +02:00
Pawel Dziepak
4b446279e6 scheduler_affine: Use CPU topology tree to create ID mappings 2013-10-21 01:34:31 +02:00
Pawel Dziepak
343c489689 kernel: Create CPU topology tree 2013-10-21 01:33:35 +02:00
Pawel Dziepak
5cbf227236 kernel/util: Allocate only one array in MinMaxHeap 2013-10-20 23:33:55 +02:00
Pawel Dziepak
a6d4233e59 scheduler_affine: Choose wisely which core to wake up
The longer core is idle the deeper idle state it has entered. That's
why the scheduler should always choose the core that has gone idle
most recently (both for performance and power saving reasons).

Moreover, if there are more than one package the scheduler should
minimize the number of packages with at least one core active when
power saving is the priority. Contrary, as many packages as possible
should be used when aiming for high performance.
2013-10-20 23:26:32 +02:00
Pawel Dziepak
da3a48f4a8 scheduler_affine: Use min-max heap as per-core CPU heap 2013-10-17 19:23:27 +02:00
Pawel Dziepak
18c0d163ed kernel/util: Add MinMaxHeap implementation 2013-10-17 19:22:29 +02:00
Pawel Dziepak
278c9784a1 scheduler_affine: Use global core heap and per-core CPU heaps
There is a global heap of cores, where the key is the highest priority
of threads running on that core. Moreover, for each core there is
a heap of logical processors on this core where the key is the priority
of currently running thread.

The per-core heap is used for load balancing among logical processors
on that core. The global heap is used in initial decision where to put
the thread (note that the algorithm that makes this decision is not
complete yet).
2013-10-17 02:11:28 +02:00
Pawel Dziepak
3ec1d8da42 scheduler_affine: Add logic shared with simple scheduler
The scheduler is in very early stage. There is no thread migration and
the algorithms choosing CPU for thread are very simple.

Since affine scheduler is going to use one run queue per core simple on
single core machines it will work exactly the same as simple scheduler.
That would allow us to have only one scheduler implementation usable
on all kinds of machines.
2013-10-16 23:50:18 +02:00
Pawel Dziepak
824ed26c51 kernel: Fully detect CPU topology before initializing scheduler 2013-10-16 20:02:56 +02:00
Pawel Dziepak
cf863a5040 kernel: Decide whether to use simple or affine scheduler
Simple scheduler is used when we do not have to worry about cache affinity
(i.e. single core with or without SMT, multicore with all cache levels
shared).

When we replace gSchedulerLock with more fine grained locking affine
scheduler should also be chosen when logical CPU count is high (regardless
of cache).
2013-10-16 18:39:25 +02:00
Pawel Dziepak
ebec24f9e0 kernel: Add support for disabling CPUs in scheduler 2013-10-15 02:02:54 +02:00
Pawel Dziepak
3de2c5ceec kernel: Add support for pinned threads 2013-10-15 01:47:28 +02:00
Pawel Dziepak
51d1e9ada0 kernel: Remove scheduler_simple_smp 2013-10-15 00:37:19 +02:00
Pawel Dziepak
f20ad54be2 kernel: Add support for SMP systems to simple scheduler
In SMP systems simple scheduler will be used only when all logical
processors share all levels of cache and the number of CPUs is low.
In such systems we do not have to care about cache affinity and
the contention on the lock protecting shared run queue is low. Single
run queue makes load balancing very simple.
2013-10-15 00:29:04 +02:00
Pawel Dziepak
298314fe4b libroot: Update sched_get_priority_{max, min}()
SCHED_RR is a real-time scheduling policy.
SCHED_FIFO and SCHED_SPORADIC are not supported (at least for now).
2013-10-09 20:57:42 +02:00
Pawel Dziepak
29e65827fd kernel: Remove possibility to yield to all threads
Kernel support for yielding to all (including lower priority) threads
has been removed. POSIX sched_yield() remains unchanged.

If a thread really needs to yield to everyone it can reduce its priority
to the lowest possible and then yield (it will then need to manually
return to its prvious priority upon continuing).
2013-10-09 20:42:34 +02:00
Pawel Dziepak
fee8009184 kernel: Add another penalty for CPU bound threads
Each thread has its minimal priority that depends on the static priority.
However, it is still able to starve threads with even lower priority
(e.g. CPU bound threads with lower static priority). To prevent this
another penalty is introduced. When the minimal priority is reached
penalty (count mod minimal_priority) is added, where count is the number
of time slices since the thread reached its minimal priority. This prevents
starvation of lower priorirt threads (since all CPU bound threads may have
their priority temporaily reduced to 1) but preserves relation between
static priorities - when there are two CPU bound threads the one with
higher static priority would get more CPU time.
2013-10-09 20:13:47 +02:00