Commit Graph

6015 Commits

Author SHA1 Message Date
Ingo Weinhold
f648efd3d4 Revert "Fix zlib-dependencies of (boot & standard) packagefs."
This reverts commit 06ed405803.
2014-06-18 22:13:36 +02:00
Humdinger
6229115bac More small C++11 tweaks. 2014-06-16 19:34:56 +02:00
PulkoMandy
004f41565e Apply fix suggested by Ingo
* Fix mixup of HAIKU_IMAGE vs HAIKU_IMAGE_NAME
* Use $(1) and $(2) instead of $(<) and $(>)
* Remove useless count parameter to dd
2014-06-15 14:59:01 +02:00
PulkoMandy
4a2260f21a Let the bootloader know about ARMv7.
When an ARMv7 CPU is detected, immediately turn on the FPU. This allows
us to use vsnprintf in the TRACE call in that function, as our libc is
compiled with floating point support and will trigger a fault if the FPU
is not available.

This lets the boot go further, and crash in mmu_init. Next steps:
* Find why mmu_init is crashing
* Setup some fault handlers, otherwise we call uboot ones, and they are
not very helpful. They will also probably not work once the mmu is
enabledvery helpful. They will also probably not work once the mmu is
enabledvery helpful. They will also probably not work once the mmu is
enabled...
2014-06-13 22:15:54 +02:00
PulkoMandy
afe56d3ab3 Load uImage higher so it doesn't overwrite itself
Loading of haiku_loader from an uImage is a 2-step process:

* First, the uImage is loaded (in our case from SD card using fatload)
to RAM at a temporary address.
* Then (using bootm), it is unpacked. The uImage is a container format
and can hold several files, with a load and execution address. The files
are copied from the uImage to their final location, and it's better if
that doesn't overlap with the uImage content

When this loading is done, bootm jumps to the entry point found in the
uImage.

We now actually execute our code from haiku_loader. This crashes with
the following call stack:
* vsnprintf
* dprintf
* boot_arch_cpu_init
* cpu_init

It seems vsnprintf is trying to use VFP instructions (probably from the
libgcc) but that triggers some kind of fault, and the handler (setup by
uboot?) ends up crashing the system by jumping to unmapped memory at 0.
2014-06-13 20:26:51 +02:00
PulkoMandy
3d6edc43d9 Patch by dnivra (GSoC 2014, ARM suppport)
* Cleanup the SD card image building to allow jam -q @bootstrap-mmc to
work.

There are a few remaining tricks before you can safely build an image:
* This uses a non-POSIX du option, and is only tested with Linux du
only (Linux is the only supported system to run bootstrap builds,
anyway)
* The Python recipe in haikuports.cross is known to not build on
Debian/Ubuntu, but work fine on OpenSuse. There is a patch available in
haikuports bugtracker to allow the reverse.
* You need to populate the haikuports repo package list with some
packages (which don't exist yet) to make the build system happy. But our
git hook to generate the repositories is preventnig me to share this
hack.

Once built, the image currently crashes early in the kernel execution.
On to debug that!
2014-06-13 17:22:48 +02:00
Jérôme Duval
d64267ffb2 vfs: checks whether the mount's unmounting flag is already set.
* thanks to Ingo for suggesting the idea, quoting him:
"by holding sVnodeLock read-locked, get_mount() ensures that fs_unmount() can't
process the nodes. If it is already past that point, the root node check
(not NULL, not busy, ref count > 0) is supposed to detect that. But it doesn't
look like this can work. fs_unmount() doesn't set the root node to NULL (the
root node field is NULL only during a short period in fs_mount()), but it just
frees the nodes after releasing sVnodeLock. So the not busy and ref count > 0
checks could already access freed memory".
* tested OK, this fixes #10522.
* replaced mount->root_vnode by the local variable with the same value.
2014-06-09 21:45:28 +02:00
Jessica Hamilton
5700f5fcc3 libroot.so: update glibc's e_pow.S on x86. Fixes #9962 2014-06-07 09:33:15 +12:00
Jessica Hamilton
01fbdbab83 xsi_semaphore: use MemoryDeleter instead of multiple free() 2014-06-03 13:38:04 +12:00
Oliver Tappe
1a7bcf6962 Lots of B_PRI... insertions to fix errors with DEBUG=1. 2014-06-02 02:00:28 +02:00
Paweł Dziepak
b20eb413cd kernel/x86_64: help gcc with devirtualization
This patch gets rid of some indirect calls in the paging code.
2014-05-30 02:11:05 +02:00
Paweł Dziepak
fb010e297f kernel/x86_64: use C++11 atomics in X86PagingMethod64Bit 2014-05-30 00:23:49 +02:00
Paweł Dziepak
91e7f347f9 kernel/x86_64: try to inline physical page mapper functions
The way we handle paging is very wasteful and relies heavily on virtual
funcions even if there is absolutely no reason to do so. The proper
solution would be to do a major rework of paging code (including
arch-independent parts).

On x86_64 physical page mapper is very simple what makes the overhead
resulting from the desing of paging interface very expensive. This
patch attempts to make things a bit better by helping GCC with
devirtualization and allowing inlining physical page mapper impementation
(well, only when it is devirtualized).
2014-05-29 23:41:46 +02:00
Puck Meerburg
d0592a1164 Fix Coverity bug 605892: Resource leak
Signed-off-by: Jessica Hamilton <jessica.l.hamilton@gmail.com>
2014-05-30 08:45:56 +12:00
Michał Siejak
679ad262e9 haiku_loader now ignores unusable drives reported by BIOS.
This fixes the problem with find_unique_check_sums() taking a very long
time to complete when one or more drives report read errors.

Fixes #10880.

[Paweł: minor style issue]
Signed-off-by: Paweł Dziepak <pdziepak@quarnos.org>
2014-05-29 22:32:15 +02:00
Jessica Hamilton
44ec21c3ff ByteOrder.h: simplify compiler test
* A problem with our gcc requires adding casts for gcc4 when
  the __builtin_bswap functions are used with a format string
* Unlike gcc2, the __builtin_bswap functions do not get disabled
  despite using -fno-builtins, hence added compiler check in
  runtime_loader/utility.cpp
2014-05-30 00:15:38 +12:00
Oliver Tappe
06ed405803 Fix zlib-dependencies of (boot & standard) packagefs.
* Some files that depend on zlib.h weren't declared as such, which
  could cause multijob builds to fail.
2014-05-24 20:26:41 +02:00
Adrien Destugues
5e36a367d7 Convert strdup.c to C++. 2014-05-23 18:30:26 +02:00
Adrien Destugues
6f79af3c55 Web+: move BookmarbKar to own file.
It's a bit long for an inline class, and I'm going to add more stuff to
it.
2014-05-23 15:38:10 +02:00
Pawel Dziepak
680ca3b13d runtime_loader: fix CID 1211995, improve generation counting
There is no need to increase generation counter each time new DSO is
registered.
2014-05-08 23:07:50 +02:00
Pawel Dziepak
fad7246fcd runtime_loader: fix CID 1211997, proper corner case handling 2014-05-08 23:07:50 +02:00
Pawel Dziepak
2c001246a0 build: when using gcc4 build kernel with c++11 2014-05-08 23:07:50 +02:00
Pawel Dziepak
76636769bd kernel/x86_64: inline x86_{read, write}_msr()
This patch makes it possible to inline rdmsr and wrmsr instruction. The
performance impact shouldn't be significant since they are used relatively
rarely and wrmsr is usually a serializing instruction, but there is no reason
not to do so.
2014-05-06 21:41:49 +02:00
Pawel Dziepak
88e8e24c84 kernel/x86_64: improve context switch implementation
The goal of this patch is to amortize the cost of context switch by making
the compiler aware that context switch clobbers all registers. Because all
register need to be saved anyway there is no additional cost of using
callee saved register in the function that does the context switch.
2014-05-06 21:15:55 +02:00
Pawel Dziepak
9db5b975f9 kernel/x86_64: rework of IDT handling code
Similarly to previous patch regarding GDT this is mostly a rewrite of
IDT handling code from C to C++. Thanks to constexpr IDT is now entirely
generated at compile-time.
2014-05-06 14:59:54 +02:00
Pawel Dziepak
2b6d4bc657 kernel/x86: add space between literal and identifier
Due to introduction of user-defined suffixes C++11 requires that there
is a space between literal and identifier to avoid ambiguity.
2014-05-06 14:59:53 +02:00
Pawel Dziepak
cd59bf4349 kernel/x86_64: x86_64 gdt handling code overhaul
Virtually no functional change, just rewriting the code from
"C in *.cpp files" to C++. Use of constexpr may be advantageous but
that code is not performance critical anyway.
2014-05-06 14:59:53 +02:00
Pawel Dziepak
c1dc104960 kernel/x86_64: enable c++11 in x86_64 specific code 2014-05-06 14:59:53 +02:00
Pawel Dziepak
f31c19bb9e libroot/x86_64: relax asm constraints in find_thread() 2014-05-06 14:59:53 +02:00
Pawel Dziepak
344643740a libroot/x86_64: minor improvements in TLS code
* less inline asm
 * std::atomic<> instead of obsolete atomic_*()
2014-05-06 14:59:53 +02:00
Pawel Dziepak
ea7e57c966 libroot: enable c++11 in os/arch/x86_64 2014-05-06 14:59:53 +02:00
Pawel Dziepak
0e45e3eb1d runtime_loader: keep symbol DSO in SymbolLookupCache
While resolving TLS related relocations it is necessary to know the DSO
that defines the symbol. Without proper support in caching that information
is available only when the symbol is resolved first time. That works well
for TLS since TLS_DTPMOD is guaranteed to be before TLS_DTPOFF relocation.
This patch makes the newly introduced parts of the interface work in a
general case.
2014-05-04 12:52:05 +02:00
Pawel Dziepak
df58e6a9f4 runtime_loader: support linking TLS symbols from any DSO
Previously TLS_DTPMOD relocation blindly returned ID of the current DSO.
This patch does proper symbol lookup if there is a symbol assigned to the
relocation and uses ID of the DSO in which the symbol is defined.
2014-05-04 12:21:26 +02:00
Pawel Dziepak
44c0c4d3d0 runtime_loader: add support for ELF based TLS
This patch introduces support of ELF based TLS handling with lazy allocation
and initalization of TLS block for each DSO and thread. The implementation
generally follows the official ABI except that generation counter in dtv
is in fact a pointer to Generation object that contains both generation
counter and size of the dtv. That simplified the implementation a bit, but
could be changed later. The ABI requirements regariding in memory position
of TLS block is not honoured what results in static TLS model being
unsupported. However, that should not be a problem as long as
"executables" in Haiku are in fact shared objects and optimizations which
require specific TLS block in memory layout are not possible anyway.
2014-05-04 04:00:17 +02:00
Pawel Dziepak
bc472ab8f9 runtime_loader: add simple vector implementation
std::vector requires libstdc++ which may be unsafe to use in runtime_loader.
2014-05-04 02:40:04 +02:00
Pawel Dziepak
634bc98a3c libroot/x86[_64]: relax asm constraints in tls_*() functions 2014-05-04 02:40:04 +02:00
Murai Takashi
79895eed07 Fix gcc 4.9.0 build
Signed-off-by: Jérôme Duval <jerome.duval@gmail.com>
2014-04-29 22:01:34 +02:00
Jessica Hamilton
f21045a772 Correct B_USER_BOOT_DIRECTORY path. Fixes #10070. 2014-04-27 15:45:40 +12:00
PulkoMandy
279c181ab8 Import stdatomic.c from freebsd for ARM port
* Fixes missing atomic stuff that gcc requires
* The gcc build still fails further down, because of a mixup of
VFP/nonVFP objects (at least for beagle build).
2014-04-19 23:44:32 +02:00
Pawel Dziepak
744dfa3c4c kernel: make sure thread priority is within valid range
The scheduler expects that all threads expect the initial idle threads
have priority in range [THREAD_MIN_SET_PRIORITY, THREAD_MAX_SET_PRIORITY].
If the requested pririty is out of range the value is clamped. Failing
with B_BAD_VALUE is probably an overkill since there isn't any real
change in the guarantees provided by the scheduler about the behavior
of such thread. Also, BeBook suggests that spawn_thread() can specify
priority 0.
2014-04-18 23:55:18 +02:00
Ingo Weinhold
6b3a5caf99 VFS: Pass packages state selected in boot loader to packagefs 2014-04-18 23:31:40 +02:00
Ingo Weinhold
8585939dca VFS: Don't try to mount the no longer existing /boot/common packagefs 2014-04-18 23:31:40 +02:00
Ingo Weinhold
5c0f8450ac Boot loader: Add support for choosing an old packages state
For potential boot volumes with older packages states the respective
item in the boot volume menu now has a sub menu for selecting a state.
The boot loader functionality for this feature is complete -- i.e. the
respective kernel is loaded and the name of the old state is added to
the kernel args -- but kernel packagefs and package daemon support is
still missing.
2014-04-18 23:31:39 +02:00
Ingo Weinhold
59881eaa16 Boot loader: Update copyright right in boot menu 2014-04-18 23:31:39 +02:00
Ingo Weinhold
59ae1c816d Boot loader: Add get_stat(), directory_from()
* Add Node::Stat() and simplify Descriptor::Stat().
* Add get_stat() and directory_from().
2014-04-18 23:31:39 +02:00
Ingo Weinhold
2f019bd6ca boot loader: Implement subset of <dirent.h> API
* Add opendir(), closedir(), readdir(), rewinddir().
* Add open_directory(), similar to opendir(), but basing the path off a
  specified directory.
2014-04-18 23:31:39 +02:00
John Scipione
ebd3bcdb9b exfat: handle 4-byte UTF-16 surrogate pairs
... in filenames. Replace the existing Unicode conversion functions
with UTF conversion functions from js that he relicensed MIT for us.

Put the UTF conversion functions in a private but shared code location
so that they can be accessed throughout the kernel.

Right now we only provide functions to convert between UTF-8 and UTF-16.
At some point we should also add functions to convert between UTF-8 and
UTF-32 and UTF-16 and UTF-32 but these aren't needed by exfat.

Remove the old Unicode conversion functions from exfat as they assumed
UCS-2 characters and don't work with UTF-16 used by exfat.

Rename most variables with the term length with code unit where code units
are intended. The term length, when used, means length in bytes while code
units represent either a full 2-byte UTF-16 character or half a 4-byte
surrogate pair.
2014-04-11 18:46:03 -04:00
Pawel Dziepak
91810926dc scheduler: Fix and simplify thread migration logic in low latency mode
This patch remove the old thread migration logic which used few special
cases and (broken) general check that attempted to balance threads.

The new logic is pretty straightforward and seems perform well without
any additional special cases. Current core is compared with the least loaded
one and the thread is migrated if that would result in estimated loads of
both cores (i.e. the current one and the least loaded one) to become closer
to the average load (i.e. average of that two cores).
2014-04-09 03:24:34 +02:00
Pawel Dziepak
1bba129c56 scheduler: Let ThreadData::ShouldRebalance() choose the actual core
Currently, ThreadData::ShouldRebalance() (and mode specific functions
it calls) only decides whether to migrate thread to another core or not.
However, in most cases it actually needs to find the best candidate for
new core so it could as well return that information.
2014-04-09 03:24:34 +02:00
Jessica Hamilton
c552bd6771 haiku_loader: search for matching shortcut in supermenus
Fixes #7469.
2014-04-07 22:14:08 +12:00
Jonathan Schleifer
6a2fd3a50e Add __dso_handle to bootloader and kernel
Clang references these when building for x86_64.
2014-04-03 19:19:33 +02:00
Jérôme Duval
aafc3386ef boot packagefs: Fix header path in zlib dependency
Thanks to Ingo for pointing at this better fix.
2014-03-26 19:38:30 +01:00
Axel Dörfler
d941d6bac3 Minor cleanup. 2014-03-25 23:36:21 +01:00
Jérôme Duval
0b565a6f51 boot packagefs: Fix zlib dependency declaration 2014-03-19 20:19:17 +01:00
Pawel Dziepak
b167307526 kernel: Properly synchronize suspending new thread
After load_image() the child thread is suspended and the parent is
expected to resume it later. However, it is possible that the parent
attempts to resume its child after it has been notified that the image
had been loaded but before the child managed to suspend itself. In such
case the child would suspends itself after that wake up attempt and,
consequently will not be ever resumed.

To mitigate that problem flag Thread::going_to_suspend has been added
which helps synchronizing thread suspension and continuation in a similar
way that "traditional" thread blocking is performed. This means that
the child should behave in a following manner: set its going_to_suspend flag,
notify the parent (i.e. any thread that may want to resume it), acquire
its scheduler_lock and suspend itself if the going_to_suspend flag is set.
The parent should follow pattern: clear going_to_suspend flag of the thread
that is about to be resumed, acquire that thread scheduler_lock and enqueue
it in a run queue if it is suspended.

Thanks Oliver for reporting the bug and identifying what causes it.
2014-03-17 02:40:12 +01:00
Pawel Dziepak
d7e1e3e012 kernel/UserEvent: Make sure UserEvent object is valid during DPC
Most of the actual UserEvent work is done in DPC so that we don't have
to care about the limitations of the context in which UserEvent::Fire()
is invoked. This requires appropriate management of lifetime of UserEvent
instances to make sure that DoDPC() method is always called on a valid
object.
2014-03-17 02:40:12 +01:00
Adrien Destugues
ba5172cccb pthread: allow NULL thread to compare equal.
- POSIX says the behavior for pthread_equal is undefined for
uninitialized arguments.
- However, gcc C++11 threads supports expects C++-compatible behavior,
that is, two uninitialized pthread_t should compare equal.

Avoids some runtime asserts in latest WebKit version.
2014-03-09 22:26:36 +01:00
Pawel Dziepak
0012ba6a87 scheduler/low_latency: Try harder to balance load
In low latency mode the scheduler would not attempt to balance load
on not heavily loaded cores unless difference in load exceeded
kLoadDifference * 2 (i.e. 40 percentage points), which does not seem
to be good enough.
2014-03-09 19:58:11 +01:00
Pawel Dziepak
a57a7a8c6d scheduler: Fix load update on idle cores
To make sure that load statistics are accurate on idle cores each time
idle thread is scheduled a timer is set to update load when current
load measurement interval elapses. However, core load is defined as the
average load during last measurement interval and idle core may be still
considered busy if it was not idle during entire measurement interval.
Since, load update timer is a one shot timer that information will not be
updated until the core becomes active again.

To mitigate that issue load update timer is set to fire after two load
measurement intervals had elapsed.
2014-03-09 19:58:11 +01:00
Pawel Dziepak
5df1ecb2ab x86_64: Relax ltr operand constraint
Any 16 bit general puprose register can be a ltr operand, no need
to force AX.
2014-03-09 19:58:10 +01:00
Pawel Dziepak
1700e825b1 scheduler: Always protect gCore[High]LoadHeap with spinlock
Should fix #10628. If there is a race condition with a writer getting
minimum or maximum from double ended heap may incorrectly result NULL.
Which is not expected in the most of the thread migration logic. Apart
from that, because of the race condition heap state may be observed as
inconsistent thus failing assertions.
ended heap
2014-03-09 19:58:10 +01:00
Adrien Destugues
217f090f9e malloc_debug: align allocations
* Align all allocations of more than 8 bytes to 8-byte.
* Avoids hitting ASSERTs in WebKit when built in debug mode (it assumes
at least 8 byte alignment)
2014-03-04 17:29:30 +01:00
Pawel Dziepak
3ed7ce75b3 kernel: Relax atomic loads in SMP code
The main purpose of using atomic_get() was the necessity of a compiler
barrier to prevent the compiler from optimizing busy loops. However,
each such loop contains in its body at least one statement that acts
as a compiler barrier (namely, cpu_wait() or cpu_pause()) making
atomic_get() redundant (well, atomic_get() is stronger - it also issues
a load barrier but in these particular cases we do not need it).
2014-02-27 02:21:13 +01:00
Pawel Dziepak
e31212e4d7 kernel: Fix acquire_read_spinlock() acquire checks
If the initial attempt to acquire read spinlock fails we use more relaxed
loop (which doesn't require CPU to lock the bus). However, check in that
loop, incorrectly, didn't allow a lock to be acquired when there was at
least one other reader.
2014-02-27 02:21:13 +01:00
Julian Harnath
ad64943039 Fix spinlock usage in kernel's system profiling
* Removal of gSchedulerLock left a few SpinLockers around which were
  now without locked interrupts.

* Makes scheduling_recorder work again.
2014-02-26 23:08:41 +00:00
Alexander von Gluck IV
b6994f96c0 ARM: Break apart ARMv5 and older dsb/dmb
* Add isb just because.
* pdziepak pointed out that ARMv5 and before
  had different barrier support.
* pdziepak also mentioned that dsb was too strong
  for __sync_synchronize
2014-02-26 13:17:21 -06:00
Alexander von Gluck IV
a21611e439 ARM: Add ARMv6 or older __sync_synchronize built-in
* On ARMv6 or older, we do a simulated dsb.
* Move __sync_synchronize into thread.c in libroot
  and use the new arch_atomic.h dsb/dmb defines.
* Gets arm @bootstrap-raw to end of bootstrap.
2014-02-26 12:51:51 -06:00
Puck Meerburg
92d40f5451 ARM Kernel stubs: Fix mutex stubs 2014-02-23 22:11:22 +01:00
Adrien Destugues
22011f8b6c ARM Atomics: implement __sync_syncronize
GCC doesn't provide an ARM implementation of it. It's easy to write one
for ARMv6 and above, while older archs will need this implemented as a
syscall just like other atomics.
2014-02-23 16:25:34 +01:00
Adrien Destugues
faa2d8a95b Don't link the kernel as a shared lib on ARM
We have the same problem as on x86_64: posiiton dependant code isn't
allowed in shared libraries. Since Kernel.so is not used at runtime,
we can use the same hack as on x86_64, and use elfedit to make the
linker think our kernel is a shared library.
2014-02-23 16:23:45 +01:00
Alexander von Gluck IV
1b38c3412c mips: Remove mips
* As per the ML discussions. Bumps MIPS to tier 3.
* We've reached a unanimous descision that MIPS doesn't
  target any real / valid hardware Haiku wants to pursue
  at the moment.  In the event that anyone wants to pursue
  MIPS, feel free to fork Haiku into your own repository
  (and we'll even link to it on the website ports page)
* If someone develops a viable plan for MIPS (and gets the
  port working, it can be readded at a later date)
2014-02-18 16:29:09 -06:00
Adrien Destugues
9046835de9 Patch by Ingo Weinhold: fix stack alignment on x86.
This is required to use some SSE instructions, which are generated by
gcc 4.8, most notably when compiling WebKit code (but it may happen
elsewhere as well).

Fixes about 900 crashes and 10000 test failures in WebKit, so this must
be working. Fixes #10509 for x86.
2014-02-18 20:55:37 +01:00
Ithamar R. Adema
8f4db360bc arm/atomic: round of atomic function changes
* change vint{32,64} to int{32,64} in:
  * kernel implementation
  * syscall definitions
  * libroot prototypes
* update syscall functions with new atomic prototypes.
2014-02-15 11:46:12 +01:00
Ithamar R. Adema
3eb1ffdb6c kernel/arm: implement stubs for new functions
These were mostly introduced after the scheduler merge.
2014-02-15 11:46:11 +01:00
Alexander von Gluck IV
abcbb5d617 arm/paging: Convert to new-style CPU management
* Aka, post-scheduler changes
* Luckily ARM paging code is very simular to x86 paging
2014-02-12 23:54:35 -06:00
Alexander von Gluck IV
35171b073d arm: Miscellaneous build fixes
* Use atomic_get_and_set for return value
* Atomics are no longer volatile
* Add missing arch_cpu_pause stub
* Move arch_cpu_idle to arch_cpu header to match
  other architectures
2014-02-12 23:37:15 -06:00
Adrien Destugues
9af2105d36 Move ZlibDecompressor to libshared
* This will be used to implement compressed http streams
* Remove the custom BDataOutput class, and use BDataIO instead, for
easier integration with existing code.
2014-02-11 12:06:38 +01:00
Jérôme Duval
7c1acc8968 x86_64: align malloc() allocations on 16 bytes.
* added a check in memalign_test.
2014-02-07 18:27:50 +01:00
Pawel Dziepak
1da76fd4cc scheduler: Inherit estimated load, do not inherit assigned core
The initial core assignment has to be done without any knowledge about
the thread behaviour. Moreover, short lived tasks may spent most of their
time executing on that initial core. This patch attempts to improve the
qualiti of that initial decision.
2014-02-06 03:23:28 +01:00
Pawel Dziepak
667b23ddc2 scheduler: Always update core heaps after thread migration
The main purpose of this patch is to eliminate the delay between thread
migration and result of that migration being visible in load statistics.
Such delay, in certain circumstances, may cause some cores to become
overloaded because the scheduler migrates too many threads to them before
the effect of migration becomes apparent.
2014-02-06 03:23:28 +01:00
Pawel Dziepak
230d1fcfea scheduler: Update load of idle cores
In order to keep the scheduler tickless core load is computed and updated
only during various scheduler events (i.e. thread enqueue, reschedule, etc).
The problem it creates is that if a core becomes idle its load may remain
outdated for an extended period of time thus resulting in suboptimal thread
migration decisions.

The solution to this problem is to add a timer each time an idle thread is
scheudled which, after kLoadMeasureInterval, would fire and force load
update.
2014-02-06 03:23:28 +01:00
Pawel Dziepak
771ae065db scheduler: Update priority penalty computation in debug dump 2014-02-06 03:23:28 +01:00
Pawel Dziepak
f116370edd scheduler: Relax penalty cancellation requirements
Priority penalties were made more strict in order to prevent situation
when two or more high priority threads uses up all available CPU time
in such manner that they do not receive a penalty but starve low priority
threads.

However, a significant change to thread priorites has been made since and
now priority of all non real time threads varies in a range from 1 to
static priority minus penalty. This means that the scheduler is able to
prevent thread starvation without any complex penalty policies.
2014-02-03 04:55:16 +01:00
Pawel Dziepak
6155ab7b25 scheduler: Provide more stable core load statistics
Originially, core load was a sum of eastimated loads of all currently
running or ready threads on a given core. Such value is changing very
rapidly preventing the thread migration logic from making any reasonable
decisions.

This patch changes the way core load is computed to make it more stable
thus improving the qualitiy of decisions made by the thread migration logic.
Currently core load is a sum of estimated loads of all threads that have been
ready during last load measurement interval and haven't been migrated or
killed.
2014-02-03 04:55:16 +01:00
Pawel Dziepak
e6cfae450e kernel/x86: Make x2APIC CPU topology detection more future proof
The main reason for this patch is to fix gcc 4.8.2 warning about
hierarchyLevels possibly being used not initialized. Such thing
actually can not happen since all x2APIC CPUs are aware of at least
3 topology levels. However, once more topology levels are introduced
we will have to deal with CPUs that do not report information about all
of them.
2014-02-03 04:55:09 +01:00
Pawel Dziepak
01a479daa9 boot/x86: Fix unused variable warning 2014-01-29 04:11:42 +01:00
Pawel Dziepak
527da4ca8a x86[_64]: Separate bootloader and kernel GDT and IDT logic
From now on bootloader sets up its own minimal valid GDT and IDT. Then
the kernel replaces them with its own tables.
2014-01-28 00:44:02 +01:00
Pawel Dziepak
819824e020 kernel/{x86, vm}: Add more error checks in VM initialization 2014-01-27 05:36:30 +01:00
Pawel Dziepak
931ce674a9 scheduler: Fix core unassignment 2014-01-27 05:36:30 +01:00
Pawel Dziepak
7adce94d45 scheduler: Check team user time timers before entering scheduler
User timers may cause another thread to become ready in which case we would
like this to happen before scheduler_reschedule() chooses next thread to
be executed.
2014-01-27 05:36:30 +01:00
Pawel Dziepak
82bcd89b92 kernel: Add CPUSet::{Clear, Set}BitAtomic() functions 2014-01-24 13:59:58 +01:00
Pawel Dziepak
03451e4cc1 kernel: Fix deadlock with thread sending signal to itself
UserEvent can be fired from scheduler_reschedule() i.e. while holding current
thread scheduler_lock. If the current thread goes sleep and during reschedule
one of its timers sends a signel to it, then scheduler_enqueue_in_run_queue()
attempts to acquire again its scheduler_lock resulting in a deadlock.

There was also a minor issue with both scheduler_reschedule() and
scheduler_enqueue_in_run_queue() acquiring current CPU scheduler mode lock.
2014-01-24 13:59:58 +01:00
Stephan Aßmus
cb3dc4b2cf Uninitialized members CID 1162813 and 1162814 2014-01-22 17:41:51 +01:00
Pawel Dziepak
5d79095e44 scheduler: Do not update load of disabled cores 2014-01-22 03:04:01 +01:00
Pawel Dziepak
d01fa1ffe3 scheduler: Always update core load at thread reenqueue 2014-01-21 03:50:26 +01:00
Alexander von Gluck IV
fd78b6df3f ppc: Modernize atomic.S.
* Stub out atomic_get_and_set. This needs completed.
2014-01-19 23:39:19 -06:00
Alexander von Gluck IV
24f0b1e29e libroot: Drop volatile in syscall atomic functions
* Per 077c84eb27, atomics are no longer volatile.
* Was changed in SupportDefs.h, but no one told libroot
  that it was no-longer volatile.
2014-01-19 22:31:37 -06:00
Alexander von Gluck IV
749a60bf39 ppc: atomic is no longer volatile per 077c84eb27 2014-01-19 22:14:28 -06:00
Alexander von Gluck IV
14919567d1 kernel: Add more architecture code post-scheduler
* Fix incorrect cpu vendor name mapping
* Add additional CPU architectures
* Add additional CPU vendors
* Rework PowerPC arch_system_info passing
  PVR back for cpu model
2014-01-19 21:53:56 -06:00
Pawel Dziepak
59b9b52aaf scheduler: system_time() may be unreliable
On multisocket systems as well as under virtual machines logical CPUs
may use separate TSC. We could attempt to synchronize them what probably
would solve problems on multisocket systems. Unfortunately, when running
under hypervisor there is still a chance that TSC will get out of sync
again (e.g. cpufreq enabled on host when there is no invariant TSC). As
long as we use RDTSC as our main time source the scheduler must accept the
fact that time may go backwards (what isn't really a serious problem).
2014-01-20 03:22:04 +01:00
Pawel Dziepak
73db12ab31 kernel: Align user_thread objects to CACHE_LINE_SIZE 2014-01-20 03:22:04 +01:00
Alexander von Gluck IV
88c54b5485 kernel: Rework ppc (and m68k) atomic functions post-scheduler
* Make atomic function more like current x86
* Remove fake fallback atomic code for ppc as hardware spinlocks exist
2014-01-19 19:33:21 -06:00
Pawel Dziepak
cf87df8ba3 libroot: Fix gcc2 build 2014-01-20 00:54:52 +01:00
Pawel Dziepak
25dcdbc2b5 libroot: Avoid conflicts with legacy CPU and platform enums 2014-01-20 00:32:57 +01:00
Pawel Dziepak
9d80738d95 kernel: Fix NULL dereference in has_permission_to_signal 2014-01-19 19:35:13 +01:00
Ingo Weinhold
8540ec2446 Save previous session's debug syslog during boot
Add boot loader debug menu option "Save syslog from previous session
during boot". If enabled (defaults to true), the previous session's
debug syslog data is copy to a separate buffer and passed to the
kernel, which writes it back to the file /var/log/previous_syslog.
As long as Haiku still boots, this should now be the most convenient way
to retrieve the output from a kernel crash.
2014-01-19 10:46:00 +01:00
Pawel Dziepak
955e4cff94 scheduler: Weaken time slept assertion 2014-01-17 18:07:47 +01:00
Pawel Dziepak
d0f2d8282f Merge branch 'scheduler'
Conflicts:
	build/jam/packages/Haiku
	headers/os/kernel/OS.h
	headers/os/opengl/GLRenderer.h
	headers/private/shared/cpu_type.h
	src/add-ons/kernel/drivers/power/acpi_battery/acpi_battery.h
	src/bin/sysinfo.cpp
	src/bin/top.c
	src/system/kernel/arch/x86/arch_system_info.cpp
	src/system/kernel/port.cpp
2014-01-17 04:06:15 +01:00
Pawel Dziepak
0269dd284e Revert "scheduler: SCHEDULER_EXIT_FUNCTION() is not needed"
This reverts commit 667617ad043a4587d8d366d5192d9ad291cfa37a.

Scheduler profiler uses CPU local data to store function information, hence
arch_thread_context_switch() usually is not a problem. However, when
we switch to a new thread we end up scheduler_new_thread_entry() instead
of scheduler_reschedule() what may corrupt data collected by the profiler.
2014-01-17 01:55:42 +01:00
Pawel Dziepak
3dce49af0e scheduler: Cache quantum length 2014-01-17 01:55:42 +01:00
Pawel Dziepak
4835c216f7 scheduler: low_latency: Try to keep all cores busy 2014-01-17 01:55:42 +01:00
Pawel Dziepak
0d27a57cf1 scheduler: Fix divide by zero on CPU disable 2014-01-16 23:26:10 +01:00
Pawel Dziepak
f978518a52 scheudler: Cache ThreadData::IsCPUBound() result 2014-01-16 23:26:10 +01:00
Pawel Dziepak
b7d404c2df scheduler: Add ThreadData::{GetPriority, IsIdle, IsRealTime}() 2014-01-16 23:26:09 +01:00
Pawel Dziepak
093c220267 scheduler: Improve latencies 2014-01-16 23:26:09 +01:00
Pawel Dziepak
7f212f45c3 scheduler: Update used time when thread yields or sleeps 2014-01-16 23:26:09 +01:00
Pawel Dziepak
dd8a866adc libroot/x86: Fix indirect jump 2014-01-16 20:18:22 +01:00
Pawel Dziepak
79c9b824e4 libroot: sync() should not return any value 2014-01-16 20:18:22 +01:00
Jonathan Schleifer
9fc69d1b00 runtime_loader: Add __dso_handle.
The symbol is needed for global objects. Usually, GCC also requires
this, but for some reason, the linking error only occurs when using
Clang.

Signed-off-by: Jérôme Duval <jerome.duval@gmail.com>
2014-01-13 19:35:34 +01:00
Jonathan Schleifer
d1c7f766fd glibc: Remove a ++ that was accidentally added.
Thanks to PulkoMandy for noticing!

Work towards bug #10396
2014-01-11 17:33:42 -06:00
Alexander von Gluck IV
4f357bc071 sysinfo: Improve x86 CPU information
* Displays standard CPUID, and shows what the
  internal CPUID used by OS.h *should* be.
* Should help out in identifying new CPU's
  as all end users have to do is run sysinfo
  to get the CPU info + value for OS.h
2014-01-11 16:14:22 -06:00
Jonathan Schleifer
38fee4c388 glibc: Remove nested function.
Nested functions are a (again, broken) GNU extension which is not
supported by Clang. It has been replaced by a bunch of gotos and a
variable that works as a return address.
2014-01-10 22:32:05 +01:00
Jonathan Schleifer
4683fcc35c glibc: Correctly create weak symbols. 2014-01-10 22:31:58 +01:00
Pawel Dziepak
082d3c1015 scheduler: Increase thread penalty at fork 2014-01-09 03:50:54 +01:00
Pawel Dziepak
a2634874ed scheduler: Estimate the load thread is able to produce
Previous implementation based on the actual load of each core and share
each thread has in that load turned up to be very problematic when
balancing load on very heavily loaded systems (i.e. more threads
consuming all available CPU time than there is logical CPUs).

The new approach is to estimate how much load would a thread produce
if it had all CPU time only for itself. Summing such load estimations
of each thread assigned to a given core we get a rank that contains
much more information than just simple actual core load.
2014-01-09 03:50:54 +01:00
Pawel Dziepak
772331c7cd scheduler: Introduce strong and weak priority penalties 2014-01-08 07:16:19 +01:00
Pawel Dziepak
d36098e043 scheduler: Keep track of the number of the ready threads 2014-01-08 05:05:25 +01:00
Pawel Dziepak
9c465cc83b scheduler: Improve recognition of CPU bound threads 2014-01-08 05:05:25 +01:00
Alexander von Gluck IV
aa4b5749d6 runtime_loader: Detect and trigger on PE binaries
* Previously PE binaries would trigger the "incorrectly
  executable" dialog. Now we get a special message for
  B_LEGACY_EXECUTABLE and B_UNKNOWN_EXECUTABLE
* Legacy at the moment is a R3 x86 PE binary. This could
  be extended to gcc2 binaries someday far, far, down the
  road though
* The check for legacy is based on a PE flag I see
  set on every R3 binary (that isn't set on dos ones)
* Unknown is something we know *is* an executable, but
  can't do anything with (such as an MSDOS or Windows
  application)
* No performance drops as we do the PE scan last
* Tested on x86 and x86_gcc2
2014-01-07 19:38:07 -06:00
Pawel Dziepak
c2a02dee65 kernel: Relax cpu_ent::interrupt_time locking
The value isn't accessed by the other CPUs and all writes and reads are
done with interrupts disabled.
2014-01-07 02:12:39 +01:00
Pawel Dziepak
c37c2aa45f scheduler: Improve should_rebalance 2014-01-07 01:11:42 +01:00
Pawel Dziepak
4ca31ac964 kernel: Fix ABA problem in try_acquire_read_spinlock() 2014-01-06 21:03:42 +01:00
Pawel Dziepak
bae6d7196a scheduler: Fix SchedulerModeLocker 2014-01-06 09:08:53 +01:00
Pawel Dziepak
a5f45afa6c scheduler: Remove unnecessary check against disabled CPU 2014-01-06 09:08:53 +01:00
Pawel Dziepak
8cf8e53774 kernel/x86: Inline atomic functions and memory barriers 2014-01-06 09:08:53 +01:00
Pawel Dziepak
8235bbc996 scheduler: Improve thread creation performance 2014-01-06 01:22:53 +01:00
Pawel Dziepak
cb66faef24 scheduler: Work around GCC2 limitations in function inlining
GCC2 won't inline a function if it is used before its definition.
2014-01-06 01:22:53 +01:00
Pawel Dziepak
9e99bf6085 scheduler: SCHEDULER_EXIT_FUNCTION() is not needed 2014-01-03 20:15:13 +01:00
Pawel Dziepak
81e04d7b97 kernel: Remove cpu_info::load
This field forces kernel to track each CPU load all the time. It is not
a problem with the current scheduler on a multicore systems, but on
single core machnies or with any other future scheduler this field may
become just an unnecessary burden. It isn't difficult for an application
to compute CPU load by itself when it needs it.
2014-01-03 19:44:57 +01:00
Pawel Dziepak
e4ea637227 scheduler: Disable load tracking when not needed 2014-01-03 19:44:56 +01:00
Pawel Dziepak
db1ddabfd0 scheduler: Thread can not stay on CPU if it has been disabled 2013-12-31 04:49:45 +01:00
Pawel Dziepak
2d52abbd5d scheduler: Inherit penalty and core from creator thread 2013-12-31 03:53:55 +01:00
Pawel Dziepak
7c92dffeef scheduler: Fix order of the includes
Thanks Jérôme!
2013-12-31 03:53:55 +01:00
Pawel Dziepak
265927509d scheduler: Protect per CPU run queue with its own lock 2013-12-31 03:53:55 +01:00
Pawel Dziepak
1524fbf742 scheduler: Fix divide error in _RequestPerformanceLevel 2013-12-30 06:10:14 +01:00
Pawel Dziepak
046af755d0 x86: Fix stack corruption in cache topology detection 2013-12-30 06:10:14 +01:00
Pawel Dziepak
8aa1539bb0 scheduler: Strengthen CoreEntry::GetLoad() assertion 2013-12-30 06:10:14 +01:00
Pawel Dziepak
15a7f2046a kernel: Return CPU load in cpu_info 2013-12-29 22:47:06 +01:00
Pawel Dziepak
56c0f467b0 scheduler: Fix unused variable warnings 2013-12-29 22:47:05 +01:00
Pawel Dziepak
a47974dd06 scheduler: Use heap to determine highest priority thread 2013-12-29 19:24:01 +01:00