Commit Graph

6015 Commits

Author SHA1 Message Date
Pawel Dziepak
484e5c737f scheduler: profiler: Compare types larger than int properly 2013-12-29 19:19:21 +01:00
Pawel Dziepak
ef8e55a1d0 scheduler: Use single ended heap for CPU heap 2013-12-28 21:47:35 +01:00
Pawel Dziepak
712f37e19e scheduler: profiler: Use nanosecond as a main time unit 2013-12-28 21:03:43 +01:00
Pawel Dziepak
ca9137de37 scheduler: Profile RunQueue implementation 2013-12-28 20:46:22 +01:00
Pawel Dziepak
4c25fcab38 scheduler: Fix double release of run queue lock 2013-12-28 20:11:30 +01:00
Pawel Dziepak
f68a486001 scheduler: Ignore time used by the profiler implementation 2013-12-28 18:55:39 +01:00
Pawel Dziepak
65d28952ae scheduler: Make sure RunQueueLink::{fPrevious, fNext} are valid 2013-12-26 22:07:26 +01:00
Pawel Dziepak
335c60552c scheduler: Remove CPUEntry::IncreaseActiveTime() 2013-12-26 19:56:50 +01:00
Pawel Dziepak
9a6868d565 x86: Fix build with kernel debugging disabled 2013-12-26 19:55:33 +01:00
Pawel Dziepak
96dcc73b39 scheduler: Add scheduler profiler
A bit hackish implementation of a profiler for the scheduler.
SCHEDULER_ENTER_FUNCTION at the begining of each function aren't nice and
usage of __PRETTY_FUNCTION__ isn't any better (both gcc and clang support
it though), but it was quick to implement and doesn't lose information
on inlined functions. It's just a tool, not an integral part of the kernal
anyway.
2013-12-26 19:40:50 +01:00
Pawel Dziepak
ebe5420f84 scheduler: No need for gQuantumLengths to be global 2013-12-26 19:40:50 +01:00
Pawel Dziepak
cf4984f645 scheduler: Use precomputed time slice lengths 2013-12-23 22:49:12 +01:00
Pawel Dziepak
ede552ab25 scheduler: Keep thread effective priority cached 2013-12-23 22:06:33 +01:00
Pawel Dziepak
b24ea642d7 scheduler: Encapsulate ThreadData fields 2013-12-23 21:32:21 +01:00
Pawel Dziepak
a08b40d408 scheduler: Encapsulate CPUEntry fields 2013-12-23 20:15:16 +01:00
Pawel Dziepak
e1e7235c60 scheduler: Encapsulate CoreEntry fields 2013-12-23 18:27:10 +01:00
Pawel Dziepak
5a69ffc01e scheduler: Remove RunQueue::PeekSecondMaximum() 2013-12-23 03:51:02 +01:00
Pawel Dziepak
60e198f2cb scheduler: Encapsulate PackageEntry fields
Apart from the refactoring this commit takes the opportunity and removes
unnecessary read locks when choosing a package and a core from idle lists.
The data structures are accessed in a thread safe way and it does not really
matter whether the obtained data becomes outdated just when we release the
lock or during our search for the appropriate package/core.
2013-12-23 00:56:44 +01:00
Pawel Dziepak
cf21c40b50 x86: Fix style
Thanks Axel.
2013-12-23 00:09:03 +01:00
Pawel Dziepak
b89b5d3826 x86: Make arch/smp.h a C++ only header 2013-12-20 22:05:26 +01:00
Pawel Dziepak
9116eec24c scheduler: Allow calling UpdatePriority() for disabled CPU 2013-12-20 05:40:59 +01:00
Pawel Dziepak
b4552fcf9b x86: Remove debug message 2013-12-20 05:40:59 +01:00
Pawel Dziepak
73363f8dde kernel/vm: Fix unsigned/signed comparison warning 2013-12-20 05:40:59 +01:00
Pawel Dziepak
c08ed2db65 scheduler: Try to keep thread on the same logical CPU
Some SMT implementations (e.g. recent AMD microarchitectures) have
separate L1d cache for each SMT thread (which AMD decides to call "cores").
This means that we shouldn't move threads to another logical processor too
often even if it belongs to the same core. We aren't very strict about
this as it would complicate load balancing, but we try to reduce unnecessary
migrations.
2013-12-20 03:36:01 +01:00
Pawel Dziepak
ad6b9a1df8 scheduler: Use sequential locks instead of atomic 64 bit access 2013-12-20 02:18:44 +01:00
Pawel Dziepak
b258298c70 kernel: Protect cpu_ent::active_time with sequential lock
atomic_{get, set}64() are problematic on architectures without 64 bit
compare and swap.
Also, using sequential lock instead of atomic access ensures that
any reads from cpu_ent::active_time won't require any writes to shared
memory.
2013-12-20 01:31:32 +01:00
Pawel Dziepak
6639514437 x86[_64]: Support assigning MSI IRQs to arbitrary CPU 2013-12-20 01:07:08 +01:00
Pawel Dziepak
3add52e8ba kernel: Fix topology node count being decreased twice per node 2013-12-19 20:24:34 +01:00
Pawel Dziepak
e3d001ff02 x86: Implement multicast ICIs 2013-12-19 19:35:44 +01:00
Jonathan Schleifer
e3e0255008 rootfs.cpp: Replace undefined behaviour with offsetof.
Signed-off-by: Axel Dörfler <axeld@pinc-software.de>
2013-12-19 01:52:33 +01:00
Jonathan Schleifer
c7cb9b2f59 delete_driver_settings.cpp: Get rid of the weak alias.
As weak aliases are not supported on OS X, this caused problems when
building Haiku on OS X, as this file is also used for the host tools.

Signed-off-by: Axel Dörfler <axeld@pinc-software.de>
2013-12-19 01:52:33 +01:00
Pawel Dziepak
5a7289d720 scheduler: Fix unassigning threads from core being disabled 2013-12-18 00:03:56 +01:00
Pawel Dziepak
1b06228f13 kernel: Propagate scheduler modes to cpu{freq, idle} modules 2013-12-17 23:26:37 +01:00
Pawel Dziepak
4fcbac58de kernel: Make get_cpu_topology() return a pointer to const
The client code is not supposed to change the topology info.
It would be also nice if cpu_topology_node::children was an array of
pointers to const but that would require several const_casts in the
topology tree generation code so it's probably not worth it.
2013-12-17 22:08:18 +01:00
Pawel Dziepak
735f67481f x86: Debugger can now use dr3 2013-12-17 04:31:29 +01:00
Pawel Dziepak
a5b070f1fa x86: Store pointer to the current thread in gs:0
Apparently, reading from dr3 is slower than reading from memory
with cache hit.

Also, depending on hypervisor configuration, accessing dr3 may cause
a VM exit (and, at least on kvm, it does), what makes it much slower
than a memory access even when there is a cache miss.
2013-12-17 04:08:51 +01:00
Pawel Dziepak
611376fef7 x86: Let each CPU have its own GDT 2013-12-17 03:57:20 +01:00
Pawel Dziepak
d02aaee17e kernel, libroot: Add more memory info in system_info
system_info now contains all information previously available only
through __get_system_info_etc(B_MEMORY_INFO, ...).
2013-12-16 04:53:46 +01:00
Pawel Dziepak
1bc7045fdf kernel, libroot: Introduce new API for obtaining system info 2013-12-16 03:58:43 +01:00
Pawel Dziepak
8cf2f36c37 libroot: Fix Hoard when the CPU count is not a power of two 2013-12-12 21:14:25 +01:00
Pawel Dziepak
82727571c3 libroot: Fix uninitialized counter in mutex_lock() 2013-12-12 04:00:56 +01:00
Pawel Dziepak
53aac05ee5 libroot: Add prototypes for __{get,set}_scheduler_mode 2013-12-12 03:56:33 +01:00
Pawel Dziepak
02749e2429 x86/paging: Do not use array placement new
Array placement new has implementation defined memory overhead what
makes it pretty useless.
2013-12-11 01:59:31 +01:00
Ingo Weinhold
781671ad5b dump_mapping_info(): Remove problematic initializer
Fixes gcc 2 build.
2013-12-10 23:17:43 +01:00
Ingo Weinhold
c259766f94 KDL "mapping" command: Allow specifying a thread ID
... instead of only a team ID.
2013-12-10 19:13:56 +01:00
Ingo Weinhold
5d3978dbe7 KDL "mapping" command: Fix argument check
It wasn't possible to actually specify the second argument (team ID).
2013-12-10 19:13:08 +01:00
Ingo Weinhold
a3fe978f8a boot loader: Always show 4 GB memory limit safemode option
On x86 we mainly want to disable PAE, which is now also used with less
memory as long as NX support is available. Ideally we'd check this
condition as well and only add the menu item, if the kernel would
enable PAE.
2013-12-10 19:12:16 +01:00
Ingo Weinhold
fc7801bc6f boot loader: apply_boot_settings(): Replace string literal 2013-12-10 19:08:07 +01:00
Ingo Weinhold
647b768f54 x86: Disable PAE, if 4 GB memory limit safemode is set 2013-12-10 19:07:01 +01:00
Ingo Weinhold
9bdb5e0a92 kernel safemode: Add functions to get options early
Add get_safemode_option_early() and get_safemode_boolean_early() to get
safemode options before the kernel heap has been initialized. They use a
simplified parser.
2013-12-10 19:05:47 +01:00
François Revol
e36ad522d6 Fix 24d0e21f51 correctly
CreateSubRequest() could still return an error and break out of the
while loop without exiting the outer for loop.

Instead we reset the error code before entering the for loop.
2013-12-08 11:34:07 +01:00
François Revol
664e3fba9b Partially revert 24d0e21f51
This reverts the extra for loop condition from
"do_iterative_fd_io_iterate(): Support sparse files".

When reading a file with more than 8 block_runs, get_vecs() would
return B_BUFFER_OVERFLOW which would never create any subrequest due
to the test on error == B_OK on the loop, but instead just fail.

Except for the get_vecs() return code, where it is not wanted,
the test made no sense as all other assignments are tested directly
or passed around with break.

Works for me but I don't guarantee it's completely correct.
2013-12-08 01:43:02 +01:00
Ingo Weinhold
00b42dde0d FD kernel tracing: Capture kernel-only stack traces
* When exec()'ing we'd otherwise get (harmless but annoying) messages
  from vm_page_fault(). With syscall tracing enabled we can get userland
  stack traces anyway.
* Simplify by using TRACE_ENTRY_SELECTOR().
2013-12-07 15:44:22 +01:00
Ingo Weinhold
0a4cbd786c X86VMTranslationMapPAE: Extend kernel tracing
* Beside the physical address also print the PTE flags.
* Also trace Protect(), ClearFlags(), ClearAccessedAndModified().
2013-12-07 15:44:22 +01:00
Ingo Weinhold
3c70914f66 ktracing: TraceOutput::PrintStackTrace(): Fix duplication 2013-12-07 15:44:22 +01:00
Michael Lotz
57d8dd92ef pthread_join: Retry when interrupted as mandated by POSIX.
The spec explicitly states that pthread_join shall not return EINTR, so
we have to retry the wait when it gets interrupted instead of letting
the error code through.
2013-12-07 14:15:05 +00:00
Pawel Dziepak
bcfdf88186 apps, kernel: Remove B_MAX_CPU_COUNT 2013-12-06 21:57:58 +01:00
Pawel Dziepak
fd96cf08a7 libroot: Remove _SC_NPROCESSORS_MAX and _SC_CPUID_MAX
_SC_NPROCESSORS_MAX and _SC_CPUID_MAX appear to be supported only by
Solaris. There isn't much point in exposing such values to the userland
anyway.
2013-12-06 21:54:07 +01:00
Pawel Dziepak
f6b71d5518 libroot/malloc: Do not use B_MAX_CPU_COUNT 2013-12-06 21:05:05 +01:00
Pawel Dziepak
3106f832a9 kernel/smp: Fix warning 2013-12-06 19:57:04 +01:00
Pawel Dziepak
e6ea745e81 kernel: Use SMP_MAX_CPUS instead of B_MAX_CPU_COUNT 2013-12-06 19:53:56 +01:00
Pawel Dziepak
3e0e3be760 boot, kernel: Replace MAX_BOOT_CPUS with SMP_MAX_CPUS 2013-12-06 19:43:08 +01:00
Ingo Weinhold
dac7b7c980 Fix various 64 bit related warnings
Mostly printf() format strings and signed-unsigned comparisons.
Fixes the x86_64 build.
2013-12-06 14:17:58 +01:00
Pawel Dziepak
2b04d8ab31 x86/paging: Use CPUSet instead of cpu_mask_t 2013-12-06 03:27:48 +01:00
Pawel Dziepak
e052b3e630 x86/paging: Remove unusued local variable 2013-12-06 03:11:42 +01:00
Pawel Dziepak
5c7f09c4d7 kernel/util: Bitmap: Silence warning 2013-12-06 03:10:50 +01:00
Pawel Dziepak
7629d527c5 kernel: Use CPUSet in ICI code instead of cpu_mask_t 2013-12-06 03:08:39 +01:00
Pawel Dziepak
5f3798921f x86/paging: Use ROUNUP() to compute the number of initial slots 2013-12-05 23:33:03 +01:00
Pawel Dziepak
730882d615 kernel: Remove RunQueueLink.h 2013-12-05 23:28:42 +01:00
Pawel Dziepak
52b442a687 kernel: smp_cpu_rendezvous(): Use counter instead of bitmap 2013-12-05 23:10:04 +01:00
Pawel Dziepak
d287274dce scheduler: Code refactoring 2013-12-05 22:47:30 +01:00
Ingo Weinhold
736fe5bc63 Fix build with TRANSLATION_MAP_TRACING enabled 2013-12-05 21:44:54 +01:00
Ingo Weinhold
372b309a4a X86VMTranslationMapPAE: Fix gcc 2 warning
... which due to the reactivated -Werror causes the build to fail.
2013-12-05 20:42:06 +01:00
Ingo Weinhold
7b83ce1142 Add KDL command "mapping"
* VMTranslationMap:
  - Add DebugPrintMappingInfo(): Given a virtual address it is supposed
    to print the paging structure information for that address. To be
    implemented by derived classes.
  - Add DebugGetReverseMappingInfo(): Given a physical addresss it is
    supposed to find all virtual addresses mapped to it. To be
    implemented by derived classes.
* X86VMTranslationMapPAE: Implement the new methods
  DebugPrintMappingInfo() and DebugGetReverseMappingInfo().
* Add KDL command "mapping". It supports both virtual address lookups
  and reverse lookups.
2013-12-05 05:13:21 +01:00
Pawel Dziepak
2e3cbcfa8a x86: Allocate as much initial physical page pools as needed 2013-12-02 03:19:25 +01:00
Ingo Weinhold
e551626f40 Implement support for a SYS:ENV attribute on executable
__flatten_process_args() does now have the executable path as an
additional (optional) parameter. If specified, the function will read
the file's SYS:ENV attribute (if set) and use its value to modified the
environment it is preparing for the new process. Currently supported
attribute values are strings consisting of "<var>=<value>" substrings
separated by "\0" (backslash zero), with '\' being used as an escape
character. The environment will be altered to contain the specified
"<var>=<value>" elements, replacing a preexisting <var> element (if
any).

A possible use case would be setting a SYS:ENV attribute with value
"DISABLE_ASLR=1" on an executable that needs ASLR disabled.
2013-12-01 18:34:07 +01:00
Ingo Weinhold
7bf85edf58 Allow disabling ASLR via DISABLE_ASLR environment variable
* VMAddressSpace: Add randomizingEnabled property.
* VMUserAddressSpace: Randomize addresses only when randomizingEnabled
  property is set.
* create_team_arg(): Check, if the team's environment contains
  "DISABLE_ASLR=1". Set the team's address space property
  randomizingEnabled accordingly in load_image_internal() and
  exec_team().
2013-12-01 02:51:50 +01:00
Ingo Weinhold
84ed99c2aa mmap(): Fix !MAP_FIXED with non-NULL address case
In that case the caller ideally wants to obtain an allocation at the
specified address, which was thwarted by using
B_RANDOMIZED_BASE_ADDRESS. Use B_BASE_ADDRESS instead.

This improves the experience with the gcc 4 pre-compiled headers
implementation (which expects to be able to map the PCH file at the same
address where it was located originally when it had been created), but
doesn't fix it completely. As long as ASLR is active, it is always
possible that something else (mapped shared objects, heap, stack) is in
the way.
2013-12-01 00:58:28 +01:00
Ingo Weinhold
97a4e3202f VMUserAddressSpace: Use align_address() instead of ROUNDUP()
Mainly for aesthetical reasons.
2013-12-01 00:46:41 +01:00
Ingo Weinhold
6c41755609 VMUserAddressSpace::_InsertAreaSlot(): Fix base address handling
Unless a free range was found before the first area a specified base
address was ignored. In the non-randomized case this could result in
a range other than (i.e. starting before) the preferred one being
chosen, although the preferred range was available.
2013-12-01 00:44:58 +01:00
Ingo Weinhold
7b96ce222a VMUserAddressSpace: Small coding style fixes 2013-11-30 23:17:34 +01:00
Ingo Weinhold
93e99b6113 VMUserAddressSpace: Use std::min/max instead of min/max_c 2013-11-30 23:13:48 +01:00
Ingo Weinhold
65947ae5ae boot loader: blacklist menu: Set different title when disabled
When booting from CD (or when no boot volume has been selected)
blacklisting isn't supported. In that case let the menu title indicated
that.
2013-11-30 19:58:41 +01:00
Ingo Weinhold
ccfc7bea50 boot loader: blacklist menu: Add "Return to ..." item 2013-11-30 19:56:13 +01:00
Ingo Weinhold
cbfc38c62d boot loader: MenuItem: Add SetLabel() 2013-11-30 19:39:57 +01:00
Ingo Weinhold
2a368f9b0e boot loader: text menu: run_menu(): Fix empty menu crash 2013-11-30 19:25:56 +01:00
Ingo Weinhold
aea2cb917e device_manager: Implement unpublish_device() 2013-11-30 17:02:49 +01:00
Ingo Weinhold
28092be196 devfs: Add devfs_{get,put}_device()
devfs_get_device() returns the device for a given path (if any), also
acquiring a reference to its vnode (thus ensuring the device won't go
away). devfs_put_device() puts the device vnode's reference.
2013-11-30 17:02:48 +01:00
Ingo Weinhold
e26c3df48c devfs: Remove superfluous create() hook
We don't support creation of files and the VFS calls open() when an
entry already exists.
2013-11-30 17:02:48 +01:00
Pawel Dziepak
255b601750 scheduler: Do not send reschedule ICI when not needed 2013-11-29 21:40:25 +01:00
Pawel Dziepak
2b7ea4cddf kernel: Remove Thread::next_state 2013-11-29 19:31:10 +01:00
Pawel Dziepak
c19f1e4fbb scheduler: Add missing check for real time threads 2013-11-29 18:09:56 +01:00
Pawel Dziepak
673f08a995 kernel: Make thread_block_locked() private 2013-11-29 05:30:50 +01:00
Pawel Dziepak
0721899709 scheduler: Allow mode to specify time slice length 2013-11-29 05:11:44 +01:00
Pawel Dziepak
7f8cf14b71 scheduler, kernel/util: Fix style issues 2013-11-29 04:51:38 +01:00
Pawel Dziepak
1987bf19b5 scheduler: Update CPU disabling code to match recent changes 2013-11-29 04:35:50 +01:00
Pawel Dziepak
1ee1d0cbab kernel, drivers: Fix gcc2 build 2013-11-29 03:47:38 +01:00
Pawel Dziepak
3514fd77f7 kernel: Reduce lock contention when processing ICIs 2013-11-29 03:36:44 +01:00
Pawel Dziepak
e736a456ba kernel: Forbid implicit casts between spinlock and int32 2013-11-29 03:36:31 +01:00
Pawel Dziepak
7b4befcd47 scheduler: Introduce upper bound on latency 2013-11-29 03:28:28 +01:00
Pawel Dziepak
f2243876df scheduler: Remove some unnecessary checks against idle threads 2013-11-28 17:53:19 +01:00
Pawel Dziepak
f9ee217ad6 scheduler: Migrate threads less often in power saving mode 2013-11-28 16:33:50 +01:00
Pawel Dziepak
286b341a40 kernel: Merge two occurences of thread resume code 2013-11-28 14:03:57 +01:00
Pawel Dziepak
87115715b4 scheduler: Protect package data with rw_spinlock 2013-11-27 04:57:26 +01:00
Pawel Dziepak
9caf7f4fb9 scheduler: Update estimate_max_scheduling_latency() 2013-11-27 04:15:36 +01:00
Pawel Dziepak
7d7dc357bf scheduler: Move simple inline functions to scheduler_common.h 2013-11-27 03:50:43 +01:00
Rene Gollent
09a8919213 InstallationLocations: Add missing static specifiers.
- Fixes a crash in find_paths() due to the InstallationLocations object getting overwritten.

Thanks to Chris Roberts for reporting.
2013-11-26 21:45:35 -05:00
Pawel Dziepak
28da7e985f scheduler: Improve debug commands 2013-11-27 03:36:06 +01:00
Pawel Dziepak
22ae68fa69 scheduler: Simplify thread priority penalties 2013-11-27 03:19:44 +01:00
Ingo Weinhold
8d23c440f7 runtime loader: Add support for $ORIGIN in rpath
Like in Linux it resolves to the directory of the shared object whose
needed library is to be loaded.
2013-11-26 16:40:42 +01:00
Pawel Dziepak
b41eaf299a scheduler_set_thread_priority: Fix null dereference 2013-11-26 03:40:32 +01:00
Pawel Dziepak
35153d1c49 scheduler: Send reschedule ICI after enqueueing the thread 2013-11-26 03:03:41 +01:00
Pawel Dziepak
7db89e8dc3 kernel: Rework cpuidle module
* Create new interface for cpuidle modules (similar to the cpufreq
   interface)
 * Generic cpuidle module is no longer needed
 * Fix and update Intel C-State module
2013-11-25 23:50:27 +01:00
Ingo Weinhold
f170a888c2 FIFO: Handle user reads/writes more correctly
* Determine whether called from userland or kernel.
* Check the buffer address via IS_USER_ADDRESS(), if from userland.
* Simplify things by merging UserRead() with Read() and
  UserWrite() with Write().
2013-11-25 16:08:00 +01:00
Ingo Weinhold
8019fdbab8 FIFO: Implement FION{BIO,READ}, B_SET_[NON]BLOCKING_IO ioctls 2013-11-25 16:08:00 +01:00
Ingo Weinhold
fd0bfd5593 FIFO: More correct locking when accessing file_cookie::open_mode 2013-11-25 16:08:00 +01:00
Ingo Weinhold
38b150a9de VFS FIFO: Add "fifo" KDL command
Prints information about a FIFO node and, optionally, its data buffer
content.
2013-11-25 12:45:37 +01:00
Ingo Weinhold
fb52b1f8b4 VFS FIFO: Enlarge FIFO buffer sizes
* Increase FIFO buffer capacity from 32 to 64 KiB and the FIFO atomic
  write size ({BUF_SIZE}) from 512 bytes to 4 KiB (both like Linux).
* Fix *pathconf(..., _PC_PIPE_BUF). It was returning 4 KiB although the
  implemented atomic write size was 512 bytes only. Now both *pathconf()
  and the FIFO implementation refer to the same constant.
2013-11-25 12:45:37 +01:00
Ingo Weinhold
334ae3c73b VFS FIFO: Fix RingBuffer::Read()/Write() return types
size_t -> ssize_t, since they may actually return an error code.
2013-11-25 12:45:37 +01:00
Ingo Weinhold
dd11460a49 Add a hex dump utility for use in KDL commands 2013-11-25 12:45:36 +01:00
Pawel Dziepak
0e94a12f8e kernel: Make CACHE_LINE_ALIGN visible in the whole kernel 2013-11-25 00:35:15 +01:00
Pawel Dziepak
26970784cd scheduler: Clean scheduler_common.h
scheduler_common.h is now meant for types, variables and functions used
by both core scheduler code and implementations of scheduler modes.
Functions like switch_thread() and update_thread_times() do not belong
there anymore.
2013-11-25 00:17:42 +01:00
Pawel Dziepak
1e8ed5558d cpufreq: Rank modules and choose the best one 2013-11-25 00:08:13 +01:00
Pawel Dziepak
13a89839fc scheduler: Fix power saving mode and other minor improvements 2013-11-24 23:51:30 +01:00
Pawel Dziepak
f95b6fdfc8 scheudler: Do not include irq load in thread load 2013-11-24 23:18:58 +01:00
Pawel Dziepak
cec16c2dcf spinlock: Fix panic messages
Thanks Jérôme for pointing this out.
2013-11-24 22:54:14 +01:00
Pawel Dziepak
03f7d3d1db kernel: Restore logical processor disabling 2013-11-24 22:51:07 +01:00
Ezo
7f6991c35e Fixed resource leak and possible strings corruption
Signed-off-by: Ingo Weinhold <ingo_weinhold@gmx.de>
2013-11-22 13:44:10 +01:00
Pawel Dziepak
7c7b9b795b scheduler: Return time stolen by irq and ipi handlers 2013-11-22 04:25:37 +01:00
Pawel Dziepak
1a7eb50254 scheduler: Calculate correct load on SMT processors 2013-11-22 03:20:19 +01:00
Pawel Dziepak
65741c8b56 scheduler: Improve locking 2013-11-22 03:00:08 +01:00
Pawel Dziepak
4ec76fd89d libroot: {g,s}et_scheduler_mode(): Avoid name clash
Thanks Ingo for pointing this out.
2013-11-21 21:51:46 +01:00
Ingo Weinhold
23c521cf5e find_path*(): Improve B_FIND_PATH_IMAGE_PATH handling
* get_file_attribute(): Use O_NOTRAVERSE, so we correctly read the
  attribute from symlinks.
* internal_path_for_path(): Shuffle things around a bit: The dependency
  is resolved before handling B_FIND_PATH_PACKAGE_PATH, now. This adds
  support for getting the package file for a dependency. The dependency
  was ignored in this case before.
* Use kSystemPackageLinksDirectory instead of hard-coding "/packages".
2013-11-21 13:29:20 +01:00
Pawel Dziepak
14e36af649 kernel[/util]: Fix debug builds 2013-11-21 03:24:54 +01:00
Pawel Dziepak
024541a4c8 kernel: Improve rw_spinlock implementation
* Add more debug checks
 * Reduce the number of executed instructions that lock the bus.
2013-11-21 02:25:03 +01:00
Pawel Dziepak
6fb61d001a scheduler: Preallocate temporary heaps for debug commands 2013-11-21 00:59:40 +01:00
Pawel Dziepak
308f594e2a kernel, libroot: Make scheduler modes interface public 2013-11-20 23:32:40 +01:00
Pawel Dziepak
cd1e7814a9 scheduler: Reduce scheduler mode lock cache bouncing 2013-11-20 21:49:31 +01:00
Pawel Dziepak
683b9bbf07 scheduler: Improve power saving mode, part 2
Consequences of committing & pushing too quickly...
2013-11-20 21:21:31 +01:00
Pawel Dziepak
ecfd444935 scheduler: Improve power saving mode
* Remove possibility to temporarily disable small task packing.
 * When small task packing target gets overloaded continue packing
   threads on another core, but avoid migrating the already packed
   ones.

Scheduler still tends to needlessly migrate threads to another cores
when under heavier load, but it is now much better than before.
2013-11-20 20:52:11 +01:00
Pawel Dziepak
3eb4224bf6 kernel: Make sure mutex::holder is set to a valid value 2013-11-20 17:53:39 +01:00
Pawel Dziepak
57d5d678f2 x86_64: Fix atomic functions 2013-11-20 17:02:51 +01:00
Ingo Weinhold
c04f3a625a boot loader: Add safe mode blacklist submenu
It's a browser for the system package content, where entries can be
selected to blacklist them. The selected entries are removed from the
packagefs instance in the boot loader, so that e.g. selected drivers
won't be picked up. The paths are also added to the safe mode driver
settings and will be interpreted when the system packagefs instance is
mounted by the kernel.
2013-11-20 16:00:35 +01:00
Ingo Weinhold
f2620e4714 boot loader: add_safe_mode_settings(): Make parameter const 2013-11-20 16:00:34 +01:00
Ingo Weinhold
6c7abe9829 boot loader: Menu[Item] API improvements
* Make Menu and MenuItem polymorphic.
* MenuItem:
  - Make SetMarked() virtual, so it can be overridden.
  - Add SetSubmenu() and Supermenu().
  - Delete the submenu in the destructor.
* Menu:
  - Add Entered()/Exited() hooks. They frame the time the user navigates
    the menu or any of its submenus. The hooks allow for subclasses
    populating their item list dynamically.
  - Add SortItems().
* Update boot loader menu copyright text to include 2013, now that it is
  over soon. :-)
2013-11-20 16:00:34 +01:00
Pawel Dziepak
c4ac37a35e scheduler: Try to pack IRQs in power saving mode 2013-11-20 12:52:05 +01:00
Pawel Dziepak
9c2e74da04 scheduler: Move mode specific logic to separate files 2013-11-20 09:46:59 +01:00
Jérôme Duval
72950e7c15 runtime_loader: fixes the 64-bit build.
1/ error: no matching function for call to 'min(long unsigned int,
uint32&)'.
2/ error: comparison between signed and unsigned integer expressions.
2013-11-19 20:17:08 +01:00
Ingo Weinhold
3a7e0b0014 packagefs: Support blacklisting entries in packages
In each installation location, it is now possible to create a settings
file "packages" that allows to blacklist entries contained in packages.
The format is:

Package <package name> {
	EntryBlacklist {
		<entry path>
		...
	}
}
...

<package name> is the base name (no version) of the respective package
(e.g. "haiku"), <entry path> is an installation location relative path
(e.g. "add-ons/Translators/FooTranslator").

Blacklisted entries will be ignored by packagefs, i.e. they won't appear
in the file system. This addresses the issue that it may be necessary to
remove a problematic file (e.g. driver, add-on, or library), which would
otherwise require editing the containing package file.

The settings file is not not "live". Changes take effect only after
reboot (respectively when remounting the concerned packagefs volume).
2013-11-19 15:30:34 +01:00
Ingo Weinhold
2fdd1d9ef1 khash: Move string hash functions to own header/source file
Unlike khash they shouldn't be phased out (only renamed).
2013-11-19 15:08:34 +01:00
Ingo Weinhold
efe9df3791 driver settings: Add load_driver_settings_file()
Allows loading an already opened driver settings file (by FD).
2013-11-19 15:06:30 +01:00
Ingo Weinhold
cf09345cf5 driver settings: Remove dead load_driver_settings_from_path()
load_driver_settings() supports being passed an absolute path.
2013-11-19 14:02:21 +01:00
Ingo Weinhold
81522ad41b find_path_for_path_etc(): Fail for B_FIND_PATH_IMAGE_PATH
There's no image in this case. We would just return the path we were
given.
2013-11-19 02:05:35 +01:00
Ingo Weinhold
22e92014f0 s/B_FIND_PATH_IMAGE_PACKAGE_PATH/B_FIND_PATH_PACKAGE_PATH/
It doesn't only work for image files, so make the name more general.
2013-11-19 02:05:35 +01:00
Pawel Dziepak
e2ff9a2865 scheduler: Rebalance IRQs on overloaded cores 2013-11-18 07:05:35 +01:00
Pawel Dziepak
f14e4567e8 kernel: Use CPU topology to distribute IRQs 2013-11-18 05:37:45 +01:00
Pawel Dziepak
d897a478d7 kernel: Allow reassigning IRQs to logical processors 2013-11-18 04:55:25 +01:00
Ingo Weinhold
94fb954c53 find_path*(): Support user specific home directory
No longer hard-code the home directory path. Instead ask
find_directory(), so we get the correct one for the current user.
2013-11-18 01:50:49 +01:00
Pawel Dziepak
955c7edec2 kernel: Measure time spent in interrupt handlers 2013-11-18 01:50:37 +01:00
Pawel Dziepak
6a164daad4 kernel: Track load produced by interrupt handlers 2013-11-18 01:17:44 +01:00
Ingo Weinhold
04c6cb37bb find_directory(): Add architecture support
* Move PathBuffer helper class out of find_paths.cpp into its own
  header.
* find_directory():
  - Make use of MemoryDeleter to simplify things.
  - Make use of PathBuffer for a simpler and more correct handling.
  - Make B_UTILITIES_DIRECTORY to B_APPS_DIRECTORY. /boot/utilities
    doesn't exist anyway.
  - Resolve the concerned constants to the architecture specific
    subdirectory, when called in a secondary architecture context, just
    like find_path*().
2013-11-17 19:11:03 +01:00
Ingo Weinhold
7fb0d6c269 find_path*(): Fix B_FIND_PATH_MEDIA_NODES_DIRECTORY
It is architecture specific as well.
2013-11-17 19:11:02 +01:00
Ingo Weinhold
8a3fe6d1bf Add private __getenv_reentrant()
A reentrant variant of getenv().
2013-11-17 19:11:02 +01:00
Ingo Weinhold
c39c9283aa Add get_architectures() and C++ versions
* get_architectures() returns the primary and the secondary
  architectures in one array. That turned out to be convenient.
* Add C++ versions for get[_secondary]_architectures(), returning a
  BStringList.
2013-11-17 02:09:37 +01:00
Ingo Weinhold
60b39cd741 Add get_*architecture() API, extend find_path*() API
* Add get_architecture(), get_primary_architecture(),
  get_secondary_architectures(), guess_architecture_for_path() to get
  the caller's architecture, the primary architecture, all secondary
  architectures, or the architecture associated with a specified path
  respectively.
* Rename the find_path*() functions to find_path*_etc() and add an
  optional architecture parameter. Add simplified find_path*()
  functions.
* BPathFinder: Add FindPath[s]() versions with an architecture
  parameter.
2013-11-17 02:09:36 +01:00
Ingo Weinhold
cf7e2ad812 runtime loader: Export get_executable_architecture() function
Given a path of an ELF file, it tries to determine its architecture.
2013-11-17 02:09:36 +01:00
Axel Dörfler
04da290fd6 Minor cleanup. 2013-11-15 23:13:54 +01:00
Pawel Dziepak
288a2664a2 scheduler: Remove sSchedulerInternalLock
* pin idle threads to their specific CPUs
 * allow scheduler to implement SMP_MSG_RESCHEDULE handler
 * scheduler_set_thread_priority() reworked
 * at reschedule: enqueue old thread after dequeueing the new one
2013-11-13 05:31:58 +01:00
Ingo Weinhold
2b269f2e47 unlock_memory_etc(): Fix address space reference leak
unlock_memory_etc() is supposed to release the address space reference
lock_memory_etc() acquired. It didn't do that, though.
2013-11-13 01:47:36 +01:00
Ingo Weinhold
93fb0ff056 vm: lock_memory_etc(): Fix error case
In case something went wrong, call unlock_memory_etc() with the rounded
base address instead of with the original address. If the original
address wasn't page aligned, unlock_memory_etc() would otherwise try to
unlock an additional page.
2013-11-13 01:47:35 +01:00
Pawel Dziepak
72e1b394a4 scheduler: Fix gcc2 build 2013-11-13 00:36:48 +01:00
Pawel Dziepak
5f3a65e578 scheduler: Remove sCorePriorityHeap
sCorePriorityHeap was meant to be a temporary solution anyway. Thread
migration and assignment is now entirely based on core load.
2013-11-13 00:01:02 +01:00
Pawel Dziepak
829f836324 scheduler: Minor cleanup 2013-11-12 04:42:12 +01:00
Pawel Dziepak
8818c942dd scheduler: Add {CPU,Core,Package}Entry constructors 2013-11-12 04:26:32 +01:00
Pawel Dziepak
e1c40769d3 scheduler: Atomically access time and load measurements 2013-11-12 04:23:42 +01:00
Ingo Weinhold
104c0688da dir_vnode_to_path(): Fix uninitialized status variable 2013-11-11 23:04:09 +01:00
Ingo Weinhold
24d0e21f51 do_iterative_fd_io_iterate(): Support sparse files
* Check whether the vectors we get are sparse file vectors and satisfy
  them immediately instead of creating a subrequest. Untested, since the
  API isn't used by ext2 as it should be.
* Add error == B_OK to the condition of the outer loop.
2013-11-11 22:27:53 +01:00
Ingo Weinhold
9f7e78ee79 IORequest::Init(): Assert offset >= 0
Just to make sure we catch sparse file vectors that shouldn't be passed
here.
2013-11-11 22:27:53 +01:00
Ingo Weinhold
c63b3de665 IORequest: Add ClearData() 2013-11-11 22:27:53 +01:00
Ingo Weinhold
426fe7db1d IORequest::_CopyData(): Small optimization
If we're running in the context of the user team the I/O buffer belongs
to, we can use _CopySimple() as well.
2013-11-11 22:27:53 +01:00
Ingo Weinhold
07f6506eb6 VFS: Fix broken zero_pages()
Besides that it failed to actually iterate through the vectors, it
shouldn't try to clear physical memory in the first place. The iovecs
refer to virtual address ranges. Rename it to zero_iovecs() to avoid
confusion.
2013-11-11 22:27:52 +01:00
Ingo Weinhold
e5f6591382 VM: vm_memset_physical(): Correct length parameter type 2013-11-11 22:27:52 +01:00
Pawel Dziepak
d17b71d6b0 scheduler: Reduce false sharing of per-CPU and per-core data 2013-11-11 21:46:18 +01:00
Pawel Dziepak
a1feba678d kernel/undertaker: Make sure the thread isn't running anymore 2013-11-11 21:04:38 +01:00
Jérôme Duval
e94bffa072 vm: allocate wrappers on the heap with small stack array fallback
see comments on #10169. Thanks Ingo for reviewing!
2013-11-11 18:34:14 +01:00
Olivier Coursière
be6d2f97cd libroot: Accept NULL for the resolved_name argument of realpath()
as specified in IEEE Std 1003.1, 2013 Edition, see
http://pubs.opengroup.org/onlinepubs/9699919799/functions/realpath.html

In this case, the returned buffer is allocated with realpath() and can be
deallocated by the caller with free().
The behavior was only "implementation defined" in previous revisions like
IEEE Std 1003.1, 2004 Edition, see
http://pubs.opengroup.org/onlinepubs/000095399/functions/realpath.html

Signed-off-by: Jérôme Duval <jerome.duval@gmail.com>
2013-11-10 23:26:18 +01:00
Ingo Weinhold
18640f25d9 vfs: dir_vnode_to_path(): Fix bug with chroot on mount
Simplify the code, which also fixes the bug that the I/O context's root
was ignored when it was a mount point, thus resulting in globally rooted
paths in this case.
2013-11-10 15:43:43 +01:00
Jérôme Duval
7f0b39a791 CID 991479 Out-of-bounds access 2013-11-09 13:40:07 +01:00
Pawel Dziepak
7e1c4534df libroot: Add adaptive mutex implementation 2013-11-08 03:37:30 +01:00
Pawel Dziepak
03fb2d8868 kernel: Remove gSchedulerLock
* Thread::scheduler_lock protects thread state, priority, etc.
 * sThreadCreationLock protects thread creation and removal and list of
   threads in team.
 * Team::signal_lock and Team::time_lock protect list of threads in team
   as well.
 * Scheduler uses its own internal locking.
2013-11-08 02:41:26 +01:00
Pawel Dziepak
72addc62e0 kernel: Introduce Thread::time_lock and Team::time_lock 2013-11-07 22:16:36 +01:00
Pawel Dziepak
3519eb334a kernel: Change Thread::team_lock to rw_spinlock 2013-11-07 04:20:59 +01:00
Pawel Dziepak
defee266db kernel: Add read write spinlock implementation 2013-11-07 04:20:32 +01:00
Pawel Dziepak
20ded5c2eb kernel/posix: Do not use thread_block_locked() 2013-11-07 02:06:42 +01:00
Pawel Dziepak
d3e5752b11 scheduler: Performance mode is actually low latency mode 2013-11-07 01:50:20 +01:00
Pawel Dziepak
83983eaf38 kernel: Remove Thread::alarm 2013-11-07 01:40:02 +01:00
Pawel Dziepak
aa4aca0264 kernel: Protect signal data with Team::signal_lock 2013-11-07 01:32:48 +01:00
Pawel Dziepak
73ad2473e7 Remove remaining unnecessary 'volatile' qualifiers 2013-11-06 00:03:07 +01:00
Pawel Dziepak
273f2f38cd kernel: Improve spinlock implementation
atomic_or() and atomic_and() are not supported by x86 are need to be
emulated using CAS. Use atomic_get_and_set() and atomic_set() instead.
2013-11-05 22:47:18 +01:00
Pawel Dziepak
077c84eb27 kernel: atomic_*() functions rework
* No need for the atomically changed variables to be declared as
   volatile.
 * Drop support for atomically getting and setting unaligned data.
 * Introduce atomic_get_and_set[64]() which works the same as
   atomic_set[64]() used to. atomic_set[64]() does not return the
   previous value anymore.
2013-11-05 22:32:59 +01:00
Ingo Weinhold
986e4abce4 Add new API find_path[s](), find_path_for_path()
The new functions are meant to replace many uses of find_directory():
* find_paths() is supposed to be used when the directories of a certain
  kind in all installation directories are needed (e.g. font
  directories, add-on directory, etc.). Using this API makes code
  robust wrt addition or removal of installation locations.
* find_path() is supposed to be used when files/directories associated
  with a loaded program, library, or add-on need to be found (e.g. data
  files or global settings).
* find_path_for_path() is similar to find_path(), but it starts from a
  given path instead of an image.
2013-11-05 21:40:43 +01:00
Pawel Dziepak
e7dba861fd kernel: User{Event, Timer}: Use atomic access where necessary 2013-11-05 20:28:25 +01:00
Pawel Dziepak
f4b088a992 kernel: Protect UserTimers with sUserTimerLock 2013-11-05 05:36:05 +01:00
Pawel Dziepak
4824f7630b kernel: Add sequential lock implementation 2013-11-05 04:16:13 +01:00
Pawel Dziepak
958f6d00aa kernel: Make UserEvent::Fire() work without gSchedulerLock held 2013-11-04 23:53:20 +01:00
Pawel Dziepak
3c819aaa72 kernel: DPC: remove schedulerLocked argument 2013-11-04 23:51:18 +01:00
Pawel Dziepak
11cacd0c13 kernel: Remove thread_block_with_timeout_locked() 2013-11-04 23:45:14 +01:00
François Revol
0e1c6462de Merge branch 'sam460ex' 2013-11-04 17:04:49 +01:00
Pawel Dziepak
c2763aaffb kernel: Add spinlock for undertaker data 2013-10-31 02:34:09 +01:00
Pawel Dziepak
d8fcc8a825 kernel: Remove B_TIMER_ACQUIRE_SCHEDULER_LOCK flag
The flag main purpose is to avoid race conditions between event handler
and cancel_timer(). However, cancel_timer() is safe even without
using gSchedulerLock.

If the event is scheduled to happen on other CPU than the CPU that
invokes cancel_timer() then cancel_timer() either disables the event
before its handler starts executing or waits until the event handler
is done.

If the event is scheduled on the same CPU that calls cancel_timer()
then, since cancel_timer() disables interrupts, the event is either
executed before cancel_timer() or when the timer interrupt handler
starts running the event is already disabled.
2013-10-31 01:49:43 +01:00
Pawel Dziepak
c8dd9f7780 kernel: Add thread_unblock() and use it where possible 2013-10-30 03:58:36 +01:00
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
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
Ingo Weinhold
fdaba7aaa5 Skip boot device check sum test on CD boot
Whatever we read from the drive in the boot loader isn't what we can
read from the device later, so rather skip the check sum test for
identifying the boot device in the kernel when booting off CD. Fixes
#10147.
2013-10-28 01:18:23 +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
François Revol
b3025a8642 bootloader: M68K: Fix mmu_free()
Same bug as in ARM code...
2013-10-26 20:54:12 +02:00
François Revol
585830a55e bootloader: M68K: s/KERNEL_BASE/KERNEL_LOAD_BASE/ 2013-10-26 20:54:11 +02:00
François Revol
b086b8ad2d bootloader: ARM: Replace KERNEL_BASE with KERNEL_LOAD_BASE 2013-10-26 20:54:10 +02:00
François Revol
18041782fd bootloader: ARM: Fix mmu_free()
Allocation size was mixed up with page counts...
Allow freeing up to sNextVirtualAddress.
2013-10-26 20:54:00 +02:00
François Revol
9703c9cc30 bootloader: Add tracing to malloc_large() 2013-10-26 18:41:57 +02:00
Julian Harnath
7f64b301b1 Reduce lock contention in kernel port subsystem.
* Replace ports list mutex with R/W-lock.

* Move team port list protection to separate array of mutexes.
  Relieve contention on sPortsLock by removing Team::port_list from its
  protected items. With this, set_port_owner() only needs to acquire the
  sPortsLock for reading.

* Add another hash table holding the ports by name. Used by find_port()
  so it doesn't have to iterate over the list anymore.

* Use slab-based memory allocator for port messages. sPortQuotaLock was
  acquired on every message send or receive and was thus another point
  of contention. The lock is not necessary anymore.

* Lock for port hashes and Port::lock are no longer locked in a nested
  fashion to reduce chances of blocking other threads.

* Make operations concurrency-safe by adding an atomically accessed
  Port::state which provides linearization points to port creation and
  deletion. Both operations are now divided into logical and physical
  parts, the logical part just updating the state and the physical part
  adding/remove it to/from the port hash and team port list.

* set_port_owner() is the only remaining function which still locks
  Port::lock and one or two of sTeamListLock[] in a nested fashion.
  Since it needs to move the port from one team list to another and
  change Port::owner, there's no way around.

* Ports are now reference counted to make accesses to already-deleted
  ports safe.

* Should fix #8007.
2013-10-26 16:10:03 +02:00
Ingo Weinhold
a3a4302bea boot loader heap: Handle large allocations separately
Use platform_{allocate,free}_region() to allocate/free chunks >= 16 KiB.
This reduces the usage of our dedicated (and limited) heap region,
particularly since packagefs makes some larger temporary allocations
while reading the package file. Should fix #10136.
2013-10-26 05:10:16 +02:00
Ingo Weinhold
6ef9697b00 boot loader: packagefs: Fix memory leak on unmount
The PackageNodes weren't destroyed.
2013-10-26 05:03:55 +02:00
Ingo Weinhold
7b1dee3929 boot loader: Fix find_unique_check_sums()
Comparing the complete disk_identifer structure isn't helpful as long as
we don't (can't) compare it in the kernel as well. ATM we only check the
check sums there, so that's what we need to do here as well. This fixes
potential mix-ups when booting off one of multiple equally sized disks.
2013-10-26 02:48:18 +02:00
Ingo Weinhold
63d56be3d9 boot loader: BootVolume::SetTo(): Fix reference counting
We release the reference for fRootDirectory in Unset() but never
acquired one. Fixes crash when selecting a boot volume in the menu.
2013-10-26 01:44:11 +02:00
Pawel Dziepak
45ff530069 scheduler: Be more demanding when cancelling penalties 2013-10-25 04:12:13 +02:00
Jérôme Duval
2bd8cdc16b acpi: switch acpi_object from a struct to a union
* this way the size of acpi_object_type matches the size of ACPI_OBJECT
for 32-bit and 64-bit builds.
* adjust users of the type acpi_object_type.
2013-10-24 14:29:47 +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
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
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
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
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
François Revol
4c7a310ce1 OF: PPC: Check for bus-frequency on '/' first
As per PowerPC IEEE 1275-1994 binding v1.8 page 13.
2013-10-20 20:53:06 +02:00
François Revol
b96e57e885 Fix typo 2013-10-19 16:06:41 +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
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
François Revol
7cbc41ae32 U-Boot: Split fdt_support.cpp, move serial stuff to fdt_serial.cpp 2013-10-15 23:05:09 +02:00
François Revol
3f92e864a1 Style fixes 2013-10-15 22:17:55 +02:00
François Revol
b55cb439e7 U-Boot: pass around argv and /chosen/bootargs
Not really handled correctly yet, but at least they are passed.
2013-10-15 22:15:04 +02:00
François Revol
cf7f92c013 bootloader: Use stage2_args:arguments_count
The code probably doesn't work correctly yet though,
I believe only the last line will be taken into account.
2013-10-15 22:15:04 +02:00
François Revol
70b50f3865 bootloader: Set stage2_args:arguments_count when needed 2013-10-15 22:15:03 +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
François Revol
8fa75a8cca ARM: Add a fallback atomic_add() for bootloader
When ATOMIC_FUNCS_ARE_SYSCALLS atomic.S doesn't export it,
but it's used by packagefs.
2013-10-12 19:43:33 +02:00
Oliver Tappe
8b08992799 Implement shebang-fixup for /usr/bin/env to runtime_loader.
* silently replace invocations /usr/bin/env with /bin/env
2013-10-11 13:00:33 +02:00
Ingo Weinhold
28fcae227c Stage 1 boot loader: Load the first file matching haiku_loader*
This allows naming the boot loader package canoncically. Due to code
size limitations we cannot perform a more correct name check, but there
shouldn't be any other entries in the packages directory with a name
with "haiku_loader" prefix, anyway.
2013-10-10 00:40:10 +02:00
François Revol
c19c9e08ef libroot: Pass members to filter as on-target variable 2013-10-09 22:04:36 +02:00
François Revol
158604494b libroot: Style fix 2013-10-09 22:04:35 +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
Ingo Weinhold
066d508682 boot loader: Support loading haiku-*.hpkg
... i.e. properly canonically named Haiku system packages.
2013-10-09 03:48:25 +02:00
Ingo Weinhold
0262f55a51 boot loader heap: Remove left over debug variables 2013-10-09 03:48:25 +02:00
Pawel Dziepak
24dbeeddb2 kernel: Give longer time slice to lower priority threads 2013-10-09 02:25:21 +02:00
Pawel Dziepak
3e91b082c8 libroot: Do not rely on thread_yield() 2013-10-09 02:07:08 +02:00
Pawel Dziepak
879ceb60d8 kernel: Remove suporfluous casts 2013-10-09 01:45:07 +02:00
Pawel Dziepak
130000e068 kernel: Dump scheduler specific thread data 2013-10-09 01:37:00 +02:00
Pawel Dziepak
f256b4aca7 kernel: Use SimpleRunQueue as run queue type everywhere 2013-10-09 01:20:40 +02:00
Pawel Dziepak
0896565a6e kernel: Support sched_yield() properly
sched_yield() should not yield to the threads with lower priority.
2013-10-09 01:18:55 +02:00
François Revol
4d5508263e libroot: Properly fix linking with libgcc without cmdline overflow
Instead of listing all the objects we want from the libgcc archive
we just make a copy of it and remove those we don't want, and link
to it.

This should allow returning MAXLINE in jam to a sane value.
2013-10-08 23:34:57 +02:00
Pawel Dziepak
ee69e53630 kernel: Minor improvements, separate priority and yield logic 2013-10-08 21:36:49 +02:00
Ingo Weinhold
ea4f2ac2dc boot loader: Optimize heap implementation
* Increase general allocation alignment from 4 to 8 byte. That was even
  incorrect.
* Use a splay tree instead of a singly linked list to manage the free
  chunks. That increases the size of the per-chunk structure to manage
  the free chunks, i.e. the of minimally allocatable memory size (from
  align(sizeof(void*)) to align(3 * sizeof(void*))), but make finding
  and inserting chunks much faster.

Fixes #10063 respectively improves the situation significantly.
2013-10-08 21:03:50 +02:00
Ingo Weinhold
e1b63b4fb8 boot loader: mount_file_systems(): Fix warning 2013-10-08 21:03:50 +02:00
Ingo Weinhold
33def4258e boot loader: bios IA32: Add optional timestamps to debug output 2013-10-08 21:03:49 +02:00
Pawel Dziepak
9363e99b19 kernel: Remove Thread::next_priority 2013-10-08 20:21:35 +02:00
Pawel Dziepak
346e789a21 kernel: Fix style issues 2013-10-08 20:15:21 +02:00
Pawel Dziepak
94f4574d78 kernel: Move thread retrieving code to separate function 2013-10-08 20:13:10 +02:00
Pawel Dziepak
03e3a82953 kernel: Allow threads to yield CPU properly 2013-10-08 06:41:20 +02:00
Pawel Dziepak
bab69bdb47 kernel: Force high priority threads to yield less often 2013-10-08 04:53:30 +02:00
Pawel Dziepak
547b8c76c7 kernel: Cancel penalty only if the thread actually waits
Require the thread to give up CPU for at least one time slice before
cancelling its penalty.
2013-10-08 04:50:23 +02:00
Pawel Dziepak
21808e8f0b kernel: Limit maximum priority penalty
The maximum penalty the thread can receive is now limited depending on
the real thread priority. However, since it make it possible to starve
threads with priority lower than that limit. To prevent that threads
that have already earned the maximum penalty are periodically forced
to yield CPU to all other threads.
2013-10-08 02:54:58 +02:00
Pawel Dziepak
31e65090db kernel: Use standard compliant version of variadic macros 2013-10-08 01:34:55 +02:00