Commit Graph

3799 Commits

Author SHA1 Message Date
Ingo Weinhold
1a7d8045d0 gcc 2 build fix
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35177 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-19 20:04:54 +00:00
Ingo Weinhold
825566f82f * Split the slab allocator code into separate source files and C++-ified
things a bit.
* Some style cleanup.
* The object depot does now have a cookie that will be passed to the return
  hook.
* Fixed object_cache_return_object_wrapper() using the new cookie.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35174 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-19 19:13:25 +00:00
Stephan Aßmus
0ccd0a0b6f axeld+stippi:
When initializing driver settings, make sure to set the parameter count to 0,
because these settings have not been parsed yet. This allows us to safely free
the settings. Freeing the settings is triggered in load_driver_settings() if
we encounter settings which have been originally loaded by the boot_loader,
which might be stale. I think the bug would trigger for settings which had been
loaded by the boot_loader but had never been parsed.

With this change, I can use the userlandfs on all my machines.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35166 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-19 15:40:24 +00:00
Ingo Weinhold
0fc052b47d Moved the definition of the CACHE_ALIGN_ON_SIZE flag to the header and fixed
its value.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35163 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-19 10:17:16 +00:00
Ingo Weinhold
a8806e5e0d * Renamed headers/private/kernel/slab/Depot.h to ObjectDepot.h.
* Moved the object depot code to its own source file.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35161 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-19 10:12:48 +00:00
Ingo Weinhold
6379e53e2d vm_page no longer points directly to its containing cache, but rather to a
VMCacheRef object which points to the cache. This allows to optimize
VMCache::MoveAllPages(), since it no longer needs to iterate over all pages
to adjust their cache pointer. It can simple swap the cache refs of the two
caches instead.

Reduces the total -j8 Haiku image build time only marginally. The kernel time
drops almost 10%, though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35155 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-19 08:34:14 +00:00
Ingo Weinhold
3632eeedb9 * VMCache: Added a UserData attribute which can be used by the lock holder.
* Added "bool consumerLocked" parameter to VMCache::Unlock() and
  ReleaseRefAndUnlock(). Since Unlock() may cause the cache to be merged with
  a consumer cache, the flag is needed to prevent a deadlock in case the
  caller still holds a lock to the consumer. Hasn't been a problem yet, since
  that situation never occurred.
* VMCacheChainLocker: Reversed unlocking order to bottom-up. The other
  direction could cause a deadlock in case caches would be merged, since the
  locking order would be reversed. The way VMCacheChainLocker was used this
  didn't happen, though.
* fault_get_page(): While copying a page from a lower cache to the top cache,
  we do now unlock all caches but the top one, so we don't unnecessarily
  kill concurrency.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35153 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-19 03:02:11 +00:00
Jérôme Duval
585a28af7b I thought afterwards the stub can still be useful to run R5 C only binaries on a GCC4 Haiku. It might be better placed in the arch folder though.
Also fixed a typo.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35146 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-18 22:32:57 +00:00
Adrien Destugues
35c16bd3fe DeadYak over IRC:
-Fix gcc4 build


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35145 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-18 21:52:30 +00:00
Jérôme Duval
a4248cf53b * Rename _thread_do_exit_notification() to _thread_do_exit_work() as suggested by Ingo.
Also added an empty stub for _thread_do_exit_notification() when compiling for GCC2.
* Removed the check testing if the thread is already dead.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35142 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-18 17:58:38 +00:00
Rene Gollent
114580cd78 Update find_directory to use a lowercase path for the on-disk trash location like more or less all other system dirs. Should be the last of the trash changes.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35135 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-17 20:47:28 +00:00
Axel Dörfler
29ddbdbb53 * Moved the "var" directory to /boot/common/.
* Moved the "tmp" directory out of /var, and to /boot/common/cache/.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35104 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-16 17:17:07 +00:00
Stefano Ceccherini
af029e2fb3 Fixed a gcc4 warning
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35103 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-16 16:49:57 +00:00
Jérôme Duval
0bce4bb917 * don't destroy an already dead thread. Fixed #5271. Maybe we should only make this check on the sMainThread though.
* Implementations of pthread_getschedparam and pthread_setschedparam I had since a while.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35098 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-16 15:19:50 +00:00
Rene Gollent
a65ec15376 Fix style violations (thanks Axel!).
Update filesystem name in find_directory as our fat filesystem is not named "dos".



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35093 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-15 23:31:45 +00:00
Ingo Weinhold
f082f7f019 * Added vm_page::accessed flag. Works analogously to vm_page::modified.
* Reorganized the code for [un]mapping pages:
  - Added new VMTranslationMap::Unmap{Area,Page[s]}() which essentially do what
    vm_unmap_page[s]() did before, just in the architecture specific code, which
    allows for specific optimizations. UnmapArea() is for the special case that
    the complete area is unmapped. Particularly in case the address space is
    deleted, some work can be saved. Several TODOs could be slain.
  - Since they are only used within vm.cpp vm_map_page() and vm_unmap_page[s]()
    are now static and have lost their prefix (and the "preserveModified"
    parameter).
* Added VMTranslationMap::Protect{Page,Area}(). They are just inline wrappers
  for Protect().
* X86VMTranslationMap::Protect(): Make sure not to accidentally clear the
  accessed/dirty flags.
* X86VMTranslationMap::Unmap()/Protect(): Make page table skipping actually
  work. It was only skipping to the next page.
* Adjusted the PPC code to at least compile.

No measurable effect for the -j8 Haiku image build time, though the kernel time
drops minimally.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35089 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-15 22:32:51 +00:00
Rene Gollent
01dffd8edd More Tracker refactoring:
* relocated Trash dirs to volume roots by modifying find_directory() to report the trash location as volume/Trash.
 * FSUtils no longer creates /home/Desktop on every volume.
 * TrashWatcher now keeps icons in sync on all volumes.
 * Simplified FSGetDeskDir since it no longer has to worry about getting the desk directory on any volume other than the root.
 * Relocated trash context menu logic to BContainerWindow so it can also be used at the volume roots.
 * DesktopPoseView now creates a virtual Trash pose representing the trash contents as before.
 * Corrected typo: Model::WriteAttrKillForegin() -> Model::WriteAttrKillForeign().

Closes ticket #5245.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35085 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-15 05:12:45 +00:00
Ingo Weinhold
c6aa013564 Changed VMTranslationMap::Lock()/Unlock() return types to the usual.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35075 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-14 20:44:29 +00:00
Ingo Weinhold
bcc2c157a1 Refactored vm_translation_map:
* Pulled the physical page mapping functions out of vm_translation_map into
  a new interface VMPhysicalPageMapper.
* Renamed vm_translation_map to VMTranslationMap and made it a proper C++
  class. The functions in the operations vector have become methods.
* Added class GenericVMPhysicalPageMapper implementing VMPhysicalPageMapper
  as far as possible (without actually writing new code).
* Adjusted the x86 and the PPC specifics accordingly (untested for the
  latter). For the other architectures the build is, I'm afraid, seriously
  broken.

The next steps will modify and extend the VMTranslationMap interface, so that
it will be possible to fix the bugs in vm_unmap_page[s]() and employ
architecture specific optimizations.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35066 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-14 03:26:12 +00:00
Ingo Weinhold
30f423606d As per the IA32 specification we can save TLB invalidations in at least two
situations:
* When mapping the page the page table entry should not have been marked
  "present" before, i.e. it would not have been cached anyway.
* When the page table entry's accessed flag wasn't set, the entry hadn't been
  cached either.

Speeds up the -j8 Haiku image build only minimally, but the total kernel time
drops about 9%.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35062 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-13 22:55:52 +00:00
Ingo Weinhold
946325051b * Added boolean "alreadyWired" parameter to vm_map_physical_memory().
* ioapic_init(): map_physical_memory() was called for already mapped
  addresses. This worked fine, but only because the x86 page mapping code
  didn't mind.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35059 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-13 22:02:21 +00:00
Ingo Weinhold
9435ae9395 x86 page mapping:
* Removed the page_{table,directory}_entry structures. The bit fields are
  nice in principle, but modifying individual flags this way is inherently
  non-atomic and we need atomicity in some situations.
* Use atomic operations in protect_tmap(), clear_flags_tmap(), and others.
* Aligned the query_tmap_interrupt() semantics with that of query_tmap().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35058 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-13 20:29:03 +00:00
Ingo Weinhold
a99debff88 Added TODOs.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35056 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-13 18:21:36 +00:00
Stephan Aßmus
06f34bf2d8 Applied patch by "Grey":
Entering the boot loader menu has changed/simplified while reducing the boot time by .75 seconds.
Now it is enough to hold one of shift/Esc/F8/F12/Space. Thanks!

I've also updated the boot loader documentation to reflect the change, but I only mentioned holding shift.
I know that changing the documention directly is not preferred anymore, but I wanted to make sure this
patch is complete.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35050 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-13 15:02:55 +00:00
Ingo Weinhold
3b8c056da0 Should have been part of r35023: Introduction of the vm_page::modified flag.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35024 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-12 01:24:40 +00:00
Ingo Weinhold
829f302836 Introduced vm_page::modified flag, which is used by vm_unmap_page[s]() to
preserve the dirty flag of the mapping without having to potentially move the
page to the modified queue. This lifts the (ignored) requirement that the
pages to be unmapped must not be busy.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35023 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-12 01:22:09 +00:00
Ingo Weinhold
3fb2a94dfb * Inline {acquire,release}_spinlock(), when spinlock debugging is disabled.
* Use atomic_{and,or}() instead of atomic_set(), as there are no built-ins
  for the latter.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35021 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-11 22:13:11 +00:00
Ingo Weinhold
9c6720c064 Fixed two instances of debug code I missed to adjust in r35004. Fixes #5242.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35020 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-11 22:10:12 +00:00
Stephan Aßmus
98664e52dd Patch by Andreas Färber:
* Fix the boot net stack's IPService to base the calculation payload size
   on the IP-indicated packet size instead of the Ethernet payload.

Thanks a lot! Fixes ticket #5234.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35016 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-11 20:50:06 +00:00
Ingo Weinhold
451ca8b4b4 PAGE_TYPE_GUARD was unused and for the other two types a simple one bit flag
suffices. Therefore replaced vm_page::type by vm_page::is_dummy.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35013 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-11 19:13:14 +00:00
Ingo Weinhold
d7455de2f6 allocate_page_run(): Use temporary lists to store the pages we're allocating.
This makes appending the pages to the active queue more efficient and we
don't need the vm_page::is_cleared bit anymore.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35011 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-11 16:36:31 +00:00
Ingo Weinhold
a0b07ebaab Added AppendUnlocked() version that appends a list of pages.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35010 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-11 16:31:44 +00:00
Ingo Weinhold
7372a88af4 Replaced the page queue mutexes by spinlocks. The critical sections are very
short and quite hot, so mutexes just cause more overhead due to frequent
rescheduling than waiting for the spinlocks does. The free and clear queues
are additionally protected by a R/W lock, which is mostly read-locked, save
for rare cases like allocating page runs.

The total -j8 Haiku image build speedup is marginal. The kernel time drops
about 8%, though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35004 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-11 02:52:53 +00:00
Ingo Weinhold
8fc761bd7a Don't use a condition variable for blocking the system profiler thread, since
that causes a locking order reversal (condition variable lock <-> system
profiler lock) and thus a potential deadlock. Instead we use the thread
blocking API directly. Fixes #5229.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35003 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-11 02:33:10 +00:00
Ingo Weinhold
5e0aacb9f8 vm_page_schedule_write_page_range(): The debug code was a bit too possessive.
We can only access the page, if it is not busy. Fixes #5228.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34980 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-09 20:59:03 +00:00
Ingo Weinhold
4aedc06701 "page" debugger command:
* Various smaller fixes.
* Used add_debugger_command_etc() and added more verbose usage message.
* Added option "-m" which iterates through all address spaces and finds out
  which virtual pages are mapped to the page.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34979 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-09 20:27:11 +00:00
Ingo Weinhold
509f1174ce * Added Size() method.
* Added Debug{First,Next}() methods to allow easy iteration through the
  address spaces in kernel debugger commands.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34978 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-09 20:21:43 +00:00
Ingo Weinhold
5bcbe8b2a0 "find_page" didn't search the inactive queue.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34972 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-09 15:26:15 +00:00
Ingo Weinhold
924a3e5f9b Removed unused <arch>_switch_stack_and_call() and
arch_thread_switch_kstack_and_call().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34971 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-09 15:09:02 +00:00
Michael Lotz
29aa1bebef Add missing error return.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34970 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-09 13:12:54 +00:00
Michael Lotz
14429e896e Reverted the part of r31520 that made devfs_unpublish_partition() take a raw
device path + child partition name. When a "raw" device is unpublished the node
removal notification triggers the partition and child partitions to be
unpublished/removed. Since in that case the "raw" node is already unpublished
trying to resolve it in devfs_unpublish_partition() again to unpublish the child
partitions would fail, leaving the child partition nodes behind. When a new raw
device would then become available publishing its partitions would fail because
of these left behind nodes, causing bug #4587. Seeing that this code is more
compact and straight forward anyway I don't quite see why it was changed in the
first place.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34967 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-09 03:55:38 +00:00
Ingo Weinhold
afed2658f4 * Made VMCacheChainLocker more flexible (added unlocking destructor and
LockAllSourceCaches()) and moved it to the beginning of the file.
* Removed sMappingLock and adjusted the locking policy for mapping/unmapping
  pages: Since holding the lock of the affected pages' caches is already
  required, that does now protect the page's mappings, too. The area mappings
  are protected by the translation map lock, which we always acquire anyway
  when mapping, unmapping, or looking up mappings.

The change results in a -j8 Haiku image build speedup of almost 10%. The
total kernel time drops almost 30%.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34965 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-09 01:38:50 +00:00
Ingo Weinhold
31996a8e56 Added TODO.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34964 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-09 01:25:38 +00:00
Ingo Weinhold
2a30aab6f4 Don't announce page access before being sure that the page isn't busy. Fixes
the erroneously trigger panic() in #5216.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34958 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-08 20:39:08 +00:00
Ingo Weinhold
aac9b8e4af unmap_and_free_physical_pages(): Don't try to free already free pages.
Apparently (at least when running in VMware >=2) the boot loader can still
map the same physical page more than once -- in the ACPI or HPET code I
suppose -- which would lead to this situation.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34954 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-08 20:01:19 +00:00
Ingo Weinhold
440a118398 Use SYMBOL() instead of FUNCTION() to define the function end symbol. The
following function might otherwise not be shown correctly in ELF tools.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34952 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-08 17:24:29 +00:00
Ingo Weinhold
1b1b94b85a Entry cache:
* Moved hash computations out of the critical sections.
* Replaced the LRU entry queue by an array of entry "generations", each
  containing a sparse array of entries of that generation. Whenever a
  generation is full, we clear the oldest generation and continue with that
  one. The main advantage of this algorithm is that entry cache's mutex could
  be replaced by an r/w lock, that most of the time only has to be read
  locked in Lookup(). This does dramatically decrease contention of that
  lock.

The total -j8 Haiku image build speedup is marginal, but the kernel time
drops about 7% (now being smaller than the real time).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34950 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-08 17:02:24 +00:00
Ingo Weinhold
74a2534a03 Small optimization proposed by "Grey": We load USER_DATA_SEG into %ecx
anyway, so we can as well push the register later.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34949 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-08 16:41:57 +00:00
Ingo Weinhold
d756fcf644 acpi_check_rsdt(), acpi_find_table(): Unmap the mapped page again, if we
don't need it. That prevents us from ending up with the page being mapped
multiple times (under VMware at least) and thus fixes #5208.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34948 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-08 16:06:22 +00:00
Ingo Weinhold
7f051b5710 * Changed/fixed mmu_map_physical_memory() semantics: It does now always
allocate all pages the given range intersects with. When not page aligned
  it could fail to allocate the last page.
* mmu_free():
  - Adjusted semantics to be compatible with mmu_map_physical_memory().
  - The validity check was broken, because page number and addresses were
    mixed, and because KERNEL_BASE + kMaxKernelSize doesn't mark the end of
    the allocated virtual ranges.
  - The final check against sNextVirtualAddress was broken.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34947 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-08 15:58:08 +00:00
François Revol
12a17213b4 Undo r34942 and use printf instead, which is standardized by POSIX and supports \n, thanks DraX!
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34943 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-07 23:31:12 +00:00
François Revol
08605557d3 Do not use echo -e, as FreeBSD doesn't support it.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34942 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-07 23:03:19 +00:00
François Revol
c505b2765b Patch by Matt Madia: detect host sfdisk in configure for ARM, including the FreeBSD port.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34940 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-07 22:08:12 +00:00
Ingo Weinhold
fb1819be95 Eliminated sVnodeCoveredByMutex. The Vnode::covered_by field is now also
protected by the global vnodes lock. The contention mostly moves to other
locks, though. The total -j8 Haiku image build time is only reduced
minimally.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34938 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-07 17:01:27 +00:00
Ingo Weinhold
bd0bff449f Changed sAreaCacheLock from mutex to rw_lock. This reduces the lock's
contention about two orders of magnitude. Most of it seems to be taken over
by other locks, though. Yields only small improvements for the -j8 Haiku
image build.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34937 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-07 15:36:18 +00:00
Ingo Weinhold
c4f9831292 Added new mutex_switch_from_read_lock() for unlocking a read lock and
starting to lock a mutex in an atomic operation.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34935 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-07 15:31:29 +00:00
Ingo Weinhold
8ab820f076 VMAddressSpace::Put() is too hot to always write lock the address spaces
table. It is now inline and uses double-checked locking. This reduces the
contention on the lock to insignificant. Total -j8 Haiku image build speedup
is marginal, but the total kernel time drops 12%.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34934 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-07 14:09:56 +00:00
Ingo Weinhold
3cd2094396 * Added new debug feature (DEBUG_PAGE_ACCESS) to detect invalid concurrent
access to a vm_page. It is basically an atomically accessed thread ID field
  in the vm_page structure, which is explicitly set by macros marking the
  critical sections. As a first positive effect I had to review quite a bit of
  code and found several issues.
* Added several TODOs and comments. Some harmless ones, but also a few
  troublesome ones in vm.cpp regarding page unmapping.
* file_cache: PrecacheIO::Prepare()/read_into_cache: Removed superfluous
  vm_page_allocate_page() return value checks. It cannot fail anymore.
* Removed the heavily contended "pages" lock. We use different policies now:
  - sModifiedTemporaryPages is accessed atomically.
  - sPageDeficitLock and sFreePageCondition are protected by a new mutex.
  - The page queues have individual locks (mutexes).
  - Renamed set_page_state_nolock() to set_page_state(). Unless the caller says
    otherwise, it does now lock the affected pages queues itself. Also changed
    the return value to void -- we panic() anyway.
* set_page_state(): Add free/clear pages to the beginning of their respective
  queues as this is more cache-friendly.
* Pages with the states PAGE_STATE_WIRED or PAGE_STATE_UNUSED are no longer
  in any queue. They were in the "active" queue, but there's no good reason
  to have them there. In case we decide to let the page daemon work the queues
  (like FreeBSD) they would just be in the way.
* Pulled the common part of vm_page_allocate_page_run[_no_base]() into a helper
  function. Also fixed a bug I introduced previously: The functions must not
  vm_page_unreserve_pages() on success, since they remove the pages from the
  free/clear queue without decrementing sUnreservedFreePages.
* vm_page_set_state(): Changed return type to void. The function cannot really
  fail and no-one was checking it anyway.
* vm_page_free(), vm_page_set_state(): Added assertion: The page must not be
  free/clear before. This is implied by the policy that no-one is allowed to
  access free/clear pages without holding the respective queue's lock, which is
  not the case at this point. This found the bug fixed in r34912.
* vm_page_requeue(): Added general assertions. panic() when requeuing of
  free/clear pages is requested. Same reason as above.
* vm_clone_area(), B_FULL_LOCK case: Don't map busy pages. The implementation is
  still not correct, though.

My usual -j8 Haiku build test runs another 10% faster, now. The total kernel
time drops about 18%. As hoped the new locks have only a fraction of the old
"pages" lock contention. Other locks lead the "most wanted list" now.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34933 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-07 02:37:05 +00:00
François Revol
cecee6bb75 M is 1024*1024, dammit ! Has the US finally switched to the metric system ?
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34920 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-06 18:15:56 +00:00
Stephan Aßmus
9149b4aa35 Fixed line-endings.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34919 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-06 17:54:21 +00:00
Stephan Aßmus
7c5a2487c1 Patch by Andreas Faerber:
* Fixed coding style issues pointed out by Axel.
 * Fixed potential buffer overflow and fault in default-client-up code path
   (OF counts terminating zero char, too).
 * Added an intermediate fallback to parsing the boot path
 * Added himself to the copyright holders

Thanks a lot! Fixes ticket #5189.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34918 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-06 17:53:03 +00:00
François Revol
bc85c20bdd - add board-specific stuff to header paths,
- automatically download the u-boot flash image when set.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34917 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-06 17:47:54 +00:00
Ingo Weinhold
66896bba13 RemovePage() + InsertPage() == MovePage()
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34913 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-05 22:04:24 +00:00
Ingo Weinhold
cb8617c1d4 unmap_and_free_physical_pages(): Added missing check whether the page
mapping is actually present. This would have resulted in page 0 being freed
over and over again, if we hadn't also incorrectly tried to look up the page
by the virtual instead of the physical address. So we were actually freeing
random pages. Fortunately the virtual addresses are kernel addresses, so that
the affected pages lay beyond 2 GB and probably weren't used at this point
yet.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34912 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-05 22:02:58 +00:00
Ingo Weinhold
88675a7eb2 steal_pages(): Recheck sUnreservedFreePages after incrementing sPageDeficit.
Since the former is no longer guarded by any lock, there's a race condition
with vm_page_unreserve_pages() which would cause us to wait longer than
necessary.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34898 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-04 20:43:25 +00:00
Ingo Weinhold
90daf7c61e * init_after_fork(): In case the reservation for the heap area failed
sHeapBase will probably not point to memory in the heap area. Use
  sFreeHeapBase instead.
* When reserving the heap area range fails, set sHeapBase to NULL, so we'll
  later know about the fact.
* hoardSbrk(): When resizing the area fails, we'll now try to allocate a new
  one, if the former failure was not due to an "out of memory" situation.
  E.g. if the heap range reservation failed or, if we just have exhausted the
  range, another area could be in the way. Also when mmap()ing over
  malloc()ed, the heap area count be split in two with the first part
  retaining the old area ID, thus preventing resizing as well. Fixed #5168.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34897 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-04 19:37:25 +00:00
Axel Dörfler
8dd44be804 * Minor cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34891 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-04 16:23:14 +00:00
Ingo Weinhold
37caa95564 Replaced the sReservedPages counter tracking the page reservations by
sUnreservedFreePages which tracks the difference between free/clear and
reserved pages. Access to it uses atomic operations which allows the three
page (un)reservation to avoid locking in most cases, thus reducing contention
of the "pages" lock.

In the -j8 Haiku image build that decreases the contention of the "pages"
lock to about one third of the previous value. As a positive side effect the
VMCache lock contention drops about the same factor. The total build speedup
is about 20%, the total kernel time drops about 20%.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34888 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-04 15:26:05 +00:00
Ingo Weinhold
1e175b599b Removed duplicate condition.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34886 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-04 01:09:58 +00:00
Ingo Weinhold
e8db7400e9 Avoid using DoublyLinkedList internals.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34885 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-04 00:11:56 +00:00
Axel Dörfler
e7385fa68e * If a block allocation fails, remove an unused one and try again - this might
improve the reliability as long as our slab implementation is a PITA.
* Removed an assertion that will no longer work (due to the DoublyLinkedList
  changes).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34877 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-03 19:08:40 +00:00
Axel Dörfler
e045a8c0df * Solved the problem independently from the list.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34876 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-03 18:54:52 +00:00
Axel Dörfler
32883e8980 * This should hopefully fix the broken kernel - this code relied on clearing
the next/previous pointers. There might be more, though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34875 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-03 18:24:27 +00:00
Ingo Weinhold
5800e8a486 * Moved the page management functionality into its own file.
* Renamed page_queue to VMPageQueue and made it a proper C++ class. Use
  DoublyLinkedList instead of own list code.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34874 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-03 17:10:32 +00:00
Ingo Weinhold
7fc65e1488 fs_unmount(): We need to hold the vnodes write lock after all. The upside is
that it saves us from locking the individual vnodes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34872 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-03 14:10:43 +00:00
Ingo Weinhold
a210e61053 * free_unused_vnodes(): Be a good citizen and use vnode_used() instead of
playing with the unused list manually. This also clears the vnode's unused
  flag, which wasn't done before and would thus cause corruption of the
  unused list a bit later.
* fs_unmount():
  - Fixed an iteration bug I introduced previously. The iterator would be
    advanced twice per iteration, leading to NULL pointer dereferencing
    when the vnode count was odd and skipping the checks for every other
    vnode.
  - All vnodes are going to be freed, so vnode_to_be_freed() has to invoked
    for every one of them. The code wasn't adjusted correctly when
    introducing the hot vnodes handling.
* Adjusted/improved some comments.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34871 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-03 13:54:22 +00:00
Axel Dörfler
e0d09e23a7 * Replaced parse_ip_address_component() with strtol() which is already
available in the boot loader.
* Simplified parse_ip_address() and use style conforming identifiers.
* Some cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34870 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-03 13:33:20 +00:00
François Revol
65a4a2c2a4 Fix m68k build... /me pets Ingo :-)
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34869 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-03 03:58:43 +00:00
François Revol
3e3a00b3ff Fix ARM build, which broke due to some *.c->*.cpp change... /me pets Ingo.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34868 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-03 03:55:26 +00:00
Ingo Weinhold
5484890096 * Moved the unused vnode management to a new file. Well the few variables
used for it that is.
* The main cause for the heavy contention of the unused vnodes mutex was that
  relatively few vnodes are actually used for a longer time. Mainly those are
  the volume roots, mmap()ed files, and the files opened by programs. A good
  deal of nodes -- particularly directories -- are just referenced for a very
  short time, e.g. to resolve a path to a contained entry. This caused those
  nodes to be added to and removed from the unused vnodes list very
  frequently, thus resulting in a high contention of the mutex guarding it.
  To address the problem I've introduced an approximation of a set of "hot"
  vnodes, i.e. vnodes that have recently been marked unused. They are stored
  in an array that by means of an r/w locker and atomic operations can most
  of the time be accessed concurrently. Whenever it gets full, it is flushed
  to the actual unused vnodes list.
* dec_vnode_ref_count(): No longer check the unused vnode count every time.
  The called new vnode_unused() does only from time to time and returns when
  the caller is expected to free some of the unused vnodes. As a side effect
  this also fixes a bug I previously introduced: The unused vnode to be freed
  was marked busy without being locked first.

The -j8 Haiku image test build shows that the changes reduce the contention
of the unused vnode list mutex to virtually zero without introducing any
significant contention of the new r/w lock. The VMCache lock contention also
seems to be decreased somewhat, which is probably not that surprising
considering that the page writer acquires/releases vnode references with the
cache lock held. The "pages" lock takes over even more contention, now
causing more than 100000 waits per second.
The total build time reduction is about 4.5%. Kernel time drops more than
10%.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34866 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-03 02:43:32 +00:00
Ingo Weinhold
8ccbb7815c * Moved the vnode structure (to by Vnode class at some time in the future) into
its own header/source files.
* Changed vnode's bit fields to a single, atomically changeable int32 using
  flags instead. Added respective accessor methods.
* Added a per-vnode mutex-like lock, which uses 2 bits of the structure and
  32 global "buckets" which are used for waiter lists for the vnode locks.
* Reorganized the VFS locking a bit:
  Renamed sVnodeMutex to sVnodeLock and made it an r/w lock. In most situations
  it is now only read-locked to reduce its contention. The per-vnode locks guard
  the fields of the vnode structure and the newly introduced sUnusedVnodesLock
  has taken over the job to guard the unused vnodes list.

The main intent of the changes was to reduce the contention of the sVnodeMutex,
which was partially successful. In my standard -j8 Haiku image build test the
new sUnusedVnodesLock took over about a fourth of the former sVnodeMutex
contention, but the sVnodeLock and the vnode locks have virtually no contention
to speak of, now. A lot of contention migrated to the unrelated "pages" mutex
(another bottleneck). The overall build time dropped about 10 %.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34865 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-02 23:27:41 +00:00
Stephan Aßmus
5c9bd9d619 Patch by Andreas Faerber with small changes by myself:
* Skip mappings to non-physical memory in the PPC MMU code. Gets the
   PPC kernel booting a little further.

Thanks! Fixes ticket #5193.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34863 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-02 18:40:07 +00:00
Stephan Aßmus
8d9e8ba5b7 Patch by Andreas Faerber (small changes by myself):
* Fix compilation with tracing enabled.

Thanks! Fixes ticket #5183.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34862 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-02 18:34:42 +00:00
Stephan Aßmus
6e95b86e15 Patch by Andreas Faerber:
* Fix compilation when commented out.

Thanks! Fixes ticket #5192.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34861 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-02 18:31:24 +00:00
Stephan Aßmus
e355ce92a4 Patch by Andreas Faerber:
* Fix compilation with tracing enabled.

Thanks! Fixes ticket #5188.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34860 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-02 18:26:43 +00:00
Stephan Aßmus
5d80127809 Patch by Andreas Faerber:
* Fix a typo in the comments: unintialized -> uninitialized.

Thanks a lot!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34857 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-02 10:21:09 +00:00
Stephan Aßmus
745b2d9db7 Patch by Andreas Faerber:
* Fix duplicate assignment which is probably a merging artifact.

This patch was also a requirement for a working PPC KDL prompt. I didn't
apply the patches in order... Thanks a lot!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34856 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-02 10:19:05 +00:00
Stephan Aßmus
16f50e3394 Patch by Andreas Faerber:
* Fix a warning in VM tracing output, which prevented the compilation since
   warnings are treated as errors.

Thanks!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34855 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-02 10:13:21 +00:00
Stephan Aßmus
352455f269 Patch by Andreas Faerber:
* The kernel's _start entry function expects now a second argument, the
   current CPU index. The PPC boot loader didn't initialize GPR4, passing
   its second argument, the kernel entry address, as CPU index, causing
   smp_cpu_rendezvous() to loop forever. This fix gets the PPC boot to a
   kernel debug prompt. The CPU index is currently fixed to 0.

Thanks a lot!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34854 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-02 10:09:09 +00:00
Stephan Aßmus
50028fc7aa Patch by Andreas Faerber:
* Choosing Reboot from the menu will now reboot the system instead of
   returning to the OpenFirmware prompt. Places, where returning to the
   prompt was desirable have been adapted to maintain their current behavior.

Thanks!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34852 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-02 10:04:37 +00:00
Stephan Aßmus
9592b510c5 Patch by Andreas Faerber:
* Fixed typo in panic() message.

Thanks!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34851 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-02 10:00:53 +00:00
Stephan Aßmus
431b9a3183 Patch by Andreas Faerber: (OpenFirmware network boot)
* If retrieving an IP address from the non-standard /chosen/dhcp-response
   fails, try to parse it from /options/default-client-ip instead.

Thanks!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34850 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-02 09:38:53 +00:00
Ingo Weinhold
fb5c39cb6d Removed TODO again. I tried a similar event mechanism as used for busy pages
in VMCache, but, if anything, that makes a -j8 build marginally slower. I
guess busy vnodes are encountered so rarely that the additional overhead for
a more intelligent algorithm isn't really worth it. Reduced the wait time,
though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34845 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-01 22:13:13 +00:00
Colin Günther
ac20a24e6f Adding strndup.cpp to kernel_lib_posix. Introduced for having a safe way
duplicating firmware names in firmware_get() of the freebsd compat layer.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34844 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-01 22:05:45 +00:00
Ingo Weinhold
f42efbcd26 Moved the entry cache implementation into its own file.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34843 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-01 20:51:30 +00:00
Ingo Weinhold
7a9b8baa54 Made vnode::type private, renamed it to fType, and added accessor methods. It
stores the value right-shifted by 12 bits, now, since those bits are not
relevant. This saves some bits and also resolves a TODO.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34842 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-01 20:43:20 +00:00
Ingo Weinhold
3caec2871a * Resolved TODO in free_vnode(): There was a race condition between vnode
destruction and VMVnodeCache::AcquireUnreferencedStoreRef(). Solved by
  adding a flag to VMVnodeCache and letting AcquireUnreferencedStoreRef()
  fail, if set.
* Added TODO regarding replacing the snooze() waiting for busy vnodes.
* get_vnode(): Unlock sVnodeMutex while calling the put_vnode() hook on
  error.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34841 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-01 20:20:11 +00:00
Axel Dörfler
a7cc5352d8 * Our userland build obviously adds some default headers with GCC2 - why would
it do that? This fixes the kernel build, and probably GCC4, too.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34840 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-01 19:36:01 +00:00
Axel Dörfler
31e49a2f1d * Implemented missing alphasort(), and scandir() POSIX functions. Completely
untested yet, though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34838 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-01 18:49:55 +00:00
Ingo Weinhold
355dc6bef4 Inlined several VMCache methods.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34837 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-01 17:09:23 +00:00
Ingo Weinhold
1021fd2826 * agp_gart(): Use vm_page_[un]reserve_pages().
* Removed unused vm_page_allocate_pages().
* Removed now unused (always true) "reserved" parameter from
  vm_page_allocate_page().
* Removed unused (always false) "stealActive" parameter from steal_page().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34836 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-01 16:37:14 +00:00
Axel Dörfler
e30dd2c076 * If the VESA driver remaps the frame buffer on init, it will now also make
sure that the kernel's frame buffer console points to the right data.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34835 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-01 14:54:41 +00:00
Ingo Weinhold
4502d80d7e capture_tracing_stack_trace():
* When interrupts are disabled, it is still safe to capture the kernel stack
  trace. The respective TODO preceded the introduction of the "kernelOnly"
  flag.
* Actually made "kernelOnly" work. The wrong flag was passed to
  arch_debug_get_stack_trace() in case it was false, so we never captured
  user stack traces.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34832 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-31 17:21:17 +00:00
Ingo Weinhold
91bd177eb1 Replaced the rootfs mutex by an rw_lock. To avoid race conditions in the
directory iteration code, a mutex to protect the iteration cookie and one
to protect the cookie list have been introduced.
Overall this reduces the contention of the rootfs lock significantly. The
Haiku image -j8 build gets only marginally faster though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34831 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-31 17:11:52 +00:00
Ingo Weinhold
2ea2527fe4 R/W lock implementation:
* Changed the rw_lock_{read,write}_unlock() return values to void. They
  returned a value != B_OK only in case of user error and no-one checked them
  anyway.
* Optimized rw_lock_read_[un]lock(). They are inline now and as long as
  there's no contending write locker, they will only perform an atomic_add().
* Changed the semantics of nested locking after acquiring a write lock: Read
  and write locks are counted separately, so read locks no longer implicitly
  become write locks. This does e.g. make degrading a write lock to a read
  lock by way of read_lock + write_unlock (as used in the VM) actually work.

These changes speed up the -j8 Haiku image build on my machine by a few
percent, but more interestingly they reduce the total kernel time by 25 %.
Apparently we get more contention on other locks, now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34830 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-31 17:03:41 +00:00
Ingo Weinhold
3ce2634533 * Fixed the semantics of [v]snprintf(): If the buffer is not large enough,
the function shall nevertheless return the length of the string that would
  be written, if the buffer were large enough.
  Added a touch of C++ while doing that. :-)
* Fixed the instances in boot loader, kernel, and kernel modules where the
  wrong semantics were expected. The majority of uses actually.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34826 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-30 15:17:09 +00:00
Ingo Weinhold
3069ca963e Enable loading debug symbols again. The approach to use the driver settings
is broken.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34825 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-30 14:55:07 +00:00
Ingo Weinhold
448671a39c * Build library libroot_debug.so, which is the standard libroot.so with the
debug heap implementation.
* Added libroot_debug.so to the DevelopmentMin optional package. Since it has
  the same soname as the standard libroot, it can simply be specified in
  LD_PRELOAD to run a program with that version.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34788 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-28 00:13:17 +00:00
Ingo Weinhold
765a039de2 Pre-load shared objects as libraries, so their symbols will be used
automatically and a pre-loaded library will not be loaded again, when it's
also a dependency.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34786 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-28 00:05:10 +00:00
Ingo Weinhold
9704a425ea When pre-loading stuff, we must not access gProgramImage unchecked.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34785 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-28 00:02:54 +00:00
Ingo Weinhold
eb8dc1ebfb * Removed DEBUG_PAGE_CACHE_TRANSITIONS debugging.
* Added VMCache::MovePage() and MoveAllPages() to move pages between caches.
* VMAnonymousCache:
  - _MergeSwapPages(): Avoid doing anything, if neither cache has swapped out
    pages.
  - _MergeSwapPages() does now also remove source cache pages that are
    shadowed by consumer swap pages. This allows us to call _MergeSwapPages()
    before _MergePagesSmallerSource(), save the swap page shadowing check
    there and get rid of the vm_page::merge_swap flag. This is an
    optimization based on the assumption that usually none or only few pages
    are swapped out, so we save a lot of checks.
  - Implemented _MergePagesSmallerConsumer() as an alternative to
    _MergePagesSmallerSource(). The former is used when the source cache has
    more pages than the consumer cache. It iterates over the consumer cache's
    pages, moves them to the source and finally moves all pages back to the
    consumer. The final move is relatively cheap (though unfortunately we
    still have to update all pages' vm_page::cache field), so that overall we
    save iterations of the main loop with the more expensive checks.

The optimizations particularly improve the common fork()+exec*() situations.
fork() uses CoW, which is implemented by putting two new empty caches between
the to be copied area and its cache. exec*() destroys one copy of the area,
its cache and thus causes merging of the other new cache with the old cache.
Since this usually happens in a very short time, the old cache does still
contain many pages and the new cache only few. Previously the many pages were
all checked and moved individually. Now we do that for the few pages instead.

A very extreme example of this situation is the Haiku image build. jam has a
huge heap (> 200 MB) and it fork()s+exec*()s for every action to be executed.
Since during the cache merging the cache is locked, any write access to a
heap page causes jam to block until the cache merging is done. Formerly that
took so long that it killed a lot of parallelism in multi-job builds. That
could be observed particularly well when lots of small actions where executed
(like the Link, XRes, Mimeset, SetType, SetVersion combos when building
executables/libraries/add-ons). Those look dramatically better now.
The overall speed improvement for a -j8 image build on my machine is only
about 15%, though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34784 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-27 16:14:13 +00:00
Ingo Weinhold
c2d5972b6a Moved merging swap pages from Merge() to a separate method.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34779 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-26 21:05:38 +00:00
Ingo Weinhold
4566a632c6 * Some style cleanup.
* Pulled the code moving the pages out of Merge() into a separate method.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34778 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-26 21:00:02 +00:00
Ingo Weinhold
ade3a199a6 Already assigned the IOScheduler's ID in the constructor and use it in the
names of its threads.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34770 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-25 11:46:15 +00:00
Ingo Weinhold
e0578cf89f Copy and paste left-over. Should fix the m68k build.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34752 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-22 22:01:55 +00:00
Ingo Weinhold
2e74d74f4f * Added method VMCache::TransferAreas() moving areas from one cache to
another. The code originates from vm_copy_on_write_area(). We now generate
  the VM cache tracing entries, though.
* count_writable_areas() -> VMCache::CountWritableAreas()
* Added debugger command "cache_stack" which is enabled when VM cache tracing
  is enabled. It prints the source caches of a given cache or area at the
  time of a specified tracing entry.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34751 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-22 22:00:35 +00:00
Ingo Weinhold
a38f850360 * arch_debug_get_stack_trace():
- Replaced the "userOnly" parameter by a "flags" parameter, that allows to
    specify kernel and userland stack traces individually.
  - x86, m68k: Don't always skip the first frame as that prevents the caller
    from being able to record its own address.
* capture_tracing_stack_trace(): Replaced the "userOnly" parameter by
  "kernelOnly", since one is probably always interested in the kernel stack
  trace, but might not want the userland stack trace.
* Added stack trace support for VM cache kernel tracing.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34742 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-22 15:15:07 +00:00
Ingo Weinhold
1c12dcb598 IOSchedulerRoster:
* Lock the notification service and check HasListeners(), so we don't prepare
  an event message needlessly.
* The on-stack buffer for the event message was too small for I/O operation
  related events. Now a larger buffer belonging to the roster object is used.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34737 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-21 21:00:21 +00:00
Ingo Weinhold
1fde952c1d DefaultNotificationService:
* Added Lock()/Unlock() for explicit locking by a service user.
* Added NotifyLocked() and made Notify() inline.
* Added HasListeners() so one can check whether there is a listener at all
  before preparing the event message.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34736 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-21 20:56:50 +00:00
Ingo Weinhold
0b58d8440c * Prefixed the INCLUDE_GPL_ADDONS variable by "HAIKU_". configure needs to
be run again or generated/build/BuildConfig needs to be adjusted manually.
* Removed bochs debug hack.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34721 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-20 13:55:45 +00:00
Ingo Weinhold
022cdb9ce3 Fixed build with scheduler tracing enabled.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34714 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-20 00:32:08 +00:00
Ingo Weinhold
a73382f7bb * uninit_port_locked(): Fixed incorrect use of ConditionVariable::NotifyAll().
Fixes #5152.
* _get_port_message_info_etc(): Check whether the port still exists and is not
  closed and empty in the loop. Though actually it shouldn't be necessary
  (same in the other functions), since Wait() would return an error, if the
  port was closed/deleted. Well, paranoia... :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34713 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-20 00:31:37 +00:00
Ingo Weinhold
7382f82116 Should have been part of an earlier commit: Initialize the IOSchedulerRoster.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34705 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-19 14:35:05 +00:00
Ingo Weinhold
f36ea5de1b Should have been part of the previous commit: Include directory for the I/O
scheduling event support.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34704 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-19 14:34:24 +00:00
Ingo Weinhold
189010cbc2 Added support for I/O scheduling events to the system profiler interface.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34703 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-19 14:33:29 +00:00
Ingo Weinhold
ca77afe75f * Implemented missing cleanup when an IOScheduler is destroyed. The threads
weren't terminated orderly.
* IOScheduler now stores its name and gets a unique ID.
* Added IOSchedulerRoster singleton which registers all IOSchedulers. It also
  provides a notification service. We generate interesting events for
  IOSchedulers, IORequests, and IOOperations.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34702 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-19 14:32:14 +00:00
Ingo Weinhold
410ba11f8c read_port_etc():
* Also check whether the port is closed after waiting.
* Don't increment read_count after waiting failed. That should have been the
  cause of #5119.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34687 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-17 12:21:05 +00:00
Ingo Weinhold
c3bc71d6e2 Removed superfluous ConditionVariableEntry::WaitStatus() checks. Wait() always
returns the correct value.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34686 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-17 11:06:16 +00:00
Ingo Weinhold
3ffeff0770 port_writev_etc(): Missing check whether the port has been closed after
waiting.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34685 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-17 10:51:05 +00:00
Axel Dörfler
7d592ec4d2 * Fixed the bug that led to #5119. There was a race condition in the read path
as soon as a second thread got into the game: if a thread was notified that
  a message is ready, another thread could call read_port() and steal it before
  the previous thread could claim it. The "Extensions" menu still doesn't seem
  to work, but I would guess that is unrelated.
* The threads of the test app never exited, as read_port() returns the number
  of bytes it read, not just a status.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34681 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-16 12:51:26 +00:00
Fredrik Holmqvist
118fa8936e Make sure settings isn't null. Not my finest day apparently.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34679 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-15 22:19:08 +00:00
Fredrik Holmqvist
0f6b7a8cad Unload driver settings as well.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34678 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-15 22:05:45 +00:00
Fredrik Holmqvist
d403ff624f Style fix:
* static variables should start with s.
 * function blocks should start on new line.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34668 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-15 17:00:03 +00:00
Fredrik Holmqvist
5e972c0f3d Implemented TODO about not loading symbols at boot.
This saves ~0.5s of boot time here, but I suspect it might be better for CD.
Enabled loadSymbols in kernel settings so the behavior should be the same as before this change.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34666 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-15 15:55:16 +00:00
Ingo Weinhold
0338371f26 * All scheduler implementations:
- enqueue_in_run_queue() no longer returns whether rescheduling is supposed
    to happen. Instead is sets cpu_ent::invoke_scheduler on the current CPU.
  - reschedule() does now handle cpu_ent::invoke_scheduler_if_idle(). No need
    to let all callers do that.
* thread_unblock[_locked]() no longer return whether rescheduling is supposed
  to happen.
* Got rid of the B_INVOKE_SCHEDULER handling. The interrupt hooks really
  can't know, when it makes sense to reschedule or not.
* Introduced scheduler_reschedule_if_necessary[_locked]() functions for
  checking+invoking the scheduler.
* Some semaphore functions (e.g. delete_sem()) invoke the scheduler now, if
  they wake up anything with greater priority.
  I've also tried to add scheduler invocations in the condition variable and
  mutex/rw_lock code, but that actually has a negative impact on performance,
  probably because it causes too much ping-ponging between threads when
  multiple locking primitives are involved.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34657 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-13 21:18:27 +00:00
Ingo Weinhold
89e87505cf Improved panic() message.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34656 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-13 21:03:48 +00:00
Ingo Weinhold
2f7eb9b546 Fixed a stupid race condition between IORequest finishing and
IORequest::Wait(). Wait() immediately returned when IsFinished() returned
true, but this is the case as soon as the last IOOperation has finished. The
I/O scheduler is not done with the request at this point, though, since it
will still be sitting in at least one of three doubly linked lists. Since the
usual procedure to issue synchronous I/O requests is to create an IORequest
on the stack, pass it to the I/O scheduler, and Wait() on it, Wait()
returning early might cause the IORequest object to be destroyed while it is
still in use, leading to invalid memory access in the I/O scheduler,
corruption of its list structures, as well as later corruption of the issuing
thread's stack.
Related tickets:
* #4431: The request issuing thread returned and already deleted the area the
  request was writing to before NotifyFinished() was called.
* #3048, #4883: Caused by the on stack IORequest being overwritten with other
  data while being handled by the I/O scheduler thread.
* #4517: Hard to say, but I've seen a such a problem too, after a thread
  scheduling related change. An explanation would be a list structure
  corruption in the I/O scheduler causing an infinite loop with disabled
  interrupts.
* #2845, #3428, #3429: The block notifier/writer is I/O heavy and as such
  quite likely to run into the stack corruption issue.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34655 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-13 19:28:33 +00:00
Jérôme Duval
d0c1951713 added fmin, fma, fmax from glibc (ticket #5114).
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34652 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-13 14:22:13 +00:00
Axel Dörfler
a195cce7b5 * Added a bit more missing info about user_threads.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34647 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-12 19:08:04 +00:00
Axel Dörfler
adf9b14ed6 * Applied r34634 to the simple SMP scheduler as well (Rene was right, I just
overlooked it).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34641 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-12 15:02:30 +00:00
Rene Gollent
5c7993bfab Small cleanup: As the cpu_ent struct now tracks the running thread directly, the affine scheduler can use that instead of keeping track internally.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34638 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-12 00:01:33 +00:00
Ingo Weinhold
e36d79e9dc CPU selection in enqueue_in_run_queue():
* Moved the CPU selection conde into a separate function.
* Re-added the support for disabling CPUs, which I accidentally removed.
* Got rid of idle CPU tracking. We don't need it anymore -- we iterate
  through all CPUs and check the priority of the running thread.
* Added a kind of round-robin component to the CPU selection loop, so that
  we pick CPUs more evenly. And indeed, the ProcessController display is
  less skewed, now. There doesn't seem to be a measurable performance gain,
  though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34637 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-11 23:28:28 +00:00
Ingo Weinhold
b4be7c9021 * Added cpu_ent::running_thread which is maintained by the schedulers.
* simple_smp scheduler: Rewrote the interesting part of
  enqueue_in_run_queue(). It always selects a target CPU for the inserted
  thread, now. If no CPU is idle, the CPU running the thread with the lowest
  priority is chosen. If the thread running on the target CPU has a lower
  priority than the inserted one, it will be asked to reschedule. If that's
  the current CPU, we'll return the correct value (wasn't done before at
  all).
  These changes help reducing latencies. On my machine in an idle system
  playing music DebugAnalyzer shows maximum latencies of about 1 us. I still
  find that a bit much, but it's several orders of magnitude better than
  before. The -j8 Haiku image build time dropped about 10%.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34635 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-11 19:06:57 +00:00
Axel Dörfler
edc69377fa * Changed the simple scheduler's next thread selection in the same way as the
affine scheduler to avoid possible latency issues.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34634 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-11 17:40:15 +00:00
Ingo Weinhold
ec1dcae8cd We have to use dprintf_no_syslog() in the scheduler, as all code is executed
with the threads spinlock held.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34629 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-11 10:25:56 +00:00
Ingo Weinhold
3533b6597d * Reintroduced the SMP_MSG_RESCHEDULE_IF_IDLE ICI message. This time
implemented by means of an additional member in cpu_ent.
* Removed thread::keep_scheduled and the related functions. The feature
  wasn't used yet and wouldn't have worked as implemented anyway.
* Resurrected an older, SMP aware version of our simple scheduler and made it
  the default instead of the affine scheduler. The latter is in no state to
  be used yet. It causes enormous latencies (I've seen up to 0.1s) even when
  six or seven CPUs were idle at the same time, totally killing parallelism.
  That's also the reason why a -j8 build was slower than a -j2. This is no
  longer the case. On my machine the -j2 build takes about 10% less time now
  and the -j8 build saves another 20%. The latter is not particularly
  impressive (compared with Linux), but that seems to be due to lock
  contention.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34615 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-10 11:54:38 +00:00
Ingo Weinhold
10b4833178 When any of the executed timer hooks return B_INVOKE_SCHEDULER, let
timer_interrupt() return B_INVOKE_SCHEDULER. The scheduler itself uses a
timer hook and relies on scheduler_reschedule() to be called. Will make this
even more reliable in the next commit.
This might fix #3535.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34614 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-10 11:29:38 +00:00
Axel Dörfler
2388f50c53 * The io_handler::handled_count was increased unconditionally, but in some cases
not at all.
* Tried to improve the readability of the "ints" command output.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34613 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-10 11:14:46 +00:00
Axel Dörfler
33c82a30c0 * While reading in a block, the block is now marked busy, and the cache
unlocked, allowing for more parallel access.
* Writing is still done synchronously, though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34611 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-10 10:29:37 +00:00
Axel Dörfler
1339ccf411 * Enforce that the caller of transfer_area() owns the area - this fixes some
mean crashes with the media_server version I just checked in.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34556 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-08 15:28:44 +00:00
Ingo Weinhold
d8d4b902cb * The system profiler scheduling event structures sport nanotime_ts now.
* Adjusted the DebugAnalyzer to handle nanosecond times.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34546 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-07 22:56:29 +00:00
Ingo Weinhold
b2a2d5c065 The usual files forgotten to commit. The generic system_time_nsecs()
implementation.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34545 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-07 22:53:53 +00:00
Ingo Weinhold
34a48c70ef Added type nanotime_t (an int64 storing a nanoseconds value) and function
system_time_nsecs(), returning the system time in nanoseconds. The function
is only really implemented for x86. For the other architectures
system_time() * 1000 is returned.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34543 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-07 21:43:19 +00:00
Ingo Weinhold
db905187d5 Implemented a class uint128 with the basic arithmetic operations and
replaced the previous, somewhat complicated and inexact method of
computing the TSC conversion factor using it.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34542 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-07 21:37:56 +00:00
Ingo Weinhold
522c2f19d4 * Added a simple mechanism to wait for events to VMCache. WaitForPageEvents()
waits for certain events on a given page, NotifyPageEvents() wakes up
  waiting threads respectively.
* Used the new feature instead of condition variables for waiting on busy
  pages. We save publishing and unpublishing of a condition variable whenever
  a page is marked busy. There's only something to do, if there's at least
  one thread waiting in the list of the respective cache. The general
  assumption is that this is only rarely the case and even if it happens,
  there should be only very few threads.
* Added an apparently missing notification in cache_io(). At least I didn't
  see the reason for it not being there.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34537 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-07 15:42:08 +00:00
Ingo Weinhold
be7328a9f6 Moved VMCache related definitions to <vm/VMCache.h>.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34535 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-07 14:14:21 +00:00
Ingo Weinhold
bcfdfff497 Added 64 bit TODO. We'll probably have to change the interface (cookie type)
of get_next_area_info() and others.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34533 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-07 12:26:26 +00:00
Ingo Weinhold
40cd019ea0 * Renamed VMAddressSpace::ResizeArea{Head,Tail}() to ShrinkArea{Head,Tail}()
to clarify that they never enlarge the area.
* Reimplemented VMKernelAddressSpace. It is somewhat inspired by Bonwick's
  vmem resource allocator (though we have different requirements):
  - We consider the complete address space to be divided into contiguous
    ranges of type free, reserved, or area, each range being represented by
    a VMKernelAddressRange object.
  - The range objects are managed in an AVL tree and a doubly linked list
    (the latter only for faster iteration) sorted by address. This provides
    O(log(n)) lookup, insertion and removal.
  - For each power of two size we maintain a list of free ranges of at least
    that size. Thus for the most common case of B_ANY*_ADDRESS area
    allocation, we find a free range in constant time (the rest of the
    processing being O(log(n))) with a rather good fit. This should also
    help avoiding address space fragmentation.
  While the new implementation should be faster, particularly with an
  increasing number of areas, I couldn't measure any difference in the -j2
  haiku build. From a cursory test the -j8 build hasn't tangibly benefitted
  either.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34528 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-06 17:18:04 +00:00
Ingo Weinhold
fe30b74fde Fix for stack traces in the early boot process: The thread might not have
its stack top/bottom assigned yet.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34527 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-06 16:01:21 +00:00
Ingo Weinhold
a54549a8cd * AVLTree:
- Renamed to AVLTreeBase and moved it into its own header/source file.
  - Renamed FindClose() to FindClosest().
  - Added CheckTree() method for debugging purposes. It checks the validity
    of the tree.
* Added a templatized class AVLTree which doesn't offer a map-like interface
  like AVLTreeMap, but rather one similar to BOpenHashMap and SplayTree. It
  is more convenient to use, if one wants to store objects that already
  contain the key.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34526 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-06 15:59:37 +00:00
Ingo Weinhold
08d9b6d462 Obvious copy and paste left-over. Totally missed it as I've been testing
the wrong image for quite a while. :-/


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34494 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-04 21:32:00 +00:00
Ingo Weinhold
2c1886aeae * Added VMArea subclasses VM{Kernel,User}Area and moved the address space list
link to them.
* VM{Kernel,User}AddressSpace manage the respective VMArea subclass now, and
  VMAddressSpace has grown factory methods {Create,Delete}Area.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34493 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-04 17:07:16 +00:00
Ingo Weinhold
e2518ddbb1 Made VMAddressSpace an abstract base class and moved the area management into
new derived classes VM{Kernel,User}AddressSpace. Currently those are
identical, but that will change.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34492 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-04 14:45:08 +00:00
Ingo Weinhold
38a97b2c36 Moved all knowledge of reserved areas from vm.cpp to VMAddressSpace. It's a
pure address space feature, so it should be handled there.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34491 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-04 13:33:25 +00:00
Ingo Weinhold
f69032f22b * Added VMAddressSpace::ResizeArea{Head,Tail}() to adjust an area's base
and size.
* Made VMArea::Set{Base,Size}() private and made VMAddressSpace a friend.
  In vm.cpp the new VMAddressSpace::ResizeArea{Head,Tail}() are used
  instead.
Finally all address space changes happen in VMAddressSpace only. *phew*
Now it's ready to be thoroughly butchered. :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34467 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-03 15:21:18 +00:00
Ingo Weinhold
bbd97b4bb4 Made the VMArea fields base and size private and added accessors instead.
This makes it more explicit where the fields are modified.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34464 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-03 14:18:24 +00:00
Colin Günther
af983c175d Coding style cleanups. Thanks axeld.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34462 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-03 13:05:39 +00:00
Ingo Weinhold
35d940014e * Changed the address space area list to doubly linked. The reason is to
simplify migration of the area management, but as a side effect, it also
  makes area deletion O(1) (instead of O(n), n == number of areas in the
  address space).
* Moved more area management functionality from vm.cpp to VMAddressSpace and
  VMArea structure creation to VMArea. Made the list and list link members
  itself private.
* VMAddressSpace tracks its amount of free space, now. This also replaces
  the previous mechanism to do that only for the kernel address space. It
  was broken anyway, since delete_area() subtracted the area size instead of
  adding it.
* vm_free_unused_boot_loader_range():
  - lastEnd could be set to a value < start, which could cause memory
    outside of the given range to be unmapped. Haven't checked whether this
    could happen in practice -- if so, it would be seriously unhealthy.
  - The range between the end of the last area in the range and the end of
    the range would never be freed.
  - Fixed potential integer overflows when computing addresses.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34459 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-03 12:41:11 +00:00
Colin Günther
1581b764e0 * Adding static Notify{One,All} functions. This allows a cleaner implementation
of the condition variable and synchronization subsystem of the freebsd compat
  layer which will be committed next.
* Also there was a discussion about adding these functions on the commit
  mailing list. The mail in http://www.freelists.org/post/haiku-commits/r34395-in-haikutrunksrclibscompatfreebsd-network-compatsys,3
  is a good sum up of it (need to scroll somewhat down, though).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34458 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-03 12:24:17 +00:00
Ingo Weinhold
def9898c9b Moved the three address space locker classes into a separate pair of
header/source files.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34451 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-02 20:16:31 +00:00
Ingo Weinhold
f34a1dd5d7 Created VMArea.{h,cpp} and moved VMArea and the global area hash table (new
class VMAreaHash) there.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34450 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-02 19:55:59 +00:00
Ingo Weinhold
e50cf8765b * Moved the VM headers into subdirectory vm/.
* Renamed vm_cache.h/vm_address_space.h to VMCache.h/VMAddressSpace.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34449 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-02 18:05:10 +00:00
Axel Dörfler
939b3801ea * Add info if the B_NO_HANDLED_INFO flag is set in the "ints" KDL command.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34448 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-02 16:49:22 +00:00
Ingo Weinhold
90d870c155 * Moved VMAddressSpace definition to vm_address_space.h.
* "Classified" VMAddressSpace, i.e. turned the vm_address_space_*() functions
  into methods, made all attributes (but "areas") private, and added
  accessors.
* Also turned the vm.cpp functions vm_area_lookup() and
  remove_area_from_address_space() into VMAddressSpace methods. The rest of
  the area management functionality will follow soon.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34447 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-02 16:12:15 +00:00
Ingo Weinhold
fc7864091e Attempt at allowing to use C++ structures in C only code: We use the
CreateAsmStructOffsetsHeader mechanism to generate a header with macros
defined to the sizes of the structures we're interested in and when compiling
in C mode define the structures as "struct { char bytes[size]; }".
It works in principle, but due to how jam works, one would have to specify the
dependency to the generated header for all sources that include it directly or
indirectly.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34441 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-02 10:56:10 +00:00
Ingo Weinhold
a477e3cf20 Finished renaming of vm_cache to VMCache.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34424 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-01 17:45:55 +00:00
Ingo Weinhold
a99eb6b56f vm_area -> VMArea
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34423 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-01 17:40:04 +00:00
Ingo Weinhold
b0db552cd9 Renamed vm_address_space to VMAddressSpace.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34422 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-01 17:27:09 +00:00
Ingo Weinhold
fe01182ce4 Accidentally reverted this change before committing: Invalid cast in C++.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34421 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-01 17:26:22 +00:00
Ingo Weinhold
bd185b4117 *.c -> *.cpp
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34417 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-01 17:06:26 +00:00
Axel Dörfler
7cab82a1c9 * Cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34415 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-01 16:20:41 +00:00
Axel Dörfler
943bec1287 * Made a class out of free_chunk.
* Fixed realloc() - "size" wasn't what I thought it would be.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34412 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-01 15:39:55 +00:00
Axel Dörfler
3c627a2751 * Reimplemented realloc() to reuse the previous buffer if possible and useful.
* Cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34409 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-01 14:50:33 +00:00
Ingo Weinhold
e182b46db6 Since there were no further complaints: Added mutex_lock_with_timeout().
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34403 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-01 09:38:34 +00:00
Ingo Weinhold
f39f7a05a2 Add init_once.cpp to the build.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34401 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-01 09:35:25 +00:00
Ingo Weinhold
840be9d6e6 Added __init_once(), an almost exact clone of pthread_once(), with the
difference that the initialization function has an additional void* argument,
so that it is suitable for initializing stuff in objects.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34400 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-01 09:34:58 +00:00
Axel Dörfler
be62abafab * Use a condition variable when waiting for a syscall to be done calling.
* Use C++ DoublyLinkedList class instead of the struct list.
* Note, this code is untested yet, but I will test it now (Qemu doesn't work
  on Haiku anymore for some reason) :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34382 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-30 16:10:11 +00:00
Axel Dörfler
4c3744b8d7 * Added missing license.
* Cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34372 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-30 12:37:16 +00:00
Ingo Weinhold
258b34c594 * Fixed wrong parameter of lazy_mutex_destroy().
* Split locks.cpp into mutex.cpp, recursive_lock.cpp, and rw_lock.cpp (new
  subdirectory locks/).
* runtime_loader no longer includes the rw_lock, allowing removal of the TLS
  dependency again.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34364 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-30 10:29:51 +00:00
Axel Dörfler
c598298047 * Cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34363 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-30 08:31:31 +00:00
Axel Dörfler
a4faebeb11 * Replace the FD used for fopendir() instead of closing the old one - according
to the specs, the application may still use the FD without changing its state,
  and only closedir() should finally close it.
* This fixes bug #5055.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34362 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-30 08:29:12 +00:00
Jérôme Duval
f6379d4127 added tls.o to runtimeloader. It linked successfully on x86 because of inlining.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34360 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-29 21:58:35 +00:00
Ingo Weinhold
ea77094b24 Replaced the hown-grown recursive lock implementation by a shared lazy
recursive lock. I haven't investigated it closer, but the previous
implementation was even broken -- "strace /bin/true" showed two
release_sem() calls, but no acquire_sem().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34342 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-29 11:17:53 +00:00
Ingo Weinhold
8bef23107e Added a lazy_recursive_lock implementation -- identical to recursive_lock,
just using a lazy_mutex instead.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34341 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-29 11:14:50 +00:00
Ingo Weinhold
6e06922908 Replace semaphores/benaphores in the env, fork, and user/group code by lazy
mutexes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34340 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-29 10:47:01 +00:00
Ingo Weinhold
937b23cb21 Added locking primitive lazy_mutex, which has essentially the same behaviour
as a mutex, but allocates its semaphore lazily. This comes at the cost of an
additional atomic_add() when the semaphore has actually to be acquired, but
saves the semaphore creation completely in single-threaded programs and in
any program when there's no lock contention.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34339 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-29 10:44:07 +00:00
Ingo Weinhold
f2bb2575e6 Use the shared recursive lock implementation instead of the home-grown stuff.
The shared implementation is benaphore style, saving unnecessary syscalls.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34338 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-29 09:57:26 +00:00
Ingo Weinhold
93b9f21335 Added recursive lock implementation (an adapted kernel version).
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34337 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-29 09:54:58 +00:00
Ingo Weinhold
d78ffde5d1 * Some minor cleanup and improved comments.
* Fixed check in hoardSbrk(): resize_area() was invoked, even if the area was
  already large enough.
* Increased the initial heap size to 64 pages. Apparently the hoard
  implementation is rather generous and the first malloc() (caused by
  __init_heap()) already required enlarging the area.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34336 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-29 09:20:58 +00:00
Axel Dörfler
dec91a9754 * Cleanup, no functional change.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34321 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-27 18:10:03 +00:00
Ingo Weinhold
a492466dad Created new private system header computed_asm_macros.h defining the macro we
use for the asm_offsets.cpp file, so it can be reused elsewhere.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34311 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-27 14:07:05 +00:00
Axel Dörfler
1db31d4dbd * The slab and the block cache now both also react on address space shortages.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34310 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-27 13:04:30 +00:00
Axel Dörfler
b8a73945cf * The kernel's address space is now also a resource that is known to the low
resource manager.
* Could be drastically improved, though, by taking the fragmentation into
  account.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34309 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-27 13:03:28 +00:00
Axel Dörfler
95235380f1 * Minor clarification.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34307 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-27 12:26:37 +00:00
Axel Dörfler
f4ab5d73ce * This fixes the remaining warnings in exit.c
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34294 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-26 17:00:09 +00:00
Axel Dörfler
52d6f78a9a * Minor cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34292 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-26 16:58:36 +00:00
Axel Dörfler
f31ffa6b8a * Use O_CLOEXEC when open directories, attribute directories, indexes, and
queries.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34291 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-26 16:38:54 +00:00
Axel Dörfler
d82802841c * Minor cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34290 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-26 16:33:03 +00:00
Axel Dörfler
486fffdaaf * Forgot to add linkat(), this really closes #4928 now.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34289 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-26 16:30:16 +00:00
Axel Dörfler
fb2500da15 * Added missing AT_EACCESS.
* Implemented renameat(), faccessat(), fchownat(), fchmodat(), and mkfifoat().
* Added stub for mknodat().
* The kernel backend for faccessat() does not yet differentiate between
  effective and real user/group IDs, though.
* Removed B_ENABLE_INCOMPLETE_POSIX_AT_SUPPORT, as we now support everything
  (more or less). This also closes ticket #4928.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34288 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-26 16:17:17 +00:00
Axel Dörfler
7ce581d7eb * Eliminated the extra buffer in dir_vnode_to_path(); we write directly to the
specified buffer now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34282 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-26 14:28:55 +00:00
Axel Dörfler
00362625b9 * Added support for O_NOFOLLOW.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34279 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-26 14:18:23 +00:00
Axel Dörfler
432bb91f34 * dir_vnode_to_path() now uses B_* error codes instead of POSIX ones, and also
returns the correct error code if the buffer was too small (should be ERANGE
  instead of ENOBUF).
* Also, it is now independent of B_PATH_NAME_LENGTH, and therefore should
  fulfill POSIX getcwd() requirements. This should also close ticket #3352.
* Is there any reason to allocate another buffer instead of using memmove()
  at the end instead of memcpy()?


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34276 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-26 12:46:51 +00:00
Axel Dörfler
1ba04177d3 * load_image() now has exec() semantics wrt file descriptors; before each team
would always inherit them all, causing quite a number of open files.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34247 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-25 16:16:22 +00:00
Axel Dörfler
3a6fc6d0aa * Improved debug output.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34246 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-25 16:14:52 +00:00
Axel Dörfler
40fddd06d6 * Introduced a flag to decide whether it's still okay to call a certain
syscall.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34238 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-25 11:50:45 +00:00
Axel Dörfler
23f179da55 * Cleanup, no functional change.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34237 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-25 11:48:39 +00:00
Axel Dörfler
24ce75c3d8 * Added a use counter for the syscalls, so that they are no longer removed
while a hook is called.
* This closes ticket #5027.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34233 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-25 09:37:31 +00:00
Axel Dörfler
5472c0c23e * The VESA driver now tries to find the PCI card that it is controlling by
checking the physical frame buffer location.
* This allows us to map the whole frame buffer at once, which means there is no
  need anymore to remap the memory on mode change.
* Also, this will ease the burden of the MTRRs, as the memory size will be
  properly aligned.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34206 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-24 15:26:52 +00:00
Ingo Weinhold
bb163c0289 * Added a set_mtrrs() hook to x86_cpu_module_info, which is supposed to set
all MTRRs at once.
* Added a respective x86_set_mtrrs() kernel function.
* x86 CPU module:
  - Implemented the new hook.
  - Prefixed most debug output with the CPU index. Otherwise it gets quite
    confusing with multiple CPUs.
  - generic_init_mtrrs(): No longer clear all MTRRs, if they are already
    enabled. This lets us benefit from the BIOS's setup until we install our
    own -- otherwise with caching disabled things are *really* slow.
* arch_vm.cpp: Completely rewrote the MTRR handling as the old one was not
  only slow (O(2^n)), but also broken (resulting in incorrect setups (e.g.
  with cachable ranges larger than requested)), and not working by design for
  certain cases (subtractive setups intersecting ranges added later).
  Now we maintain an array with the successfully set ranges. When a new range
  is added, we recompute the complete MTRR setup as we need to. The new
  algorithm analyzing the ranges has linear complexity and also handles range
  base addresses with an alignment not matching the range size (e.g. a range
  at address 0x1000 with size 0x2000) and joining of adjacent/overlapping
  ranges of the same type.

This fixes the slow graphics on my 4 GB machine (though unfortunately the
8 MTRRs aren't enough to fully cover the complete frame buffer (about 35
pixel lines remain uncachable), but that can't be helped without rounding up
the frame buffer size, for which we don't have enough information). It might
also fix #1823.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34197 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-23 15:06:08 +00:00
Ingo Weinhold
12fef51bc7 Since r33809 dprintf() acquires a mutex when called with interrupts enabled.
This is something must must not do in an idle thread or we get the scheduler
into trouble.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34196 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-23 14:19:09 +00:00
Stephan Aßmus
f89fd840a0 bonefish+stippi:
PThreads didn't have their array for the TLS values initialized.
From what we can tell, this would have been a problem for any program using
pthreads, but since all threads are pthreads now, it was much more likely to
be encountered. Like in Beam as reported in #4949 (which via libbind seems
to use some pthread stuff).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34161 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-20 18:08:56 +00:00
Axel Dörfler
5cea99288b * Unlock the auto locker before deleting the object or else you will find
yourself in KDL.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34158 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-20 16:33:09 +00:00
Ingo Weinhold
0d1fab522b * Added flag KMESSAGE_CLONE_BUFFER, which will cause buffer passed to SetTo()
to be cloned.
* Added "flags" parameter to the SetTo(const void*,...) version.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34155 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-20 13:52:23 +00:00
Ingo Weinhold
395fb0895f Style cleanup. No functional change.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34152 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-20 11:04:12 +00:00
Ingo Weinhold
1c61ec1aad Fixed gcc 4 warning.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34151 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-20 11:03:27 +00:00
Ingo Weinhold
c89002c82c * Added missing include.
* Made buildable for userland.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34146 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-20 07:56:18 +00:00
Ingo Weinhold
9837ec16c8 Fixed spelling.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34144 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-20 07:10:23 +00:00
Ingo Weinhold
1748a3cb45 IOBuffer::SetVecs(): fUser was initialized incorrectly, if the vecs referred
to physical memory whose address would accidentally satisfy the
IS_USER_ADDRESS() check.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34136 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-19 16:23:22 +00:00
Ingo Weinhold
778aa3bf62 transfer_io_request_data(): There was some confusion about the isWrite
parameter and request->IsWrite(). The parameter means whether we want to
write to the request's I/O buffer (therefore renamed it to writeToRequest),
while request->IsWrite() indicates whether the request is a write request.
One can only write to a read request's buffer and vice versa.
IOBuffer::LockMemory() also wants to know whether the request is a write
request, not whether we want to write to the memory.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34135 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-19 16:19:59 +00:00
Ingo Weinhold
62b3c49b85 Added missing "static". Spotted by Axel "Eagle Eye" Doerfler. ;-)
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34123 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-19 08:41:13 +00:00
Ingo Weinhold
59d51abc40 Removed obsolete uncommented function stubs.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34122 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-19 07:39:47 +00:00
Ingo Weinhold
1ca0b78f54 Extended the public I/O request C API.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34121 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-19 07:38:33 +00:00
Axel Dörfler
dcf71e1cae * Cleanup, no functional change.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34094 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-17 16:08:22 +00:00
Axel Dörfler
8fd850fca9 * Added "address" specifier for the "allocations" KDL command.
* Removed superfluous malloc.h include.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34093 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-17 16:07:58 +00:00
Axel Dörfler
931d8b07e8 * Reverted r32216 (by mmlr): it's not a good idea to access a variable on the
stack after that has just been changed, and does not contain the data one
  would assume.
* This fixes the leaking the vm_translation_map_arch_info objects, and thus
  bug #4957.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34090 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-17 14:56:51 +00:00
Axel Dörfler
3917e20402 * Minor cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34089 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-17 14:54:32 +00:00
Ingo Weinhold
713cc7fc84 Added fs_read_attr().
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34085 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-17 11:35:47 +00:00
Axel Dörfler
96c4511a25 * Shuffled functions around, no functional change.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34083 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-17 10:23:53 +00:00
Axel Dörfler
07d4556346 * Change get_next_sem_info() to be index based, not ID based - the semaphore IDs
aren't monotonically increasing which this code was assuming. This fixes bug
  #4917.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34074 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-16 13:08:36 +00:00
François Revol
fbe3b5b994 Force C linkage on those two, fixes them being undefined after the .c to .cpp rename.
Fixes part of #4965.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34042 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-14 19:44:00 +00:00
Ingo Weinhold
6c00aabc9e Implemented POSIX.1-2008 functions unlinkat(), symlinkat(), mkdirat(),
utimensat(), and futimens().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34010 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-12 19:14:42 +00:00
Ingo Weinhold
db2b554fa3 Moved the POSIX *at() functions and AT_* macros out of the default namespace
as long as the full set hasn't been implemented. They are guarded by the
B_ENABLE_INCOMPLETE_POSIX_AT_SUPPORT macro until then. Fixes the build.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33990 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-10 17:12:03 +00:00
Ingo Weinhold
a6147679a3 Added AT_SYMLINK_[NO]FOLLOW constants and fstatat(). Fixes the findutils
gnulib build.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33987 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-10 14:51:25 +00:00
Axel Dörfler
492dd892ce * Removed /system/etc directory.
* /etc now points to /boot/common/etc/, and the remaining contents of the former
  "etc" are put there now, as well.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33986 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-10 14:26:42 +00:00
Axel Dörfler
0491552bc3 * Moved the "fonts" directory into the "data" directory.
* Moved fonts to where they belong.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33981 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-10 12:30:06 +00:00
Ingo Weinhold
9c71b326c9 Fixed build.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33980 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-10 12:20:26 +00:00
Ingo Weinhold
b189a2014e Added readlinkat().
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33978 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-10 11:24:46 +00:00
Ingo Weinhold
fdec1a3f87 Should have been part of r33976: fcntl.c and open.c have been joined to
fcntl.cpp.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33977 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-10 11:16:44 +00:00
Ingo Weinhold
098906f1d4 * src/system/libroot/posix: Moved open.c and fcntl.c out of the unistd
directory, where they were misplaced, and joined them to fcntl.cpp.
* Added openat().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33976 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-10 11:15:35 +00:00