vm_remove_all_page_mappings() all computed the wrong virtual address for the
page in question, and would therefore return incorrect data!
Introduced a virtual_page_address() function that is now used by all of them.
So that's why we were still "losing" modified flags - it took me some hours
to find those (sometimes processes died after stealing pages)...
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22498 a95241bf-73f2-0310-859d-f6bbb57e9c96
it intended to. That resulted in more writable pages where you wouldn't want
them (ie. allowing the area to change pages in lower caches).
* We were losing modified pages: vm_unmap_pages() sometimes has to preserve
the modified flag (eg. when called from page fault).
* Both of these were responsible that stealing active pages would crash
applications - even if less likely, this could also have happened when
stealing inactive pages. Therefore, I've activated stealing active pages
again.
* The page writer now pushes the pages of busy vnodes to the end of the queue,
so that it won't pick them up again too soon (the vnode destruction would
be in the process of writing those pages back, anyway).
* The page thief now triggers the page writer to run once it has to steal
active pages. This might be a bit too aggressive, though.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22495 a95241bf-73f2-0310-859d-f6bbb57e9c96
pages to reserve, which could result in to few being reserved in certain
situations.
* Use MutexLocker where appropriate.
* Reordered includes following the new rules.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22494 a95241bf-73f2-0310-859d-f6bbb57e9c96
the blue screen was initialized - blue_screen_enter() now returns wether
or not it has been initialized already (there will only be serial output
in that case).
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22491 a95241bf-73f2-0310-859d-f6bbb57e9c96
* The page_thief() will no longer steal any pages in B_LOW_MEMORY_NOTE state,
only in the more serious cases.
* I've disabled stealing active pages for now again; there seem to be some
problems with it (either with how we do it, or with other stuff).
* vm_page_schedule_write_page() now always releases the page writer semaphore,
resulting in many more written pages - this isn't optimal as long as there is
no I/O scheduler, but before it was much too rare when there are many dirty
pages.
* Customized the thread priorities a bit to make the page scanner/thief/writer
experience a bit nicer with our current scheduler.
* vm_page_reserve_pages() would return too early, it did not test if really
enough pages are free.
* Under certain circumstances, the wakeup from vm_page_reserve_pages() did not
work - we now always notify in vm_page_unreserve_pages() to work around that
problem.
* Checked if the page reservations are done when needed and are always balanced
for the whole kernel.
* vm_page_allocate_page() now panics if it can't deliver a reserved page.
* vm_page_allocate_page_run() can no longer steal reserved pages.
* With all of those changes, I could finally copy a file in emulation, ie. the
Luposian bug should finally be fixed, even though the system might still not
be perfectly stable under low memory. Will do some more testing.
* write_page() no longer prints something on failure.
* Dumping a whole page queue will now also write the cache type of each page.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22486 a95241bf-73f2-0310-859d-f6bbb57e9c96
busy vnodes.
* dir_create_entry_ref() used get_vnode() incorrectly (and could therefore
potentially prevent a file system from doing proper locking when called
from the kernel).
* The vnode_store now uses this for its acquire_unreferenced_ref()
implementation (and therefore for the page writer).
* read_into_cache() and write_to_cache() were still marked inline.
* The system will now wait 10 secs for a busy vnode before returning an error.
* It will also no longer panic in that case.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22485 a95241bf-73f2-0310-859d-f6bbb57e9c96
* vm_low_memory_state() now periodically recomputes the state in case the
low memory thread is waiting for something.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22483 a95241bf-73f2-0310-859d-f6bbb57e9c96
We actually need to fail for sockets, too, but until I'm mistaken, we
can't identify them in the VFS. Fixes bug #1539.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22480 a95241bf-73f2-0310-859d-f6bbb57e9c96
additional partition_data* child parameter now.
* _user_get_partitionable_spaces() doesn't need to copy the buffer into
the kernel, since it is no input parameter. It also copies back the
actual partitionable spaces count on error, now -- B_BUFFER_OVERFLOW
is returned when the buffer was too small, but then the count must be
returned too.
* Fixed several instances of syscall implementations that unloaded a disk
system, although they didn't load it in the first place. This screwed
up the load count with undesirable consequences.
* _user_create_child_partition() would set the size to the supplied
offset.
* Fixed broken loop in KPhysicalPartition::CreateShadowPartition().
* KPartition::RemoveChild() notified the listeners about the wrong
event.
* Intel partitioning module:
- The *_get_partitionable_spaces() correctly return B_BUFFER_OVERFLOW
now, if the supplied buffer is too small.
- Implemented a part of pm_shadow_changed(), which creates and updates
the PartitionMap, so that the validate_*() hooks have a chance to
work at all.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22475 a95241bf-73f2-0310-859d-f6bbb57e9c96
but it is mandatory to the KDiskSystem::ValidateCreateChild(), which is
invoked, so we need to use a stack variable.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22473 a95241bf-73f2-0310-859d-f6bbb57e9c96
physical partition, unlike get_partition() which returns the shadow
partition, if it exists.
* Added B_PARTITION_SHADOW[_CHILD] partition pseudo operation values for
the shadow_changed() hook, notifying a disk system, that a shadow
partition has been created.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22472 a95241bf-73f2-0310-859d-f6bbb57e9c96
allocate with the vm_cache locked - this is necessary to be able to steal pages
from itself (large files...).
The system doesn't actually lock up anymore, but it still renders itself unusable;
obviously the page thief does not work correctly, yet. The rest of the experience
is created by our current scheduler (the page thief runs and runs, but it doesn't
free any pages anymore).
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22466 a95241bf-73f2-0310-859d-f6bbb57e9c96
twice into the same cache: cache_io() called read_into_cache() (or
write_to_cache()), and that broke down the request into smaller parts.
It then called read_chunk_into_cache() (or write_chunk_to_cache() resp.)
to actually allocate pages and fulfill the request.
However, it needed to unlock the cache for each chunk, and in the mean
time someone else could insert pages into the remaining chunks.
* Now, cache_io() already takes care of chunking the data which makes this
approach safe, and also simplified the code a bit - read_into_cache()/
write_to_cache() are gone now. I've renamed read_chunk_into_cache() to
read_into_cache() (same for the write function).
* Also got rid of that goto in that function while I was on it.
* Disabled cache_prefetch_vnode() for now (it's similar to cache_io(), but
since it's currently not used [since no cache module is installed yet],
I didn't want to go through updating it now, too).
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22465 a95241bf-73f2-0310-859d-f6bbb57e9c96
* his has to be used by the page writer to make sure the vnode is still valid.
* This should have been the final nail on the Luposian bug - I haven't tested
it yet, but we'll certainly see :-)
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22462 a95241bf-73f2-0310-859d-f6bbb57e9c96
heap is going away soon, it doesn't hurt to have it in the repository.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22457 a95241bf-73f2-0310-859d-f6bbb57e9c96
interfere with the page thief, we always need to have reserved a page for
this upfront. I introduced a function to the vm_translation_map layer that
estimates how much pages a mapping might need at maximum. All functions that
map a page now call this and reserve the needed pages upfront.
It might not be a nice solution, but it works.
* The page thief could run into a panic when trying to call vm_cache_release_ref()
on a non-existing (NULL) cache.
* Also, it will now ignore wired active pages.
* There is still a race condition between the page writer and the vnode
destruction - writing a page back needs a valid vnode, but that might just
have been deleted.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22455 a95241bf-73f2-0310-859d-f6bbb57e9c96
mjw for the hint. Fixes bug #1516.
* Changed _{kern,user}_create_symlink() to no longer check the supplied
link string. BeOS seems to do that, but this is not standard
conforming. The previous implementation even used the path processed
by check_path(), which would potentially have appended a ".".
* Some style cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22451 a95241bf-73f2-0310-859d-f6bbb57e9c96
(currently, wired pages don't always have the PAGE_STATE_WIRED, but a
wired_count).
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22449 a95241bf-73f2-0310-859d-f6bbb57e9c96
* Corrected checking of parameters (name).
* Gracefully deals with disk systems that rescan after initialization,
now.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22448 a95241bf-73f2-0310-859d-f6bbb57e9c96
system initialize() hooks. It's often the only info about the
partition one needs and thus locking the partition just to get it is
no longer necessary.
* intel partitioning system:
- Removed passing around block sizes. We require 512 byte sectors
anyway. In fact using the parent partition's block size was even
wrong.
- Simplified writing the partition map sector.
- Simplified and corrected the partition map initialization.
- We don't fail identifying a partition anymore, if the partition map
contains no partitions. We would never identify a freshly
initialized partition map before.
- Made pm_identify() more intelligent: It determines the priority to
return depending on whether the partition is the device itself and
whether we have recognized child partitions.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22447 a95241bf-73f2-0310-859d-f6bbb57e9c96
the unmapped page.
* This is needed by everyone who calls this to make sure modifications to a
page aren't ignored. Namely, the page scanner and the page thief were
affected.
* Cleaned up locking the page's cache a bit in page_thief(); there is now
a helper class that takes care of everything.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22438 a95241bf-73f2-0310-859d-f6bbb57e9c96
* Made the kernel rootfs reusable by the FS Shell and removed the
copy in the FS Shell sources.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22436 a95241bf-73f2-0310-859d-f6bbb57e9c96
* the page writer don't allow to block, while all other writers do. This fixes
bug #1509. The reason the page writer needs this is because it marks several
pages from different caches as busy.
* Fixed a warning about ASSERT being defined already in BFS, since
util/DoublyLinkedList.h now includes debug.h.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22434 a95241bf-73f2-0310-859d-f6bbb57e9c96
team as well. Otherwise the children would later try to remove them from
a list they weren't in.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22429 a95241bf-73f2-0310-859d-f6bbb57e9c96
dprintf() with the exception that it doesn't write anything to the
syslog. The reason is that syslog_write() releases a semaphore and can
therefore not be invoked when the thread spinlock is held.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22428 a95241bf-73f2-0310-859d-f6bbb57e9c96
vfs_select.h, respectively moved most of it into the new kernel
private header wait_for_objects.h.
* Added new experimental API functions wait_for_objects[_etc](). They
work pretty much like poll(), but also for semaphores, ports, and
threads.
* Removed the "ref" parameter from notify_select_events() and the
select_sync_pool functions as well as from fd_ops::fd_[de]select(). It
is no longer needed. The FS interface select() hook still has it,
though -- the VFS will always pass 0.
* de]select_fd() take a select_info* instead of a select_sync* + ref
pair, now. Added respective functions for semaphores, ports, and
threads.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22416 a95241bf-73f2-0310-859d-f6bbb57e9c96
could be written back. This should stop the page thief from stealing active
pages that cannot be recreated easily :-)
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22404 a95241bf-73f2-0310-859d-f6bbb57e9c96
the death stack and reacquiring the thread lock in which another thread
could snatch our stack that we were still going to use for the
scheduler. Now we've got a second spinlock that we can hold while
releasing a semaphore.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22403 a95241bf-73f2-0310-859d-f6bbb57e9c96
and thread spinlock was reverse in Wait() and Notify(). The thread lock
is now the outer lock -- this way it is still possible to call Notify()
with the thread lock being held.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22401 a95241bf-73f2-0310-859d-f6bbb57e9c96
* In select_fd(): First get the file descriptor, then check whether any
events have to be selected at all. This has the advantage that the
caller can interpret an error return code as invalid FD. Consequently
common_poll() no longer checks FD validity separately -- this was a
race condition.
* common_poll() always selects POLLERR and POLLHUP now, which it has to
do according to the specs.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22400 a95241bf-73f2-0310-859d-f6bbb57e9c96
* Reworked the select support:
- The io_context additionally stores a table of lists of select_infos,
which enables it to deselect events of a pending select() when
closing a FD. This prevents a race condition potentially causing a
write to stale memory.
- The opaque selectsync* passed to FSs is now actually a select_info*.
This was necessary, since the FDs deselect() hook (unlike the
select() hook) doesn't take a "ref" argument and deselecting a
single info (e.g. caused by a premature close()) was not possible.
The select() hook's "ref" argument has become superfluous.
- It should now be relatively easy to implement a poll_on_steroids()
that can also wait for objects other than FDs (e.g. semaphores,
ports, threads etc.).
* Set/reset the signal mask in common_select(). This makes pselect()
work as required.
* Reorganized vfs_resize_fd_table().
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22391 a95241bf-73f2-0310-859d-f6bbb57e9c96
necessary because low memory handlers might need to wait for other services
while we need to make sure the page thief can always steal pages.
* Made the page thief more aggressive when memory is critical: added a third
run where it will also steal a small amount of active pages to keep things
going.
* The page thief did not maintain the cache's reference correctly in all
situations.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22382 a95241bf-73f2-0310-859d-f6bbb57e9c96
writers.
* Removed the optimization for piping data between two threads of the
same team. This greatly simplifies the code. It seems to me the case
is very uncommon; it could be added back later, though.
* Basically rewrote reading from and writing to the pipe:
- A blockable writer can now write more than what is currently
available in the ring buffer.
- Writing respects the PIPE_BUF non-interleaving limit, though our
headers don't seem to define PIPE_BUF anywhere.
- Unblock writers, when the last reader is gone and send those that
haven't written anything yet a SIGPIPE. Fixes bug #1476.
* Correctly implemented select() support. We were only notifying
writers. We manage two separate select sync pools per pipe now: one
for the reader end and one for the writer end.
* Reading/writing from the root dir does no longer end in KDL.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22378 a95241bf-73f2-0310-859d-f6bbb57e9c96
components - now, we divide the initialization of that service into two parts
which allows this (before, most handlers were gone after boot).
* Added debugger command that dumps the low memory handlers.
* The slab allocator now registers its low memory handler with a higher
priority, so that it'll run before the potentially heavier ones.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22374 a95241bf-73f2-0310-859d-f6bbb57e9c96
inserted into the list according to their priority; higher priority
handlers are now called first.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22359 a95241bf-73f2-0310-859d-f6bbb57e9c96