Tomas Hruby [Mon, 25 Oct 2010 16:21:23 +0000 (16:21 +0000)]
SMP - reduced TLB flushing
- flush TLB of processes only if the page tables has been changed and
the page tables of this process are already loaded on this cpu which
means that there might be stale entries in TLB. Until now SMP was
always flushing TLB to make sure everything is consistent.
Ben Gras [Sun, 10 Oct 2010 22:33:23 +0000 (22:33 +0000)]
change SSIZE_MAX to INT_MAX instead of 32767.
With this change, suggested by Gautam Tirumala, ports for pkgin and
pkg_install are cleaner and so easier to upstream. Presumably other
ports will be smoother too.
There doesn't seem to be a reason SSIZE_MAX was so small to begin with.
Ben Gras [Mon, 4 Oct 2010 11:41:10 +0000 (11:41 +0000)]
vm: optimisation: avl tree for virtual regions
- regions were preivous stored in a linked list, as 'normally'
there are just 2 or 3 (text, data, stack), but that's slow
if lots of regions are made with mmap()
- measurable performance improvement with gcc and clang
Ben Gras [Fri, 1 Oct 2010 14:39:04 +0000 (14:39 +0000)]
make the asynsend table size NPROCS-dependent.
this is a fix for e.g. the situation where lots of processes die
instantly, and PM has to send an asyn msg for each one to VFS, and
panics if there are too many. there are likely more situations in
which this table should be dependent on the no. of processes.
Thomas Veerman [Thu, 30 Sep 2010 13:44:13 +0000 (13:44 +0000)]
Revamp the mthread library and update test59
Before, the 'main thread' of a process was never taken into account anywhere in
the library, causing mutexes not to work properly (and consequently, neither
did the condition variables). For example, if the 'main thread' (that is, the
thread which is started at the beginning of a process; not a spawned thread by
the library) would lock a mutex, it wasn't actually locked.
Tomas Hruby [Thu, 23 Sep 2010 14:42:19 +0000 (14:42 +0000)]
CPU type detection
- sometimes the system needs to know precisely on what type of cpu is
running. The cpu type id detected during arch specific
initialization and kept in the machine structure for later use.
- as a side-effect the information is exported to userland
Tomas Hruby [Thu, 23 Sep 2010 10:49:52 +0000 (10:49 +0000)]
Busy idle loop when profiling
- the Intel architecture cycle counter (performance counter) does not
count when the CPU is idle therefore we use busy loop instead of
halting the cpu when there is nothing to schedule
- the downside is that handling interrupts may be accounted as idle
time if a sample is taken before we get out of the nested trap and
pick a new process
Tomas Hruby [Thu, 23 Sep 2010 10:49:39 +0000 (10:49 +0000)]
New profile protocol
- when kernel profiles a process for the first time it saves an entry
describing the process [endpoint|name]
- every profile sample is only [endpoint|pc]
- profile utility creates a table of endpoint <-> name relations and
translates endpoints of samples into names and writing out the
results to comply with the processing tools
- "task" endpoints like KERNEL are negative thus we must cast it to
unsigned when hashing
Ben Gras [Mon, 20 Sep 2010 11:07:53 +0000 (11:07 +0000)]
. forget obsolete /usr/local/bin in $PATH
. update release.sh's notion of where packages are
. update release.sh's notion of how many files are on root
as -xdev won't work anymore to separate /usr from /
Tomas Hruby [Sun, 19 Sep 2010 15:52:12 +0000 (15:52 +0000)]
Userspace scheduling - exporting stats
- contributed by Bjorn Swift
- adds process accounting, for example counting the number of messages
sent, how often the process was preemted and how much time it spent
in the run queue. These statistics, along with the current cpu load,
are sent back to the user-space scheduler in the Out Of Quantum
message.
- the user-space scheduler may choose to make use of these statistics
when making scheduling decisions. For isntance the cpu load becomes
especially useful when scheduling on multiple cores.
Tomas Hruby [Wed, 15 Sep 2010 14:11:25 +0000 (14:11 +0000)]
SMP - lazy FPU
- when a process is migrated to a different CPU it may have an active
FPU context in the processor registers. We must save it and migrate
it together with the process.
Tomas Hruby [Wed, 15 Sep 2010 14:11:21 +0000 (14:11 +0000)]
SMP - can boot even if some cpus fail to boot
- EBADCPU is returned is scheduler tries to run a process on a CPU
that either does not exist or isn't booted
- this change was originally meant to deal with stupid cpuid
instruction which provides totally useless information about
hyper-threading and MPS which does not deal with ht at all. ACPI
provides correct information. If ht is turned off it looks like some
CPUs failed to boot. Nevertheless this patch may be handy for
testing/benchmarking in the future.
Tomas Hruby [Wed, 15 Sep 2010 14:11:17 +0000 (14:11 +0000)]
SMP - Force TLB flush before scheduling a process
- this makes sure that each process always run with updated TLB
- this is the simplest way how to achieve the consistency. As it means
significant performace degradation when not require, this is nto the
final solution and will be refined
Tomas Hruby [Wed, 15 Sep 2010 14:11:12 +0000 (14:11 +0000)]
SMP - Process is stopped when VM modifies the page tables
- RTS_VMINHIBIT flag is used to stop process while VM is fiddling with
its pagetables
- more generic way of sending synchronous scheduling events among cpus
- do the x-cpu smp sched calls only if the target process is runnable.
If it is not, it cannot be running and it cannot become runnable
this CPU holds the BKL
Tomas Hruby [Wed, 15 Sep 2010 14:10:42 +0000 (14:10 +0000)]
SMP - Changed prototype of sys_schedule()
- sys_schedule can change only selected values, -1 means that the
current value should be kept unchanged. For instance we mostly want
to change the scheduling quantum and priority but we want to keep
the process at the current cpu
- RS can hand off its processes to scheduler
- service can read the destination cpu from system.conf
Tomas Hruby [Wed, 15 Sep 2010 14:10:37 +0000 (14:10 +0000)]
SMP - BKL statistics
- pressing 'B' on the serial cnsole prints statistics for BKL per cpu.
- 'b' resets the counters
- it presents number of cycles each CPU spends in kernel, how many
cycyles it spends spinning while waiting for the BKL
- it shows optimistic estimation in how many cases we get the lock
immediately without spinning. As the test is not atomic the lock may
be already held by some other cpu before we actually try to acquire
it.
Tomas Hruby [Wed, 15 Sep 2010 14:10:33 +0000 (14:10 +0000)]
SMP - Scheduler can assign process to a cpu
- machine information contains the number of cpus and the bsp id
- a dummy SMP scheduler which keeps all system processes on BSP and
all other process on APs. The scheduler remembers how many processes
are assigned to each CPU and always picks the one with the least
processes for a new process.
Tomas Hruby [Wed, 15 Sep 2010 14:10:07 +0000 (14:10 +0000)]
SMP - The slave CPUs turn paging on
- APs wait until BSP turns paging on, it is not possible to safely
execute any code on APs until we can turn paging on as well as it
must be done synchronously everywhere
Tomas Hruby [Wed, 15 Sep 2010 14:10:03 +0000 (14:10 +0000)]
SMP - Big kernel lock (BKL)
- to isolate execution inside kernel we use a big kernel lock
implemented as a spinlock
- the lock is acquired asap after entering kernel mode and released as
late as possible. Only one CPU as a time can execute the core kernel
code
- measurement son real hw show that the overhead of this lock is close
to 0% of kernel time for the currnet system
- the overhead of this lock may be as high as 45% of kernel time in
virtual machines depending on the ratio between physical CPUs
available and emulated CPUs. The performance degradation is
significant