Commit Graph

3699 Commits

Author SHA1 Message Date
Ingo Weinhold
211c63df5a reserve_pages(): When cannibalizing pages from the own cache it didn't check
whether the pages where mapped. Was introduced already in r22731.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35532 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-20 12:36:49 +00:00
Ingo Weinhold
9824ded0b0 cache_io(): Also requeue the last touched page to keep things roughly LRU
sorted.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35530 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-20 10:51:53 +00:00
Jérôme Duval
87c1c0e443 moved fenv arch implementations to their respective directories
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35527 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-19 22:48:35 +00:00
Axel Dörfler
63b69bec3c * Applied patch by Andreas Färber as part of #5319.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35522 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-19 16:44:55 +00:00
Ingo Weinhold
c3d7933274 Added missing PPCVMTranslationMap::QueryInterrupt(). Fixes #5275.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35516 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-18 17:43:09 +00:00
Ingo Weinhold
dac21d8bfe * map_physical_memory() does now always set a memory type. If none is given (it
needs to be or'ed to the address specification), "uncached" is assumed.
* Set the memory type for the "BIOS" and "DMA" areas to write-back. Not sure, if
  that's correct, but that's what was effectively used on my machines before.
* Changed x86_set_mtrrs() and the CPU module hook to also set the default memory
  type.
* Rewrote the MTRR computation once more:
  - Now we know all used memory ranges, so we are free to extend used ranges
    into unused ones in order to simplify them for MTRR setup.
  - Leverage the subtractive properties of uncached and write-through ranges to
    simplify ranges of any other respectively write-back type.
  - Set the default memory type to write-back, so we don't need MTRRs for the
    RAM ranges.
  - If a new range intersects with an existing one, we no longer just fail.
    Instead we use the strictest requirements implied by the ranges. This fixes
    #5383.

Overall the new algorithm should be sufficient with far less MTRRs than before
(on my desktop machine 4 are used at maximum, while 8 didn't quite suffice
before). A drawback of the current implementation is that it doesn't deal with
the case of running out of MTRRs at all, which might result in some ranges
having weaker caching/memory ordering properties than requested.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35515 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-18 13:52:43 +00:00
Axel Dörfler
c5e52ecb78 * cache_sync_transaction() now puts all blocks into the BlockWriter, and
therefore does not unlock anymore while iterating over the transactions.
  This gave other threads the opportunity to finish a transaction, causing
  bug #5412. Also, the BlockWriter will now always close transactions on its
  own, and you need to pass the transaction hash iterator to Add().
* Also, transactions that contain blocks that are currently written back will
  be ignored by the block writer, as well as cache_sync_transaction(). This
  fixes bug #5415.
* Improved error handling if BlockWriter fails to write back blocks. Most
  notably, they are no longer left busy_writing, and the functions calling
  it do proper error reporting (besides block_cache_discard() that does not
  return any erro code; I've added a TODO note there for now).
* The BlockWriter now starts with a larger array once it has to allocate one.
* One can now limit the number of blocks that go into a BlockWriter. This is
  used by the block writer thread, that shouldn't always write back everything
  every two seconds.
* Also, the fixed array is larger now (leaving enough space such that the
  block writer/notifier does not need to allocate anything).
* And finally, if allocating the array fails, the BlockWriter falls back to the
  synchronous write back used previously. IOW it will never write back less
  blocks than you ask for.
* Added static BlockWriter::WriteBlock() method replacing write_cached_block().
* Forgot to rename block_cache::busy_count to busy_reading_count.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35510 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-17 16:36:40 +00:00
Ingo Weinhold
d4af8f3e33 Added several TODOs for problems of the IOBuffer virtual vecs code.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35509 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-17 16:00:05 +00:00
Ingo Weinhold
176f7588eb Added warning to vm_map_physical_memory_vecs().
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35508 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-17 15:58:12 +00:00
Axel Dörfler
8941a2ba08 * Fixed compilation with PARANOID_HEAP_VALIDATION turned on.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35507 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-17 15:40:02 +00:00
Stefano Ceccherini
03bab65450 set_hardware_timer() would sometimes (on boot) pass a negative timeout to
arch_timer_set_hardware_timer(). This was harmless, at least with our
current x86 timers implementation, since they checked for minimum timeouts.
Very small cleanup (now that the file is compiled as C++).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35505 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-17 09:12:43 +00:00
Ingo Weinhold
1f611c018b The file cache code was completely ignoring the vm_page::modified flag. In
particular it wouldn't set the flag when writing something to a page, but
only move it to the modified queue. Since mapping the page would move it to
another queue, the information that the page was modified would be lost and
it would never be written to disk. Was well reproducible with a Haiku image
build and limited amount of memory.
Fixes the hopefully last remaining cause for #5374.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35500 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-16 17:22:56 +00:00
Ingo Weinhold
6949076049 * Added some more asserts for cached pages.
* full_scan_inactive_pages(): Fixed syntactical glitch (missing "else").
  Affected only the active paging mode and was relatively harmless. The worst
  case would be that an inactive page would be moved to the cached queue
  although its usage_count hadn't dropped to 0 yet, thus freeing it before
  pages that deserved it more.
* move_page_to_active_or_inactive_queue():
  - Was ignoring the page's modified flag, thus potentially moving a modified
    page to the cached queue. That could happen only in rare cases though,
    like when the page was still mmap()ped while being written and modified and
    unmapped before being done.
  - No longer move the page to the inactive queue, even if its usage count is 0.
    In idle mode the page daemon doesn't look at inactive pages, so the page's
    stats wouldn't be updated anymore.
  - Renamed to move_page_to_appropriate_queue().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35499 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-16 17:12:42 +00:00
Ingo Weinhold
665e7ac629 map_page(): Got rid of the activatePage parameter. We always move previously
inactive pages to the active queue. This has the advantage that the page
daemon will keep track of those pages even in idle mode (where it only
processes the active queue).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35498 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-16 16:54:01 +00:00
Axel Dörfler
66a1a16cbc * Made cache_end_transaction(), cache_detach_sub_transaction(), and
block_cache_discard() use the BlockWriter directly as well.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35496 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-16 14:00:44 +00:00
Axel Dörfler
599b988100 * Fixed coding style violation.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35495 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-16 13:26:28 +00:00
Axel Dörfler
e190cae151 * Build fix (bfs_inode::InitCheck() is now const), and cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35494 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-16 12:49:52 +00:00
Axel Dörfler
319a2dee90 * Improved KDL command output (ie. take busy_writing into account, too).
* Added new KDL command "cached_block" that dumps a cached block.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35493 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-16 12:24:54 +00:00
Axel Dörfler
751e92fde1 * cache_sync_transaction() used an earlier signature of the BlockWriter
constructor, causing bug #5412.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35489 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-16 08:16:17 +00:00
Michael Lotz
64bf879506 Finish the implementation of heap_debug_malloc_with_guard_page() using mprotect
to make the guard page inaccessible. Thanks Ingo for the pointer!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35488 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-15 23:48:51 +00:00
Ingo Weinhold
22fb471ff0 * page_writer(): Missing continue in the temporary skipping case.
* vm_page_write_modified_page_range(): Need to DEBUG_PAGE_ACCESS_END() a bit
  later.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35487 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-15 23:01:31 +00:00
Ingo Weinhold
4322b983cd Fixed the build with DEBUG_PAGE_ACCESS enabled.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35486 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-15 22:50:28 +00:00
Ingo Weinhold
fa47a7c434 page_writer():
* Use the same criterion when to write back temporary pages as the page daemon.
* Move wired and temporary pages that shall not be written back to the active or
  inactive queue so they don't get stuck in the modified queue and potentially
  cause the page writer to run permanently without actually making progress
  (#5382).

page writing implementation:
* If writing back a temporary page failed, move it back to the inactive or
  active queue, so it doesn't get stuck in the modified queue. If active paging
  continues, it might find its way back to the modified queue in the next
  iteration, but that improves the situation a bit at least. Particularly with
  the port heap pages not really being swappable ATM.
* Never dequeue pages from the modified queue. We mark them busy, so the page
  writer will skip them anyway. This allows others to play with the page to some
  extend (at least allowing to move it between the queues). This fixes #5404.
* Removed PageWriteWrapper::ClearModifiedFlag(). We clear the modified flag in
  PageWriteWrapper::SetTo(), now, so that the page writer doesn't need to do
  that explicitly either.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35485 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-15 22:40:37 +00:00
Ingo Weinhold
bf96cfdcbe Added TODO regarding the non-swappability of the initial port heap area.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35484 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-15 22:19:49 +00:00
Ingo Weinhold
3795172c67 VMVnodeCache::AcquireUnreferencedStoreRef(): We put the wrong vnode when ours
was already deleted.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35483 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-15 22:18:39 +00:00
Michael Lotz
386c8bad1b Return an error when encountering an invalid allocation info.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35482 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-15 21:42:55 +00:00
Michael Lotz
ac653a30df Add heap_debug_set_debugger_calls() which allows to disable debugger calls for
the heap debug panics. Instead syslog output is generated if turned off.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35481 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-15 21:35:07 +00:00
Michael Lotz
c1502cf1b8 Add heap_debug_get_allocation_info() to retrieve the size of the allocation as
well as the thread allocating it. Can for example be used to verify that an
object or buffer is as large as expected.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35480 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-15 20:57:52 +00:00
Michael Lotz
081ff2db28 * Add heap_debug_set_memory_reuse() which allows to disable memory reuse,
keeping all returned heap memory in the 0xdeadbeef state (including the
  first sizeof(void *) bytes otherwise for the free list). While wasting a lot
  of memory it allows you to rely on 0xdeadbeef being always present as no
  future allocation will reuse the freed memory block.
* Also added heap_debug_malloc_with_guard_page() which is intended to allocate
  a memory block so it is aligned that the start of invalid memory past the
  allocation is in an unmapped guard page. However the kernel backend that would
  guarantee this is not yet implemented, so right now this works only by chance
  if no other area happens to be allocated exactly past the created one. With a
  very specifc suspicion you can put that one allocation you get to good use
  though. It causes a crash when accessing memory past the allocation size so
  you actually get a backtrace from where the access happened instead of only
  after freeing/wall checking.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35478 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-15 20:28:15 +00:00
Ingo Weinhold
ba3d62b66f X86VMTranslationMap::UnmapArea(): Don't change the page state before
it has been unmapped. This way modified pages could end up in the "cached"
queue without having been written back. That would be a good explanation for
#5374 (partially wrong file contents) -- as soon as such a page was freed,
the invalid on-disk contents would become visible.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35477 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-15 19:36:17 +00:00
Ingo Weinhold
c1f3da7b5b UnmapPage() requires the caller to deal with the debug page access marking,
so the fallback implementations of UnmapPages() and UnmapArea() need to do
that. Not relevant for x86.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35476 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-15 19:10:44 +00:00
Ingo Weinhold
0f2666ecc2 _user_set_memory_protection(): Missing page access debug markers.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35475 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-15 18:49:12 +00:00
Ingo Weinhold
b0f5b17072 Removed PageWriteWrapper::CheckRemoveFromShrunkenCache() and moved removing
the page to Done().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35474 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-15 18:47:45 +00:00
Axel Dörfler
54f3267e78 * Fixed maintaining the object depot's free magazine count (it's not really used
though).
* Added/improved some KDL commands to make the slab easier to work with from
  KDL.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35466 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-15 13:22:58 +00:00
Axel Dörfler
2cb3c4eb06 * Improved panic output I recently ran into.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35465 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-15 13:20:01 +00:00
Axel Dörfler
4ea83177ff * Implemented a BlockWriter class that now performs writing back blocks.
* Renamed the "busy" stuff to "busy_reading", and added a "busy_writing"
  concept.
* This now allows reading a block (and other blocks), while blocks are written
  back. This should speed all operations needing to write back blocks, like
  unzipping or compiling.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35464 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-15 13:07:14 +00:00
Axel Dörfler
fb40740174 * Restructured the notification driven addition/removal of drivers to
driver_events (ie. there is now only a single list to walk).
* Also, the DriverWatcher is now maintained using the driver_events.
  This fixes bug #5005.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35463 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-14 22:57:47 +00:00
Stefano Ceccherini
0b102d72d5 The hpet registers area is already wired, so use the vm_map_physical_memory()
call with the true parameter. Fixes a panic at boot when using the hpet timers


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35453 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-11 15:57:59 +00:00
Stefano Ceccherini
7ae188c379 Patch by Grey which fixes "auto-enabling" of the boot loader screen debug
which happened on some systems (mine included).
Should close ticket #5341.
Thanks! 


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35441 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-09 19:47:23 +00:00
Artur Wyszynski
e381020556 Disabled fenv for ppc & arm platforms for now.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35440 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-09 14:10:07 +00:00
Artur Wyszynski
38ecc1a764 Added FreeBSD fenv implementation - tested with dmd port, seems that it works
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35437 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-09 06:09:28 +00:00
Artur Wyszynski
cee04e8074 Fixed various errors/warnings reported by cppcheck:
* memory leaks
* resource leaks
* added const's to getters
* removed a few reundant conditions


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35433 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-08 22:50:38 +00:00
Michael Lotz
f6a6245c89 * Adding malloc_debug.h that exposes the malloc_debug API.
* Moving some functions around, removing and adding others for the public API.

I've written a blog post at haiku-os.org to go as documentation for this
introducing the API and the other helpful bits.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35431 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-08 01:27:21 +00:00
Michael Lotz
60fb713d19 Must only advance by step sizes, otherwise we may end up with misaligned pages
again.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35426 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-07 16:55:43 +00:00
Michael Lotz
160abe2685 Sync two locking changes from kernel heap. This just moves the page locking into
the contiguous page allocation function and unlocks a bin locker a bit earlier.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35424 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-07 02:02:13 +00:00
Michael Lotz
b7d3ddaa0e Sync kernel heap with alignment handling fixes, simplifications and performance
improvements from debug heap in r35422.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35423 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-07 01:59:53 +00:00
Michael Lotz
638a24fa52 * Seperate the raw page wise allocation and allocations from bins.
* Make the contiguous page allocation capable of aligning the allocation
  and make it more clever by checking up front if there's a chance of getting
  enough pages at all, by giving up earlier if the page count can't be fit
  anymore, and in the alignment case by only checking the pages which have a
  valid alignment.
* If the alignment requirement is > B_PAGE_SIZE we now use page allocation
  directly, because the bins aren't necesarily aligned on their size past
  B_PAGE_SIZE anymore.
* When doing aligned bin allocation, calculate the aligned size up front and
  choose the right heap for the allocation.
* Also when doing aligned bin allocations we not only need to round up the size
  but also ensure that the bin we choose is aligned at all.
* Moved adding leak check info into it's own function.

Fixes various misalignment problems when working with alignments > B_PAGE_SIZE
or when using alignments < allocation size. Also the directly aligned page
allocations now only use up as many pages as actually required instead of
allocating based on the rounded up to align size.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35422 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-07 01:09:27 +00:00
Stephan Aßmus
bc00016122 Patch by "notzed": Adapt ARM platform stubs for recent VM changes. Thanks!
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35411 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-05 08:20:11 +00:00
Ingo Weinhold
4dafcc3b3b Since we potentially split segments into different regions, we need to
consider that when filling in the text and data ranges of the image info.
This fixes #5361 and #5351, caused by libtracker.so not finding its own
image.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35407 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-04 19:01:11 +00:00
Ingo Weinhold
dc6a6a9b42 Reenabled interrupts before notifying the page writer.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35399 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-03 21:11:31 +00:00