#
44073aa6 |
|
27-Feb-2024 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel/vm: Do not try to reserve more memory than the system has. All that happens is we wait unnecessarily, and cause the low_resource monitor to run a lot, so we should skip doing that here altogether. Encountered while running Falkon (Chromium): some part of Chromium repeatedly tries to allocate 10+GB, more than my system has, which caused the system to "stutter" due to low-resource-monitor runs locking various kernel subsystems. This prevents that problem.
|
#
a2270c70 |
|
16-Jan-2024 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel/vm: Avoid committing memory in vm_map_file for PRIVATE_MAP without PROT_WRITE. Instead, rely on commitment being done later, when the protections are changed. set_area_protection() already did just that, but set_memory_protection did not, so it is implemented here. Fixes #18733. Change-Id: Ia58aee93faf1296fce69d723b12d0fa0a8440706 Reviewed-on: https://review.haiku-os.org/c/haiku/+/7339 Reviewed-by: waddlesplash <waddlesplash@gmail.com>
|
#
094f6384 |
|
23-Dec-2023 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel/vm: Perform area ownership check before protection check. This way we do not "leak" area protection status (not really a significant concern at the moment, but might as well while I was looking at this.)
|
#
04f148c7 |
|
23-Dec-2023 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel/vm: Allow B_CLONEABLE_AREA flag to be added through set_area_protection.
|
#
70e8eacb |
|
19-Jun-2023 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel: Implement realloc_etc and make use of it.
|
#
79572316 |
|
01-Jun-2023 |
Trung Nguyen <trungnt282910@gmail.com> |
kernel/vm: check if page is in area Checks if a `vm_page` is part of a `VMArea` before doing work with it, as pages in a `VMCache` that an area is a part of might not belong to that area. This fixes a bug for copy-on-write areas when an application is `fork`ing. Change-Id: Ic5683c67865b41bf3708bb7ea4104502ddf31a19 Reviewed-on: https://review.haiku-os.org/c/haiku/+/6496 Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org> Reviewed-by: Jérôme Duval <jerome.duval@gmail.com> Reviewed-by: Axel Dörfler <axeld@pinc-software.de>
|
#
bdcc293f |
|
30-May-2023 |
Trung Nguyen <trungnt282910@gmail.com> |
kernel/vm: handle page protections in cut_area - Resize the `page_protections` array in `cut_area` and also shift the bits if necessary. - Set the correct protection array as well as the real page protections for the second area produced by `cut_area`. Change-Id: I62293480487e869420ebe5a3bc729cec2a14c687 Reviewed-on: https://review.haiku-os.org/c/haiku/+/6395 Reviewed-by: Jérôme Duval <jerome.duval@gmail.com> Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
|
#
7be37179 |
|
20-May-2023 |
Trung Nguyen <trungnt282910@gmail.com> |
kernel/vm: unlock cache before unmapping addresses Unlock the current cache in `map_backing_store` before `unmap_address_range` is called, since `unmap_address_range` may call `delete_area` which would then also attempt to lock the same cache if that cache has already been mapped to an area in the conflicting address range. Fixes #18422. Change-Id: I6fc5301c43d11bb6df489a2e6d6bdcd6cd80d2b7 Reviewed-on: https://review.haiku-os.org/c/haiku/+/6392 Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
|
#
cb1df90e |
|
31-May-2023 |
Augustin Cavalier <waddlesplash@gmail.com> |
Revert "kernel/vm: handle page protections in cut_area" This reverts commit de07bc3fa58600e923d75cb732c60dacf160c098. That's what I get for fixing bugs on test branches.
|
#
de07bc3f |
|
30-May-2023 |
Trung Nguyen <trungnt282910@gmail.com> |
kernel/vm: handle page protections in cut_area - Resize the `page_protections` array in `cut_area` and also shift the bits if necessary. - Set the correct protection array as well as the real page protections for the second area produced by `cut_area`. Change-Id: I62293480487e828970ebe5a3bc729cec2a14c687
|
#
74d2e61e |
|
19-May-2023 |
Trung Nguyen <trungnt282910@gmail.com> |
kernel/vm: Make cut_area respect overcommitting flag `cut_area` now checks the protection of the target area for the `B_OVERCOMMITTING_AREA` flag and sets it on any cache it creates. This allows operations that split large overcommitting areas to succeed. Change-Id: I8dee27d22df29741cc61af2575c9e6626da25949 Reviewed-on: https://review.haiku-os.org/c/haiku/+/6391 Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org> Reviewed-by: waddlesplash <waddlesplash@gmail.com>
|
#
bbd6beb7 |
|
12-May-2023 |
Trung Nguyen <trungnt282910@gmail.com> |
kernel/vm: Allow more maximum protection for mmap'ed areas Always allow a memory region mapped by `map_file` to change its protection to any user protection flags other than `B_WRITE_AREA`. This flag should only be settable when the file is opened with write access. Change-Id: Icc00c08fc033b3bd6b6ceb2833bf566c72914007 Reviewed-on: https://review.haiku-os.org/c/haiku/+/6389 Reviewed-by: Jérôme Duval <jerome.duval@gmail.com> Reviewed-by: John Scipione <jscipione@gmail.com> Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org> Reviewed-by: waddlesplash <waddlesplash@gmail.com>
|
#
412bcb11 |
|
11-May-2023 |
Trung Nguyen <trungnt282910@gmail.com> |
kernel/vm: Fix area_for with PROT_NONE address Do not assume "no user protection" means "kernel area". This allows calls to `area_for` for addresses with protection 0 to work properly. Change-Id: I54cbcc154d10b63359a2e1233f0c0f45d0d8e21e Reviewed-on: https://review.haiku-os.org/c/haiku/+/6388 Reviewed-by: waddlesplash <waddlesplash@gmail.com>
|
#
c650846d |
|
14-Mar-2023 |
Augustin Cavalier <waddlesplash@gmail.com> |
vm: Replace the VMAreas OpenHashTable with an AVLTree. Since we used a hash table with a fixed size (1024), collisions were obviously inevitable, meaning that while insertions would always be fast, lookups and deletions would take linear time to search the linked-list for the area in question. For recently-created areas, this would be fast; for less-recently-created areas, it would get slower and slower and slower. A particularly pathological case was the "mmap/24-1" test from the Open POSIX Testsuite, which creates millions of areas until it hits ENOMEM; it then simply exits, at which point it would run for minutes and minutes in the kernel team deletion routines; how long I don't know, as I rebooted before it finished. This change fixes that problem, among others, at the cost of increased area creation time, by using an AVL tree instead of a hash. For comparison, mmap'ing 2 million areas with the "24-1" test before this change took around 0m2.706s of real time, while afterwards it takes about 0m3.118s, or around a 15% increase (1.152x). On the other hand, the total test runtime for 2 million areas went from around 2m11.050s to 0m4.035s, or around a 97% decrease (0.031x); in other words, with this new code, it is *32 times faster.* Area insertion will no longer be O(1), however, so the time increase may go up with the number of areas present on the system; but if it's only around 3 seconds to create 2 million areas, or about 1.56 us per area, vs. 1.35 us before, I don't think that's worth worrying about. My nonscientific "compile HaikuDepot with 2 cores in VM" benchmark seems to be within the realm of "noise", anyway, with most results both before and after this change coming in around 47s real time. Change-Id: I230e17de4f80304d082152af83db8bd5abe7b831
|
#
bc35a6e4 |
|
28-Feb-2023 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel/vm: Prohibit offset from being < 0 in mmap. POSIX seems to be silent about whether this is permitted, but at least FreeBSD explicitly does not allow it. Fixes #16936. Change-Id: If6b23410ae88245e706df77d276234f4775654f9
|
#
8045bb17 |
|
29-Aug-2022 |
Jérôme Duval <jerome.duval@gmail.com> |
kernel/vm: also honor page protections on copy-on-write this fixes #17895 Change-Id: Ide6cb044cf96213b4bae7eb62235f988b73c0fb1 Reviewed-on: https://review.haiku-os.org/c/haiku/+/5601 Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org> Reviewed-by: waddlesplash <waddlesplash@gmail.com>
|
#
fc473ac2 |
|
07-Aug-2022 |
Jérôme Duval <jerome.duval@gmail.com> |
kernel/vm: _user_set_memory_protection() should only check the user protection as it extends the provided protection with the kernel protection. fix hrev55016 Change-Id: I9fa9349c15b4ef896a9dadd1b1b7a4165cc03b39 Reviewed-on: https://review.haiku-os.org/c/haiku/+/5531 Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org> Reviewed-by: waddlesplash <waddlesplash@gmail.com>
|
#
77694f92 |
|
03-Jun-2022 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel: Move validate_user_memory_range to kernel.h and rename it. It has more general use than just in the VM code; basically anything which receives buffers from userland should be invoking this if it does anything besides user_memcpy (which alreay does it.)
|
#
956f4507 |
|
22-May-2022 |
Trung Nguyen <trungnt282910@gmail.com> |
kernel/vm: Remove default kernel read/write flags `fix_protection` will not apply `B_KERNEL_READ_AREA` and `B_KERNEL_WRITE_AREA` by default. Kernel drivers that directly call `create_area` or `create_area_etc` and do not pass any protection flags have been updated to apply `B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA` instead. Bug: #17751 Change-Id: I43e7ee6b5396e0309cdcff750e28262942c6d01c Reviewed-on: https://review.haiku-os.org/c/haiku/+/5330 Reviewed-by: waddlesplash <waddlesplash@gmail.com>
|
#
c25f6f53 |
|
29-Mar-2022 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel/vm: Completely replace mlock() implementation. The old implementation used the real lock_memory(). This is problematic and does not work for a large number of reasons: 1) Various parts of the kernel assume memory is locked only very temporarily, and will often wait on locked memory to become unlocked. The transient nature of locks is further demonstrated by the fact that lock_memory acquires references to structures, like the address space, which are only released by unlock_memory 2) The VM has a hard assumption that all lock_memory calls will be exactly balanced, and maintains internal "WiredRange" structures on areas, etc. corresponding to the original lock_memory calls. Maintaining separate data structures as this code did is a recipe for even more problems when the structures are manipulated separately, leading to confusing or incorrect behavior on unlocks. 3) Areas with locked memory cannot be deleted, nor can the pages which are locked be removed from the areas/caches. This of course is most notable when destroying teams which locked memory, but the problem also occurs when just using delete_area, resize_area, mmap/munmap, etc. Because of (2) and especially (3), adding support for mlock()-like semantics to the existing memory locking system is just not a good option. A further reason is that our lock_memory is much stricter than mlock(), which only demands the pages in question must remain resident in RAM and cannot be swapped out (or, it seems, otherwise written back to disk.) Thus, this commit completely removes the old implementation (which was seriously broken and did not actually automatically unlock memory on team exit or area destruction at all, etc.) and instead adds a new feature to VMAnonymousCache to block certain pages from being written out. The syscall then just invokes this to do its work. Fixes #17674. Related to #13651. Change-Id: Id2745c51796bcf9a74ba5325fe686a95623cd521 Reviewed-on: https://review.haiku-os.org/c/haiku/+/5147 Reviewed-by: waddlesplash <waddlesplash@gmail.com>
|
#
69b5103b |
|
23-Mar-2022 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel/vm: Add user address checks to mlock routines. Also adjust general checks at the beginning. Patterned after _user_set_memory_protection.
|
#
760270af |
|
23-Mar-2022 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel/vm: Use ObjectDelter and slight cleanup to the mlock() routines.
|
#
77034a15 |
|
11-Mar-2022 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel/vm: Let _user_set_memory_protection change area->protection if possible. If mprotect() is being run over an entire area, and the area does not have per-page protections, then we can just invoke set_area_protection instead of allocating a protections array. This is a major efficiency increase, as every page fault would otherwise have to use the protections array if it was allocated. Testing with QtWebEngine shows this new path being hit relatively often (multiple hundred times in loading a single webpage). Change-Id: I60258d56f681060861602922f3fbdbce2fd380d6 Reviewed-on: https://review.haiku-os.org/c/haiku/+/5097 Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org> Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
|
#
a09dd6bb |
|
11-Mar-2022 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel/vm: Cleanups and minor fixes to get_area_page_protection. * We should not assume all non-kernel areas have KERNEL_READ_AREA permission, but follow the other permission flags directly. This way the kernel will be blocked from accessing guard pages, too. * Compute kernelProtection only once, and either return it directly or return it OR'd with the user protections. Change-Id: Id6daa1cd15eb3102e23f95c08672ad97344e0722 Reviewed-on: https://review.haiku-os.org/c/haiku/+/5096 Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com> Reviewed-by: waddlesplash <waddlesplash@gmail.com> Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
|
#
4c51faeb |
|
11-Mar-2022 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel/vm: Use get_area_page_protection in all cases of _user_get_memory_properties. It already checks for area->page_protections == NULL and returns area->protection appropriately if so, we do not need to test specifically for that here. No functional change intended.
|
#
5c69be73 |
|
11-Mar-2022 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel/vm: De-wrap line for clarity. No functional change. Now it looks the same as the surrounding checks.
|
#
63664eaa |
|
11-Mar-2022 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel/vm: Do not assume "no user protection" means "kernel area". It's entirely possible that we have a user area with a page that has protections of 0 (e.g. a guard page). In that case we should print the standard read/write fault message instead of "kernel" fault messages. This should not be a major behavioral change, only the syslog and tracing entries should be affected; such memory accesses should be caught by the read/write permissions checks immediately following.
|
#
3a81e944 |
|
10-Mar-2022 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel/vm: Check the area's cache_type, not the cache's, in cut_area. It seems this is the type of the innermost source cache, not the topmost cache (which well may be "RAM" if this is an anonymous cache on top of a Vnode cache.) Originally VMArea::cache_type was introduced 15 years ago (commit 0c12332715ae3cd6dedad4270d52ccf29d2cdcbf, 2007) merely to mirror the underlying cache's type. Somewhere along the way, it acquired different values. As the VM has changed a lot since then, perhaps its overall purpose should be re-evaluated? Fixes #17556.
|
#
d38d90de |
|
09-Mar-2022 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel/vm: Notify the low_resource manager on low_resource address space. We cannot wait here, but now that the low_resource manager actually does something with the information it is provided, we can invoke it.
|
#
8ca0f03d |
|
08-Nov-2021 |
X512 <danger_mail@list.ru> |
riscv64/smp: Implement multi-processor support * Working under qemu smp 1,2+ * Working on SiFive Unmatched * x86_64 efi not broken by smp_boot_other_cpus change Change-Id: I32ebc17913e46ed082be9ade8f56448bbf12f16e Reviewed-on: https://review.haiku-os.org/c/haiku/+/4705 Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org> Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>
|
#
60fee365 |
|
09-Sep-2021 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel/vm: Allow locking kernel space if allocating page_protections for userspace. Some applications may request per-page protections for an especially large area (e.g. multiple GB), which leads to allocating a rather large page protections area (e.g. 512KB), which we cannot allocate without locking the kernel space to get new slabs. We only need to avoid locking the kernel space if the area in question is in the kernel space, as in that case, kernel space will already be read-locked by the current thread. Fixes #16898. Change-Id: If52413a594da66edfc2821811d959085a2c3c78e Reviewed-on: https://review.haiku-os.org/c/haiku/+/4436 Reviewed-by: waddlesplash <waddlesplash@gmail.com>
|
#
057fe191 |
|
01-Sep-2021 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel: Break thread-related AutoLockers into a separate header. Including thread.h brings a massive array of things with it from the kernel thread arch headers, team and thread definitions, hash tables, linked lists, Referenceable, etc. that the vast majority of AutoLock.h consumers neither want nor need. So, put these in a separate header, and adjust all consumers of these lockers to include the new file. This change exposes the fact that a lot of files were inadvertently making use of headers included indirectly through thread.h. Those will be fixed in the next commit.
|
#
71f3ec46 |
|
16-Jul-2021 |
Adrien Destugues <pulkomandy@pulkomandy.tk> |
vm: fix off by one errors Various functions would return an error if trying to use them on the last page of userspace, as they tested the permissions for the first byte out of the requested range. Also, the code was duplicated in several places - Rename validate_user_range to validate_memory_range. The "user" in the name was to mean that the range is provided by the user calling the syscall, but it is a bit confusing, as the function accepts any range that is either in kernel or in user memory. - Add a new function validate_user_memory_range that only accepts userspace memory, and use this one where appropriate. Change-Id: I135f8d584340f0ba4ae7e4b8cb6f8600fbf3ef2d Reviewed-on: https://review.haiku-os.org/c/haiku/+/4212 Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org> Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
|
#
45872f7f |
|
17-Mar-2021 |
Jérôme Duval <jerome.duval@gmail.com> |
kernel/vm: restrict permission changes on shared file-mapped areas a protection_max attribute is added in VMArea. a read-only opened file already can't be mapped shared read-write at the moment, but can later be changed to read-write with mprotect() or set_area_protection(). When creating the VMArea, the actual maximum protection is stored in the area, so that it can be checked when needed. this fixes a VM TODO. Change-Id: I33b144c192034eeb059f1dede5dbef5af947280d Reviewed-on: https://review.haiku-os.org/c/haiku/+/3804 Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
|
#
cdccd323 |
|
09-Dec-2020 |
X512 <danger_mail@list.ru> |
use common AutoDeleter types Change-Id: I115e14b76f3ff049c5f7d9471efd3619a0038fcf Reviewed-on: https://review.haiku-os.org/c/haiku/+/3483 Reviewed-by: Adrien Destugues <pulkomandy@gmail.com> Reviewed-by: Axel Dörfler <axeld@pinc-software.de>
|
#
36aafa56 |
|
04-Dec-2020 |
X512 <danger_mail@list.ru> |
fix build after CObjectDeleter interface change Change-Id: I76e217abcd13c22c4d68170e07333cdde4d7a891 Reviewed-on: https://review.haiku-os.org/c/haiku/+/3461 Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
|
#
6f243905 |
|
07-Dec-2020 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel: Allow usage of magic team constants in create_area_etc. All other functions that support these handle them specifically, so vm_create_anonymous_area must do so as well. Change-Id: I7233770926b718936baeff10ef73668ac15c5201 Reviewed-on: https://review.haiku-os.org/c/haiku/+/3477 Reviewed-by: waddlesplash <waddlesplash@gmail.com>
|
#
a959262c |
|
14-Dec-2019 |
Adrien Destugues <pulkomandy@pulkomandy.tk> |
implement mlock(), munlock() Change-Id: I2f04b8986d2ed32bb4d30d238d668e21a1505778 Reviewed-on: https://review.haiku-os.org/c/haiku/+/1991 Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
|
#
481b1137 |
|
22-Aug-2020 |
Michael Lotz <mmlr@mlotz.ch> |
kernel/vm: Dump page protections array address in area command. Had to abbreviate the trailing 's' to make it fit the alignment... Change-Id: Iae88c4cd92c3f54bf3ea3433ea3dafe5df90a8e8 Reviewed-on: https://review.haiku-os.org/c/haiku/+/3168 Reviewed-by: waddlesplash <waddlesplash@gmail.com>
|
#
5984257d |
|
22-Aug-2020 |
Michael Lotz <mmlr@mlotz.ch> |
kernel/vm: Avoid page protection overflows for very large areas. For areas >= 32TiB the page protection array size would overflow. Change-Id: Ic95d9a6e35bbedb165c2bbd382f6c47edde07ac2 Reviewed-on: https://review.haiku-os.org/c/haiku/+/3167 Reviewed-by: waddlesplash <waddlesplash@gmail.com>
|
#
75a10a74 |
|
22-Aug-2020 |
Michael Lotz <mmlr@mlotz.ch> |
kernel/vm: Make vm_copy_area take page protections into account. When copying an area with vm_copy_area only the new protection would be applied and any possibly existing page protections on the source area were ignored. For areas with stricter area protection than page protection, this lead to faults when accessing the copy. In the opposite case it lead to too relaxed protection. The currently only user of vm_copy_area is fork_team which goes through all areas of the parent and copies them to the new team. Hence page protections were ignored on all forked teams. Remove the protection argument and instead always carry over the source area protection and duplicate the page protections when present. Also make sure to take the page protections into account for deciding whether or not the copy is writable and therefore needs to have copy on write semantics. Change-Id: I52f295f2aaa66e31b4900b754343b3be9a19ba30 Reviewed-on: https://review.haiku-os.org/c/haiku/+/3166 Reviewed-by: waddlesplash <waddlesplash@gmail.com>
|
#
b3bd6696 |
|
29-May-2020 |
Michael Lotz <mmlr@mlotz.ch> |
libroot/kernel: Implement MADV_FREE madvise() extension. It allows an application to signal that it no longer needs the data in the given address range and the underlying pages can be discarded and reused elsewhere. This is finer grained than working with full areas or mappings at a time and enables unmapping sections of partially used mappings without giving up its address space. Compared with punching holes into a mapping by "mapping over" with PROT_NONE and MAP_NORESERVE, this has the obvious advantage of not producing a lot of unused extra areas and saves the corresponding resources. It is also a lot "lighter" of an operation than cutting existing areas. This introduces madvise() alongside the existing posix_madvise() to allow for OS specific extensions. The constants for both functions are aliased, the POSIX_MADV_* being a subset of the MADV_* ones without the non-POSIX extensions. Internally posix_madvise() simply calls madvise(). MADV_FREE is commonly supported in other OSes with various subtle semantic differences as to when pages are actually freed/cleared and how or whether the pages are counted against the memory use of a process. In the variant implemented here, pages are always immediately discarded and memory counting is not altered. This behaviour should be considered an implementation detail and may be altered later. The actual unmap and discard could for example be delayed until pages are needed elsewhere to reduce overhead in case of repeated discarding and remapping. Note that MADV_FREE doesn't really align with the rest of the madvise() API as it works like a command (i.e. discard these pages) and does not add an attribute to the pages in the given range (i.e. mark these pages for quick access from now on). As such, an MADV_FREE does not need to be undone by setting a different advice later on, unlike how the other flags work. This discrepancy may be the reason why it is not part of POSIX. Change-Id: Icc093379125a43e465dc4409d8f5ae0f64e107e0 Reviewed-on: https://review.haiku-os.org/c/haiku/+/2844 Reviewed-by: waddlesplash <waddlesplash@gmail.com>
|
#
8e74e307 |
|
29-May-2020 |
Michael Lotz <mmlr@mlotz.ch> |
kernel/vm: Add discard_address_range that discards pages. Pages in the given range are unmapped and freed without getting written back anywhere. It can be used whenever a caller does not care about the data in the given range anymore and wants to reduce page pressure. Change-Id: I8bcce68fab278efef710d3714677e1d463504a56 Reviewed-on: https://review.haiku-os.org/c/haiku/+/2843 Reviewed-by: waddlesplash <waddlesplash@gmail.com>
|
#
31cee26c |
|
13-Jun-2020 |
Michael Lotz <mmlr@mlotz.ch> |
kernel: Whitespace cleanup only.
|
#
a6926d42 |
|
29-May-2020 |
Michael Lotz <mmlr@mlotz.ch> |
kernel/vm: Introduce and use VMAddressSpace::AreaRangeIterator. It iterates over all areas intersecting a given address range and removes the need for manually skipping uninteresting initial areas. It uses VMAddressSpace::FindClosestArea() to efficiently find the starting area. This speeds up the two iterations in unmap_address_range and one in wait_if_address_range_is_wired and resolves a TODO in the latter hinting at such a solution. Change-Id: Iba1d39942db4e4b27e17706be194496f9d4279ed Reviewed-on: https://review.haiku-os.org/c/haiku/+/2841 Reviewed-by: waddlesplash <waddlesplash@gmail.com>
|
#
a626bdab |
|
29-May-2020 |
Michael Lotz <mmlr@mlotz.ch> |
kernel/vm: Remove linear search from _get_next_area_info. This introduces VMAddressSpace::FindClosestArea() that can be used to find the closest area to a given address in either direction. This is now trivial and efficient since both kernel and user address spaces use a binary search tree. Using FindClosestArea() getting multiple area infos is sped up dramatically as it removes the need for a linear search from the first area to the one given in the cookie on each successive invocation. Change-Id: I227da87d915f6f3d3ef88bfeb6be5d4c97c3baaa Reviewed-on: https://review.haiku-os.org/c/haiku/+/2840 Reviewed-by: waddlesplash <waddlesplash@gmail.com>
|
#
928d780b |
|
24-May-2020 |
Michael Lotz <mmlr@mlotz.ch> |
kernel/vm: Factor out intersect_area and use it for cut_area. It combines the intersection check and setting address, size and offset so that they fall within the area. Change-Id: Iffd3feca75d4e6389d23b9d70294253b4c3d1f4c Reviewed-on: https://review.haiku-os.org/c/haiku/+/2837 Reviewed-by: waddlesplash <waddlesplash@gmail.com>
|
#
4986a9a3 |
|
24-May-2020 |
Michael Lotz <mmlr@mlotz.ch> |
Revert "kernel: Remove the B_KERNEL_AREA protection flag." This reverts parts of hrev52546 that removed the B_KERNEL_AREA protection flag and replaced it with an address space comparison. Checking for areas in the kernel address space inside a user address space does not work, as areas can only ever belong to one address space. This rendered these checks ineffective and allowed to unmap, delete or resize kernel managed areas from their respective userland teams. That protection was meant to be applied to the team user data area which was introduced to reduce the kernel to userland overhead by directly sharing some data between the two. It was intended to be set up in such a manner that this is safe on the kernel side and the B_KERNEL_AREA flag was introduced specifically for this purpose. Incidentally the actual application of the B_KERNEL_AREA flag on the team user data area was apparently forgotten in the original commit. The absence of that protection allowed applications to induce KDLs by modifying the user area and generating a signal for example. This change restores the B_KERNEL_AREA flag and also applies it to the team user data area. Change-Id: I993bb1cf7c6ae10085100db7df7cc23fe66f4edd Reviewed-on: https://review.haiku-os.org/c/haiku/+/2836 Reviewed-by: waddlesplash <waddlesplash@gmail.com>
|
#
4e2b49bc |
|
04-May-2020 |
Michael Lotz <mmlr@mlotz.ch> |
kernel/vm: Implement swap adoption for cut_area middle case. Rename MovePageRange to Adopt and group it with Resize/Rebase as it covers the third, middle cut case. Implement VMAnonymousCache::Adopt() to actually adopt swap pages. This has to recreate swap blocks instead of taking them over from the source cache as the cut offset or base offset between the caches may not be swap block aligned. This means that adoption may fail due to memory shortage in allocating the swap blocks. For the middle cut case it is therefore now possible to have the adopt fail in which case the previous cache restore logic is applied. Since the readoption of the pages from the second cache can fail for the same reason, there is a slight chance that we can't restore and lose pages. For now, just panic in such a case and add a TODO to free memory and retry. Change-Id: I9a661f00c8f03bbbea2fe6dee90371c68d7951e6 Reviewed-on: https://review.haiku-os.org/c/haiku/+/2588 Reviewed-by: waddlesplash <waddlesplash@gmail.com>
|
#
6dc4e9d7 |
|
03-May-2020 |
Michael Lotz <mmlr@mlotz.ch> |
kernel/vm: Factor out condition for cache resizing in cut_area. Change-Id: I2c49b550f72b9778934abbf90a04579caa7b43f2 Reviewed-on: https://review.haiku-os.org/c/haiku/+/2587 Reviewed-by: waddlesplash <waddlesplash@gmail.com>
|
#
65598ca6 |
|
02-May-2020 |
Michael Lotz <mmlr@mlotz.ch> |
kernel/vm: Inherit the temporariness of source cache on split. Otherwise pages from it would later be tried to be written back with nowhere to go in case of temporary caches. Change-Id: I81e7335408c419a9b2c7bbb31290d551f5508d56 Reviewed-on: https://review.haiku-os.org/c/haiku/+/2586 Reviewed-by: waddlesplash <waddlesplash@gmail.com>
|
#
d2dd287e |
|
02-May-2020 |
Michael Lotz <mmlr@mlotz.ch> |
kernel/vm: Use already determined priority in middle cut_area. Change-Id: I4dd677a0f1378f4fa483502124bea70ad7ba40c0 Reviewed-on: https://review.haiku-os.org/c/haiku/+/2585 Reviewed-by: waddlesplash <waddlesplash@gmail.com>
|
#
c6657ffe |
|
15-Apr-2012 |
Hamish Morrison <hamish@lavabit.com> |
Resize caches in all cases when cutting areas * Adds VMCache::MovePageRange() and VMCache::Rebase() to facilitate this. Applied on top of hrev45098 and rebased with the hrev45564 page_num_t to off_t change included. Change-Id: Ie61bf43696783e3376fb4144ddced3781aa092ba Reviewed-on: https://review.haiku-os.org/c/haiku/+/2581 Reviewed-by: waddlesplash <waddlesplash@gmail.com>
|
#
891edac9 |
|
16-Mar-2020 |
waddlesplash <waddlesplash@gmail.com> |
kernel/vm: Revise overflow checking in user_strlcpy. Change-Id: I6a066e7b2c51ff94d80381fcc940565f777209e7 Reviewed-on: https://review.haiku-os.org/c/haiku/+/2376 Reviewed-by: waddlesplash <waddlesplash@gmail.com>
|
#
1e3d4cf7 |
|
21-Mar-2020 |
X512 <danger_mail@list.ru> |
Kernel: remove dead code area->name is a fixed array inside struct, not pointer, so it should be never be NULL. Pointed by clang. Change-Id: Ic8930450cb8461eef158bc854f214eb47d92ce22 Reviewed-on: https://review.haiku-os.org/c/haiku/+/2391 Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
|
#
65920cac |
|
15-Mar-2020 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel/vm: Validate user addresses do not cross the kernel/user boundary. This protects against malicious programs trying to steal/overwrite kernel memory by overflowing user buffers. Note that this constitutes a behavioral change to user_strlcpy: previously, address overflows on the "source" side would either copy less data, or copy some data and fail anyway. Now, address overflows on either side will always fail before any data is copied at all. Change-Id: I01d8b22672ab3758a9dd87b521af6fedd0487417 Reviewed-on: https://review.haiku-os.org/c/haiku/+/2361 Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
|
#
72b37d9f |
|
14-Aug-2019 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel: Turn the clone-area-attempt panic into a dprintf.
|
#
da73ed96 |
|
10-Aug-2019 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel/vm: Enable area-cloning protection for userland areas, too. We allow teams to clone areas within themselves, but I'm not sure exactly what use that has. The kernel can of course clone anything it wants to, still. Hopefully this will prove substantially less disruptive than the reverse change last year, as the preceding commits are likely the only major consumers of this API, rather than a variety of drivers that need to be individually tested.
|
#
329866d1 |
|
10-Aug-2019 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel/vm: Set CLONEABLE_AREA before cloning areas for transfer.
|
#
8a0c9d52 |
|
10-Aug-2019 |
Augustin Cavalier <waddlesplash@gmail.com> |
OS: Rename B_USER_CLONEABLE_AREA to B_CLONEABLE_AREA. It now lives in OS.h. The idea is that this will now be accessible to userland applications, so userland memory is protected from access by other processes, just as kernel memory is. No functional change (the constants are still the same, though I've changed some to use shifts to make clear which bits are allocated are which are unused.)
|
#
351575e0 |
|
15-Apr-2019 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel/vm: Do not invoke the low_resource monitor in map_backing_store. As the comment implies, we don't want to wait here, but low_resource() waits forever when timeout=0. It doesn't seem to do anything with the "size" argument at all, so not calling it is just as effective, and so replace the comment there altogether. The case where this was most often hit, causing a full system deadlock in anything relating to memory management, was when the passed "size" was 0. So now we check for this case explicity at the beginning and panic() on KDEBUG kernels for it.
|
#
5ffbe7d7 |
|
30-Mar-2019 |
Augustin Cavalier <waddlesplash@gmail.com> |
Change all references to "__INTEL__" to "__i386__". They are functionally identical, but the former is a BeOS/Haiku-specfic macro that we include in the compiler specs, and the latter is defined by GCC.
|
#
6f7d94a1 |
|
23-Feb-2019 |
PulkoMandy <pulkomandy@pulkomandy.tk> |
vm: fix stack erase when printing 64bit value Getting 64 bytes of data in a 32 bit variable is a bad idea Change-Id: I760e1cfb996a9be053dbc50d6610b3e865cde65d Reviewed-on: https://review.haiku-os.org/c/1096 Reviewed-by: waddlesplash <waddlesplash@gmail.com>
|
#
67f185ec |
|
12-Dec-2018 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel: Don't retry or wait for the low_resource handler. As axeld pointed out on the mailing list, map_backing_store is called with the address space write-locked, and so the resources won't be released until after we return. Due to the state we are in at this point, unlocking the address space before making this call would be likely be very dangerous, and so simply issuing the notification and then returning an error is all we can safely do here.
|
#
f1e86789 |
|
11-Dec-2018 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel: Notify low resource handler & retry when low on kernel address space. Solves a decade-old TODO. This might help with strange behavior in low-memory conditions.
|
#
8a1709b3 |
|
11-Dec-2018 |
Augustin Cavalier <waddlesplash@gmail.com> |
vm: Allow W|X before kernel startup ends. The altcodepatch mechanism needs to overwrite parts of the kernel image. This can't be done by setting it to RW-only and not RWX, as we are already running within the kernel when this occurs, and so instruction fetches can and will occur between the points of +W and -W. As gKernelStartup is turned off before the scheduler is started, this is not much of a lifted restriction, as no modules are loaded, no secondary threads started, etc. Fixes #14751.
|
#
cb097732 |
|
09-Dec-2018 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel: Enforce W^X protection for kernel areas. We already adhere to this in the kernel itself as well as all in-tree drivers, so we might as well actually enforce it now.
|
#
04f1a9be |
|
17-Nov-2018 |
Augustin Cavalier <waddlesplash@gmail.com> |
vm: B_EXECUTE_AREA should not imply B_KERNEL_EXECUTE_AREA. Trying to execute user-mapped areas in kernel space should trigger a fault with SMEP enabled anyway (and we have not seen any thus far.)
|
#
d12a2ff5 |
|
17-Nov-2018 |
Augustin Cavalier <waddlesplash@gmail.com> |
vm: Block userland from modifying any area owned by the kernel. Previously this protection was possible via the opt-in B_KERNEL_AREA flag, however, almost nothing used that, so in practice these protections were rarely enforced. Userland can still access kernel areas according to the protection flags (and due to SMAP, these have been refined and reduced as appopriate) and clone them (according to B_USER_CLONEABLE_AREA flag, which has been required since August of this year), but they can no longer resize them (something no in-tree application does on any shared area), set protections (otherwise they could add B_USER_CLONEABLE_AREA...), unmap them, or essentially do anything else besides get their information (and even that we should restrict to uid 0, in the future.) From my testing, this does not introduce any issues, and no applications nor drivers should have been relying on the previous behavior (unlike SMAP or the clone-area changes, which did affect applications.)
|
#
494a6e4e |
|
10-Nov-2018 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel/vm: Remove hacky stack dumper from vm_page_fault. As the TODO said, we now have good userland debugging facilities, so this isn't needed (and has been if 0'd out for almost a decade now.) The dprintf on page faults may still be useful under rare circumstances, but we already have a "TRACE_FAULTS" configuration for this file, so guard it behind that. Fixes part of #14360.
|
#
753e0066 |
|
18-Sep-2018 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel: Include the area name and ID in the "attempting to clone" panic message. Change-Id: Iecc842047929531f8feb7304fbcd1a8f2b28ab2f Reviewed-on: https://review.haiku-os.org/584 Reviewed-by: waddlesplash <waddlesplash@gmail.com>
|
#
023a547d |
|
06-Aug-2018 |
Augustin Cavalier <waddlesplash@gmail.com> |
vm: Enable B_USER_CLONEABLE_AREA protection. Spotted while reading through the VM code while thinking about how to implement vfork(). When axeld disabled this in 2005 (!), Haiku's kernel was still young, BeOS drivers were still "a thing," and there was no distinction in this function from being called by the kernel / not by the kernel. Now, it's 2018, we manage all drivers ourselves, have SMAP enabled by default when available, and as axeld recently noted on the mailing lists, "there's not much reason we still use GCC2 for the kernel anyway." So we probably don't care about any BeOS drivers that may be broken by this (are there any still around?) Besides the usual fixes to get this 13-year-old chunk to work again, there are two functional changes: 1) Allow the kernel to clone whatever it likes into the user's address space. It seems that this is often done legitimately (e.g. team creation), and so attempting to distinguish those cases seems more work than it may be worth right now. The disadvantage is that drivers without proper checks may be "tricked" into cloning areas they shouldn't; but I'm guessing if that's the case, then something else is probably broken and the driver should be fixed. It seems the reverse case (cloning a userland area into the kernel) is much more common (in fact, it looks like all 4 of the 4 places where clone_area is used in kernel-space outside the kernel itself are doing this.) 2) At KDEBUG_LEVEL 2 and higher, throw a panic when attempting to clone an area that does not have the protection flag set. This should make finding any bugs exposed by this change much easier than "hardware doesn't work" / "black screen on boot" / etc., as well as any potential future bugs introduced in the process of driver development.
|
#
4f7b9506 |
|
14-Jun-2018 |
Augustin Cavalier <waddlesplash@gmail.com> |
Revert the rest of the COMPAT_MODE changes (back to hrev52003.) This reverts commit 458e758f3792ef11ca26d6ff7e24600c88326e83. This reverts commit ce5eb94a82b1b377ef5909e65411e031f54ceb15. This reverts commit aac8d4c317ca11a9a6e194e2c668e8183ec23dd6. This reverts commit c70cba914aa79c01bbc2da38085936f589899c8c. This reverts commit 2ffbe7aaca8668c5a68ac7488459bace7a0700f2 This reverts commit c6e120e2d2f909d95f95839fa99fccf811fdb3c5.
|
#
458e758f |
|
19-May-2018 |
Jérôme Duval <jerome.duval@gmail.com> |
kernel/x86_64: compatibility syscalls for vm.cpp. * define compat_area_info to be used when applicable in compatibility mode. * handle 32-bit types in _user_reserve_address_range(), _user_get_area_info(), _user_get_next_area_info(), _user_transfer_area(), _user_clone_area(), _user_create_area(), _user_map_file(), other syscalls are compatible as is. * _get_next_area_info() doesn't work well with a 32-bit address cookie (address could be in 64-bit range). Instead use _compat_get_next_area_info() which uses the area id as cookie, though the areas are not ordered by address any more. Change-Id: Ic7519ca8824aa2d534b0f03ea75a1bf6ae321535
|
#
321372e3 |
|
03-Apr-2018 |
Michael Lotz <mmlr@mlotz.ch> |
kernel: Make size argument to create_area_etc() size_t. It was limited to a uint32 and could for example be overflown by the slab MemoryManager that uses size_t on a 64 bit system. This aligns the signature with create_area() that already uses size_t for the size argument. Note that the function is currently private, so the impact should be limited.
|
#
1603eec4 |
|
27-Jan-2018 |
Jérôme Duval <jerome.duval@gmail.com> |
kernel: vm: allow mmapping of the last page of the userspace.
|
#
b521a45e |
|
13-Dec-2016 |
Jessica Hamilton <jessica.l.hamilton@gmail.com> |
Revert "vm: Try harder to allocate early physical pages." This reverts commit 21e3ac6cf52f91dba8217f15fc33dc1d45dffd40, which was accidentally applied twice, missed during rebase. Originally applied in 601b2f7eda4d25b46e7d17e212d22954f28bd0fe.
|
#
21e3ac6c |
|
21-Oct-2014 |
Henry Harrington <henry.harrington@gmail.com> |
vm: Try harder to allocate early physical pages. Signed-off-by: Jessica Hamilton <jessica.l.hamilton@gmail.com>
|
#
c73d1301 |
|
08-Nov-2015 |
Michael Lotz <mmlr@mlotz.ch> |
kernel: Use anonymous namespaces to avoid type collisions. The anonymous namespace makes type definitions local to the translation unit (like static does for objects). For pretty much any type not shared across multiple files this is what one wants to happen (and might erroneously expect to happen automatically). This commit solves some actual collisions that were present: * The VFS and the rootfs both used an incompatible VnodeHash struct for their BOpenHashTable. * XSI semaphores and message queues both used queued_thread, Ipc and IpcHashTableDefinition. For release builds these did not cause problems as the types were fully inlined. Debug builds would crash at boot however because parts of a BOpenHashTable<VnodeHash> from the rootfs meant to operate on struct rootfs_vnode would be applied to one from the VFS expecting struct vnode. As such collisions are violations of the one definition rule, the code is at fault and unfortunatley the compiler isn't required to diagnose such problems across translation units (which isn't actually trivial). This can lead to subtle and hard to debug problems and it's therefore best to avoid leaking types into the global namespace whenever possible.
|
#
d8548e00 |
|
07-Nov-2015 |
Jonathan Schleifer <js@webkeks.org> |
Fix some more type mismatches with std::{min,max}
|
#
271ac910 |
|
09-Jan-2015 |
Adrien Destugues <pulkomandy@gmail.com> |
Remove useless includes of khash.h * These files were already converted to BOpenHashTable. * For #9552.
|
#
8068b64b |
|
13-Nov-2014 |
PulkoMandy <pulkomandy@pulkomandy.tk> |
Fix build with guarded heap on x86_64 * Type mismatch.
|
#
601b2f7e |
|
21-Oct-2014 |
Henry Harrington <henry.harrington@gmail.com> |
vm: Try harder to allocate early physical pages. * On UEFI, pages are allocated top-down; previously, VM would fail to allocate early pages due to running into pages allocated at the top and assume it had run out of pages to map. Signed-off-by: Jessica Hamilton <jessica.l.hamilton@gmail.com>
|
#
7ca277b9 |
|
28-Oct-2014 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
vm_soft_fault(): remove unused wiredRange parameter
|
#
078a965f |
|
28-Oct-2014 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
vm_soft_fault(): Avoid deadlock waiting for wired ranges * VMArea::AddWaiterIfWired(): Replace the ignoreRange argument by a flags argument and introduce (currently only) flag IGNORE_WRITE_WIRED_RANGES. If specified, ranges wired for writing are ignored. Ignoring just a single specified range doesn't cut it in vm_soft_fault(), and there aren't any other users of that feature. * vm_soft_fault(): When having to unmap a page of a lower cache, this page cannot be wired for writing. So we can safely ignore all writed-wired ranges, instead of just our own. We even have to do that in case there's another thread that concurrently tries to write-wire the same page, since otherwise we'd deadlock waiting for each other.
|
#
8ef857d8 |
|
28-Oct-2014 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
vm_soft_fault(): Avoid inconsistent state when seeing wired page When we encounter a wired page that we'd have to unmap to map our newly allocated one, we need to get rid of the latter before unlocking everything and waiting for the wired page. Otherwise we'd leave things in an inconsistent state (a page from an upper cache shadowing a mapped page from a lower cache).
|
#
70d3bd55 |
|
28-Oct-2014 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
vm_soft_fault(): Missing DEBUG_PAGE_ACCESS_END() ... in case we'd need to unmap a page that is wired. Fixes the immediate issue of #10977. There's a problem remaining (as discussed in comment 1): If two threads want to wire the same page at the same time (which led to the assertion being triggered), they will now deadlock, waiting for each other to remove the pre-registered VMAreaWiredRange.
|
#
95e97463 |
|
14-Sep-2014 |
Paweł Dziepak <pdziepak@quarnos.org> |
kernel: add generic wrapper for accessing user memory This patch adds user_access() which can be used to gracefully handle page faults that may happen when accessing user memory. It is used by arch_cpu_user{memcpy, memset, strlcpy}() to allow using optimized functions from the standard library. Currently only x64 uses this, but nothing really is arch specific here. Signed-off-by: Paweł Dziepak <pdziepak@quarnos.org>
|
#
819824e0 |
|
26-Jan-2014 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel/{x86, vm}: Add more error checks in VM initialization
|
#
d02aaee1 |
|
15-Dec-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel, libroot: Add more memory info in system_info system_info now contains all information previously available only through __get_system_info_etc(B_MEMORY_INFO, ...).
|
#
781671ad |
|
10-Dec-2013 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
dump_mapping_info(): Remove problematic initializer Fixes gcc 2 build.
|
#
c259766f |
|
10-Dec-2013 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
KDL "mapping" command: Allow specifying a thread ID ... instead of only a team ID.
|
#
5d3978db |
|
10-Dec-2013 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
KDL "mapping" command: Fix argument check It wasn't possible to actually specify the second argument (team ID).
|
#
7b83ce11 |
|
04-Dec-2013 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Add KDL command "mapping" * VMTranslationMap: - Add DebugPrintMappingInfo(): Given a virtual address it is supposed to print the paging structure information for that address. To be implemented by derived classes. - Add DebugGetReverseMappingInfo(): Given a physical addresss it is supposed to find all virtual addresses mapped to it. To be implemented by derived classes. * X86VMTranslationMapPAE: Implement the new methods DebugPrintMappingInfo() and DebugGetReverseMappingInfo(). * Add KDL command "mapping". It supports both virtual address lookups and reverse lookups.
|
#
2b269f2e |
|
12-Nov-2013 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
unlock_memory_etc(): Fix address space reference leak unlock_memory_etc() is supposed to release the address space reference lock_memory_etc() acquired. It didn't do that, though.
|
#
93fb0ff0 |
|
12-Nov-2013 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
vm: lock_memory_etc(): Fix error case In case something went wrong, call unlock_memory_etc() with the rounded base address instead of with the original address. If the original address wasn't page aligned, unlock_memory_etc() would otherwise try to unlock an additional page.
|
#
e5f65913 |
|
11-Nov-2013 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
VM: vm_memset_physical(): Correct length parameter type
|
#
8614737f |
|
15-Apr-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
elf: restore correct region protection after relocation
|
#
feae2b5a |
|
09-Apr-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
vm: force userland to use B_RANDOMIZED_* address specifications
|
#
bf65fc1d |
|
09-Apr-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
vm: remove B_RANDOMIZED_IMAGE_ADDRESS address specification This address specification is actually not needed since PIC images can be located anywhere. Only their size is restriced but that is the compiler and linker concern. Thanks to Alex Smith for pointing that out.
|
#
d4823423 |
|
05-Apr-2013 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
VM: Fix vm_block_address_range() area protection B_ALREADY_WIRED, which was erroneously passed for the area protection parameter to map_backing_store(), has the value 7 which implies user readable and writable. Hence the address ranges around 0xdeadbeef and 0xcccccccc could actually be read and written from anywhere.
|
#
65ed4fa9 |
|
03-Apr-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
vm: implement B_RANDOMIZED_IMAGE_ADDRESS address specification On some 64 bit architectures program and library images have to be mapped in the lower 2 GB of the address space (due to instruction pointer relative addressing). Address specification B_RANDOMIZED_IMAGE_ADDRESS ensures that created area satisfies that requirement.
|
#
966f2076 |
|
06-Mar-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
x86: enable data execution prevention Set execute disable bit for any page that belongs to area with neither B_EXECUTE_AREA nor B_KERNEL_EXECUTE_AREA set. In order to take advanage of NX bit in 32 bit protected mode PAE must be enabled. Thus, from now on it is also enabled when the CPU supports NX bit. vm_page_fault() takes additional argument which indicates whether page fault was caused by an illegal instruction fetch.
|
#
b3e4c677 |
|
26-Feb-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
vm: implement B_RANDOMIZED_ANY_ADDRESS address specification Randomized equivalent of B_ANY_ADDRESS. When a free space is found (as in B_ANY_ADDRESS) the base adress is then randomized using _RandomizeAddress pretty much like it is done in B_RANDOMIZED_BASE_ADDRESS.
|
#
f9bab525 |
|
25-Feb-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
vm: implement B_RANDOMIZED_BASE_ADDRESS address specification B_RAND_BASE_ADDRESS is basically B_BASE_ADDRESS with non-deterministic created area's base address. Initial start address is randomized and then the algorithm looks for a large enough free space in the interval [randomized start, end]. If it fails then the search is repeated in the interval [original start, randomized start]. In case it also fails the algorithm falls back to B_ANY_ADDRESS (B_RANDOMIZED_ANY_ADDRESS when it is implemented) just like B_BASE_ADDRESS does. Randomization range is limited by kMaxRandomize and kMaxInitialRandomize.
|
#
d1f280c8 |
|
01-Apr-2012 |
Hamish Morrison <hamishm53@gmail.com> |
Add support for pthread_attr_get/setguardsize() * Added the aforementioned functions. * create_area_etc() now takes a guard size parameter. * The thread_info::stack_base/end range now refers to the usable range only.
|
#
4efc3430 |
|
14-Aug-2012 |
Alex Smith <alex@alex-smith.me.uk> |
Fixed possible NULL dereference in vm_page_fault. This bug was introduced by changing IS_USER_ADDRESS to check against USER_BASE AND USER_TOP rather than just !IS_KERNEL_ADDRESS. Faults on addresses outside both the user and kernel address spaces (i.e. the gap between user and kernel) would result in addressSpace being NULL, but addressSpace was being used without checking for NULL at one point.
|
#
25871c68 |
|
04-Aug-2012 |
Alex Smith <alex@alex-smith.me.uk> |
Removed Thread::fault_callback, no longer necessary now that vm86 is gone.
|
#
6e2f6d1a |
|
29-Jul-2012 |
Alex Smith <alex@alex-smith.me.uk> |
Changed cookie type for get_next_area_info() to ssize_t. The cookie is used to store the base address of the area that was just visited. On 64-bit systems, int32 is not sufficient. Therefore, changed to ssize_t which retains compatibility on x86 while expanding to a sufficient size on x86_64.
|
#
c3f0fd28 |
|
12-Jul-2012 |
Alex Smith <alex@alex-smith.me.uk> |
Fixed formatting of output in some debugger commands. Currently all debugger commands assume 32-bit pointers when formatting their output. This means that on x86_64 the output is incorrectly formatted. Fixed this by adding a B_PRINTF_POINTER_WIDTH definition (16 on 64-bit, 8 on 32-bit), and using this to correctly format the output. Not all commands have been fixed yet, but all VM, slab, VFS, team, thread and image commands should be correct.
|
#
5e9bb17d |
|
08-Jul-2012 |
Alex Smith <alex@alex-smith.me.uk> |
Renamed remaining i386_* functions to x86_* for consistency.
|
#
3b802628 |
|
09-Jul-2012 |
Alex Smith <alex@alex-smith.me.uk> |
Support ELF64 in the kernel. This has been done by adding typedefs in elf_common.h to the correct ELF structures for the architecture, and changing all Elf32_* uses to those types. I don't know whether image loading works as I cannot test it yet, there may be some 64-bit safety issues around. However, symbol lookup for the kernel is working correctly.
|
#
c1517626 |
|
06-Jul-2012 |
Alex Smith <alex@alex-smith.me.uk> |
Compile APIC and timer code for x86_64, and create an area for the IDT.
|
#
ab7726a2 |
|
06-Jul-2012 |
Alex Smith <alex@alex-smith.me.uk> |
Temporary fix for create_preloaded_image_areas. Will be replaced with a typedef later on.
|
#
11d35d1b |
|
05-Jul-2012 |
Alex Smith <alex@alex-smith.me.uk> |
Fixed tracing printf formats in VM code.
|
#
fb8447d5 |
|
02-Jul-2012 |
Rene Gollent <anevilyak@gmail.com> |
Fix ticket #8650. - Replace arch_cpu_user_strlcpy() and arch_cpu_user_memset() with x86 assembly versions. These correctly handle the fault handler, which had broken again on gcc4 for the C versions, causing stack corruption in certain error cases. The other architectures will still need to have corresponding asm variants added in order for them to not run into the same issue though.
|
#
294711f9 |
|
27-Jun-2012 |
Alex Smith <alex@alex-smith.me.uk> |
Changed {,u}int64 to be long rather than long long on x86_64.
|
#
f1244978 |
|
22-Jun-2012 |
Alex Smith <alex@alex-smith.me.uk> |
Added an ELF64 version of preloaded_image. * There is now 2 structures, preloaded_elf32_image and preloaded_elf64_image, which both inherit from preloaded_image. * For now I've just hardcoded in use of preloaded_elf32_image, but the bootloader ELF code will shortly be converted to use templates which use the appropriate structure. The kernel will be changed later when I add ELF64 support to it. * All kernel_args data is now compatible between 32-bit and 64-bit kernels.
|
#
192af9e0 |
|
20-Jun-2012 |
Alex Smith <alex@alex-smith.me.uk> |
Changed addr_range to use uint64. I've tested this change on x86, causing no issues. I've checked over the code for all other platforms and made the necessary changes and to the best of my knowledge they should also still work, but I haven't actually built and tested them. Once I've completed the kernel_args changes the other platforms will need testing.
|
#
4be4fc6b |
|
15-Jun-2012 |
Alex Smith <alex@alex-smith.me.uk> |
More 64-bit compilation/safety fixes.
|
#
c40f3186 |
|
16-Jan-2012 |
Jérôme Duval <jerome.duval@gmail.com> |
Fix with enabled tracing.
|
#
6ef7d359 |
|
11-Dec-2011 |
Michael Lotz <mmlr@mlotz.ch> |
ASSERT() that there really aren't any wired pages.
|
#
af09f123 |
|
11-Dec-2011 |
Michael Lotz <mmlr@mlotz.ch> |
Create the right cache type ([non-]swappable) on copy on write. When forking a team, copy on write areas (and therefore caches) are created for all the areas in the parent team, but they were always created as swappable. If the parent team had some B_FULL_LOCK areas, which aren't swappable, the wrong type of cache would be created which lead to them not being mergeable later on (causing a panic). Comments about a possibly cleaner way to figure out the cache type would be welcome.
|
#
ded69b4c |
|
06-Dec-2011 |
Michael Lotz <mmlr@mlotz.ch> |
Only the to be protected range needs to be non-wired. When setting memory protection, only ensure/wait for the range that needs to be protected to not be wired instead of requiering the whole area to be non-wired. The memory protection is done page wise and having some parts of the area wired shouldn't preclude other parts to be protected.
|
#
1fe24d0c |
|
03-Dec-2011 |
Michael Lotz <mmlr@mlotz.ch> |
Add heap with guard pages to detect out of bound reads/writes. This is a very simple heap implementation that allocates memory so that the end of each allocation always coincides with a page end and is followed by a guard page which is marked non-present. Out of bounds access (both read and write) therefore cause a crash (unhandled page fault). Note that this allocator is neither speed nor space efficient, indeed it wastes huge amounts of pages and address space so it is quite easy to hit limits. It is intended as a pure debug feature.
|
#
7418dbd9 |
|
03-Dec-2011 |
Michael Lotz <mmlr@mlotz.ch> |
Introduce debug page wise kernel area protection functions. This adds a pair of functions vm_prepare_kernel_area_debug_protection() and vm_set_kernel_area_debug_protection() to set a kernel area up for page wise protection and to actually protect individual pages respectively. It was already possible to read and write protect full areas via area protection flags and not mapping any actual pages. For areas that actually have mapped pages this doesn't work however as no fault, at which the permissions could be checked, is generated on access. These new functions use the debug helpers of the translation map to mark individual pages as non-present without unmapping them. This allows them to be "protected", i.e. causing a fault on read and write access. As they aren't actually unmapped they can later be marked present again. Note that these are debug helpers and have quite a few restrictions as described in the comment above the function and is only useful for some very specific and constrained use cases.
|
#
5247333d |
|
13-Nov-2011 |
Michael Lotz <mmlr@mlotz.ch> |
Don't do the heap size calculation when using the slab as heap. The initial heap size calculation only applies to the legacy/debug heap, so it isn't needed when using the slab as kernel heap.
|
#
f8154d17 |
|
02-Nov-2011 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
mmlr (distracted) + bonefish: * Turn VMCache::consumers C list into a DoublyLinkedList. * Use object caches for the different VMCache types and the VMCacheRefs. The purpose is to reduce slab area fragmentation. * Requires the introduction of a pure virtual VMCache::DeleteObject() method, implemented in the derived classes. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43133 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ffb6929a |
|
31-Oct-2011 |
Michael Lotz <mmlr@mlotz.ch> |
bonefish+mmlr: Move blocking the 0xcccccccc and 0xdeadbeef address ranges from heap to VM init so that it also works when used in the slab allocator. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43047 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
02cd58f4 |
|
27-Jun-2011 |
Michael Lotz <mmlr@mlotz.ch> |
Move resizing the page_protections before resizing the cache to avoid a needless resize operation that has to be undone and may fail when doing so. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42332 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
3fb17998 |
|
27-Jun-2011 |
Michael Lotz <mmlr@mlotz.ch> |
When resizing an area that has individual page protections (set via mprotect), we have to enlarge/shrink the array that holds them and assign a protection value for the additional pages as necessary. Otherwise we'll access invalid memory when looking up page protections for enlarged areas and get random protection values. Experienced with QEMU that sets page protections via mprotect on heap memory. When the heap was later enlarged, write access to the additional memory would result in permission denied errors and crashes. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42330 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
6244ea50 |
|
21-Jun-2011 |
Michael Lotz <mmlr@mlotz.ch> |
Fix range check. The previous check would produce an off by one error making the last byte of an unmapped-but-still-there page non-readable (i.e. from B_NO_LOCK areas), causing such reads to fail in KDL. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42276 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
36dc99a3 |
|
12-Jun-2011 |
Rene Gollent <anevilyak@gmail.com> |
Add private get_memory_properties() syscall which allows one to retrieve the address protection bits as well as the wiring flags for an arbitrary address in a team's address space. Will be used in the debugger for the purposes of the memory inspector/editor, in order to determine whether it can in fact allow editing for the currently inspected address range. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42129 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
24df6592 |
|
11-Jun-2011 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Merged signals-merge branch into trunk with the following changes: * Reorganized the kernel locking related to threads and teams. * We now discriminate correctly between process and thread signals. Signal handlers have been moved to teams. Fixes #5679. * Implemented real-time signal support, including signal queuing, SA_SIGINFO support, sigqueue(), sigwaitinfo(), sigtimedwait(), waitid(), and the addition of the real-time signal range. Closes #1935 and #2695. * Gave SIGBUS a separate signal number. Fixes #6704. * Implemented <time.h> clock and timer support, and fixed/completed alarm() and [set]itimer(). Closes #5682. * Implemented support for thread cancellation. Closes #5686. * Moved send_signal() from <signal.h> to <OS.h>. Fixes #7554. * Lots over smaller more or less related changes. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42116 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d78e0dc9 |
|
23-Jan-2011 |
Rene Gollent <anevilyak@gmail.com> |
CID 10326 - remove superfluous for loop. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40277 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
4535495d |
|
10-Jan-2011 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Merged the signals branch into trunk, with these changes: * The team and thread kernel structures have been renamed to Team and Thread respectively and moved into the new BKernel namespace. * Several (kernel add-on) sources have been converted from C to C++ since private kernel headers are included that are no longer C compatible. Changes after merging: * Fixed gcc 2 build (warnings mainly in the scary firewire bus manager). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40196 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ce30d635 |
|
17-Oct-2010 |
Ithamar R. Adema <ithamar.adema@team-embedded.nl> |
* fix outdated commented dprintf (still useful for local debugging) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38990 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
b9447668 |
|
10-Jul-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Moved the vm_page initialization from vm_page.cpp:vm_page_init() to the new vm_page::Init(). * Made vm_page::wired_count private and added accessor methods. * Added VMCache::fWiredPagesCount (the number of wired pages the cache contains) and accessor methods. * Made more use of vm_page::IsMapped(). * vm_copy_on_write_area(): Added vm_page_reservation* parameter that can be used to request a special handling for wired pages. If given the wired pages are replaced by copies and the original pages are moved to the upper cache. * vm_copy_area(): - We don't need to do any wired ranges handling, if the source area is a B_SHARED_AREA, since we don't touch the area's mappings in this case. - We no longer wait for wired ranges of the concerned areas to disappear. Instead we use the new vm_copy_on_write_area() feature and just let it copy the wired pages. This fixes #6288, an issue introduced with the use of user mutexes in libroot: When executing multiple concurrent fork()s all but the first one would wait on the fork mutex, which (being a user mutex) would wire a page that the vm_copy_area() of the first fork() would wait for. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37460 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
fbcffaef |
|
23-Jun-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Fixed non-x86 builds. __get_memory_map_haiku() must be the default. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37237 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
2a25d16d |
|
23-Jun-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* get_memory_map(): Changed parameters types to fixed-width types. * Added BeOS compatibility wrappers for get_memory_map(), map_physical_memory(), and create_area(). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37232 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ef4fd448 |
|
23-Jun-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
vm_create_anonymous_area(): Optimized the B_32_BIT_{FULL_LOCK,CONTIGUOUS} cases for B_HAIKU_PHYSICAL_BITS > 32 and accessible physical memory < 4 GB. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37231 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
9fb2d737 |
|
23-Jun-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Replaced B_32_BIT_MEMORY by B_32_BIT_FULL_LOCK and B_32_BIT_CONTIGUOUS, so the constraint can be expressed more precisely. ATM B_32_BIT_FULL_LOCK is implemented as B_32_BIT_CONTIGUOUS when B_HAIKU_PHYSICAL_BITS > 32, though. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37226 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
91af25d3 |
|
21-Jun-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
vm_create_anonymous_area(): * Fixed check: If a low *or* high address restriction is given, we need to force B_CONTIGUOUS wiring. * Optimization: Contiguous single-page allocation can be allocated as full-lock, if the no low/high address restrictions are given. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37203 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
be87d0a0 |
|
21-Jun-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Added area creation "lock" constant B_32_BIT_MEMORY for physically contiguous memory < 4 GB. * vm_create_anonymous_area(): Implemented support for B_LOMEM and B_32_BIT_MEMORY. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37200 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
13638944 |
|
21-Jun-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Removed never read VMCache::scan_skip. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37195 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
94226016 |
|
21-Jun-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Mark caches of null areas temporary, so we don't try to write back modified pages when deleting the area. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37194 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
c955359c |
|
18-Jun-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added vm_available_not_needed_memory_debug(), a vm_available_not_needed_memory() version that can be called from within the kernel debugger. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37167 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
377ecfe7 |
|
14-Jun-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Renamed cache_type_to_string() to vm_cache_type_to_string() and made in kernel private. * Moved dumping code from dump_cache() to new VMCache::Dump(). * Override VMCache::Dump() in VMVnodeCache to also print the vnode. * Removed no longer needed VMCache::GetLock(). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37138 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
a8ad734f |
|
14-Jun-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Introduced structures {virtual,physical}_address_restrictions, which specify restrictions for virtual/physical addresses. * vm_page_allocate_page_run(): - Fixed conversion of base/limit to array indexes. sPhysicalPageOffset was not taken into account. - Takes a physical_address_restrictions instead of base/limit and also supports alignment and boundary restrictions, now. * map_backing_store(), VM[User,Kernel]AddressSpace::InsertArea()/ ReserveAddressRange() take a virtual_address_restrictions parameter, now. They also support an alignment independent from the range size. * create_area_etc(), vm_create_anonymous_area(): Take {virtual,physical}_address_restrictions parameters, now. * Removed no longer needed B_PHYSICAL_BASE_ADDRESS. * DMAResources: - Fixed potential overflows of uint32 when initializing from device node attributes. - Fixed bounce buffer creation TODOs: By using create_area_etc() with the new restrictions parameters we can directly support physical high address, boundary, and alignment. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37131 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
1d26c724 |
|
10-Jun-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
vm_page_allocate_page_run(): Added parameter "limit", specifying the upper physical address limit for the page run to allocate. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37086 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
641b3c82 |
|
09-Jun-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Renamed allocate_early_physical_page() to vm_allocate_early_physical_page() and made it public. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37072 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
2ea7b17c |
|
09-Jun-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* vm_allocate_early(): Replace "bool blockAlign" parameter by a more flexible "addr_t aligmnent". * X86PagingMethod32Bit::PhysicalPageSlotPool::InitInitial(), generic_vm_physical_page_mapper_init(): Use vm_allocate_early()'s alignment feature instead of aligning by hand. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37070 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
06185163 |
|
06-Jun-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Debug output of map_backing_store(), vm_map_physical_memory[_vecs](): Print the potential input parameter (virtual address) rather than its address. As suggested by Andreas Faerber in #6141. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37029 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
1ba89e67 |
|
05-Jun-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Removed no-op VMTranslationMap::InitPostSem() and VMAddressSpace::InitPostSem(). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37025 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
2e04c067 |
|
04-Jun-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Patch by Andreas Faerber: vm_free_unused_boot_loader_range(): Don't free any memory beyond the given range. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37010 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
1d578e15 |
|
02-Jun-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Fixed more address types related issues. Mostly printf() or comparison warnings, but also some oversights from earlier changes. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37000 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
435c43f5 |
|
02-Jun-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Introduced type generic_io_vec, which is similar to iovec, but uses types that are wide enough for both virtual and physical addresses. * DMABuffer, IORequest, IOScheduler,... and code using them: Use generic_io_vec and generic_{addr,size}_t where necessary. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36997 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
64d79eff |
|
27-May-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Changed physical_entry::{address,size} to phys_{addr,size}_t and changed map_physical_memory()'s physicalAddress parameter type from void* to phys_addr_t. This breaks source compatibility, but -- as long as phys_{addr,size}_t remain 32 bit wide -- keeps binary compatibility with BeOS. * Adjusted all code using the affected interfaces (Oh what fun!). Added a few TODOs in places where the wrong types (e.g. void* for physical addresses are used). Looks like quite a few drivers aren't 64 bit safe and others will break with PAE. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36960 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
147133b7 |
|
25-May-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* First run through the kernel's private parts to use phys_{addr,size}_t where appropriate. * Typedef'ed page_num_t to phys_addr_t and used it in more places in vm_page.{h,cpp}. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36937 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
f51bcfb2 |
|
18-May-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added a heap_init_post_area() which is called right after areas can be created, and moved the heap's grow and VIP heap initialization to it. Should fix #5956. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36855 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
13fa4c84 |
|
06-May-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Introduced new area creation flag CREATE_AREA_DONT_COMMIT_MEMORY. map_backing_store() doesn't commit memory when this flag is given. * Used the new flag vm_copy_area(): We no longer commit memory for read-only areas. This prevents read-only mapped files from suddenly requiring memory after fork(). Might improve the situation on machines with very little RAM a bit. We should probably mark writable copies over-committing, since the usual case is fork() + exec() where the child normally doesn't need more than a few pages until calling exec(). That would significantly reduce the memory requirement for jamming the Haiku tree. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36651 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
7b926f51 |
|
05-May-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Allocate memory for the DEBUG_CACHE_LIST debug feature only when there's plenty available. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36634 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
7198f765 |
|
05-May-2010 |
Axel Dörfler <axeld@pinc-software.de> |
* During early kernel startup, we must not create areas without the CREATE_AREA_DONT_WAIT flag; waiting at this point is not allowed. * I hope I found all occurences, but there might be some areas left (note, only those that don't use B_ALREADY_WIRED are problematic). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36624 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
6f2772b1 |
|
02-May-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
vm_map_physical_memory(): When alreadyWired we have to explicitly set the memory type for the mapped pages. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36590 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
c1be1e07 |
|
01-May-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* VMTranslationMap::Map()/Protect(): Added "memoryType" parameter. Not implemented for any architecture yet. * vm_set_area_memory_type(): Call VMTranslationMap::ProtectArea() to change the memory type for the already mapped pages. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36574 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
3b0c1b52 |
|
01-May-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* VMArea: Made memory_type private and added setter and getter methods. * Don't set the VMArea's memory type in arch_vm_set_memory_type(), but let the callers do that. * vm_set_area_memory_type(): Does nothing, if the memory type doesn't change. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36573 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
90788614 |
|
01-May-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Changed some parameters of VM syscalls from int to uint32, mostly for sake of consistency. * Moved the B_OVERCOMMITTING_AREA flag from B_KERNEL_AREA_FLAGS to B_USER_AREA_FLAGS, since we really allow it to be passed from userland. * Most VM syscalls check the provided protection against B_USER_AREA_FLAGS instead of B_USER_PROTECTION, now. This way they allow for B_OVERCOMMITTING_AREA as well. * _user_map_file(), _user_set_memory_protection(): Check the protection like the other syscalls do and use fix_protection() instead of doing that manually. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36572 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
278f7e57 |
|
30-Apr-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
map_backing_store(): Also consider the B_OVERCOMMITTING_AREA for private maps. The new cache will be created in over-committing mode. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36550 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
c1b8ab4e |
|
26-Apr-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
vm_create_anonymous_area(): Allocate the page run for B_CONTIGUOUS areas before locking the address space. That gives us a bit more flexibility in vm_page_allocate_page_run(). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36486 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ccb3f07a |
|
22-Apr-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
get_memory_map_etc(): Setting the return value to B_BUFFER_OVERFLOW in the loop causes the function to return before setting the _numEntries. The overflow case is checked at the end of the function anyway, so we can just break out. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36425 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ba16e4ec |
|
20-Apr-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
cut_area(): We should only resize RAM caches. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36372 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d97b5913 |
|
13-Apr-2010 |
Axel Dörfler <axeld@pinc-software.de> |
* Fixed incorrect indentation. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36258 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
e506fde8 |
|
13-Apr-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
wait_if_address_range_is_wired() was leaking a cache reference. Fixes #5710. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36237 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
c3676b54 |
|
13-Apr-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Added vm_debug_copy_page_memory() which copies memory from a potentially not mapped page. * debug_{mem,strl}cpy(): - Added "team" parameter for specifying the address space the address are to be interpreted in. - When the standard memcpy() (with fault handler) fails, fall back to vm_debug_copy_page_memory(). * Added debug_is_debugged_team(): Predicate returning true, if the supplied team_id refers to the same team debug_get_debugged_thread() belongs to. * Added DebuggedThreadSetter class for scope-based debug_set_debugged_thread(). Made use of it in several debugger functions. * print_demangled_call() (x86): Fixed unsafe memory access. Allows KDL stack traces to work correctly again, even if the page daemon has already unmapped the concerned pages. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36230 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
aa26d107 |
|
12-Apr-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
delete_area(): When the address space is the kernel address space, we need to pass stricter allocation flags to VMAddressSpace::{Remove,Delete}Area() or could deadlock otherwise. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36188 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
349039ff |
|
11-Apr-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added vm_[un]wire_page(), which are essentially versions of [un]lock_memory_etc() optimized for a single page. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36156 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
4f774c50 |
|
04-Apr-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* VMArea::Unwire(addr_t, size_t, bool): Don't delete the removed range, but return it. * lock_memory_etc(): On error the VMAreaWiredRange object could be leaked. * [un]lock_memory_etc(): Call VMArea::Unwire() with the cache locked and explicitly delete the range object after unlocking the cache to avoid potential deadlocks. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36035 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
369111e7 |
|
05-Apr-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Removed the VMArea::Wire() version that has to allocate a VMAreaWiredRange. Since the requirement is that the area's top cache is locked, allocating memory isn't allowed. * lock_memory_etc(): Create the VMAreaWiredRange object explicitly before locking the area's top cache. Fixes #5680 (deadlocks when using the slab as malloc() backend). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36033 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
550376ff |
|
03-Apr-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* vm_delete_areas(): Changed return type to void (was status_t and not used). * _user_map_file(), _user_unmap_memory(): Verify that the address (if given) is page aligned. * Reworked memory locking (wiring): - VMArea does now have a list of wired memory ranges and supports waiting for a range to be removed. - vm_soft_fault(): - Added "wirePage" parameter that, if given, makes the function wire the page and return it. - Added "wiredRange" parameter (for calls from lock_memory_etc()) and made sure we never unmap wired pages. This could e.g. happen when a page from a lower cache was read-mapped and a write fault occurred. Now in such a situation the function waits for the page to be unwired and restarts. - All functions that manipulate areas in a way that could affect wired ranges do now either require the caller to make sure there are no wired ranges in the way or do that themselves. Added a few wait_if_*_is_wired() helper functions for that purpose. - lock_memory_etc(): - Does now also work correctly when the range spans more than one area. - Adds VMAreaWiredRanges to the affected VMAreas and retains an address space reference (so that the address space won't be deleted as long as a wired range exists). - Resolved TODO: The area's caches are now locked when increment_page_wired_count() is called. - Resolved TODO: The race condition due to missing locking after looking up the page mapping is now prevented. We hold the cache locks (in case the page is already mapped) and the new vm_soft_fault() parameter allows us to get the page wired. - unlock_memory_etc(): Changes symmetrical to those in lock_memory_etc() and resolved all TODOs. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36030 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d80af65f |
|
18-Mar-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
The "page" and the "cache" kernel debugger commands set a few temporary variables, now. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35903 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
98248b16 |
|
12-Mar-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Let the compiler decide whether to inline or not. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35821 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d40a9355 |
|
02-Mar-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Boot loader (x86 mmu.cpp): * Made the page table allocation more flexible. Got rid of sMaxVirtualAddress and added new virtual_end address to the architecture specific kernel args. * Increased the virtual space we reserve for the kernel to 16 MB. That should suffice for quite a while. The previous 2 MB were too tight when building the kernel with debug info. * mmu_init(): The way we were translating the BIOS' extended memory map to our physical ranges arrays was broken. Small gaps between usable memory ranges would be ignored and instead marked allocated. This worked fine for the boot loader and during the early kernel initialization, but after the VM has been fully set up it frees all physical ranges that have not been claimed otherwise. So those ranges could be entered into the free pages list and would be used later. This could possibly cause all kinds of weird problems, probably including ACPI issues. Now we add only the actually usable ranges to our list. Kernel: * vm_page_init(): The pages of the ranges between the usable physical memory ranges are now marked PAGE_STATE_UNUSED, the allocated ranges PAGE_STATE_WIRED. * unmap_and_free_physical_pages(): Don't free pages marked as unused. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35726 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ff59ce68 |
|
24-Feb-2010 |
Axel Dörfler <axeld@pinc-software.de> |
* The low resource handler now empties the cache depot's magazines; before, they were never freed unless the cache was destroyed (I just wondered why my system would bury >1G in the magazines). * Made the magazine capacity variable per cache, ie. for larger objects, it's not a good idea to have 64*CPU buffers lying around in the worst case. * Furthermore, the create_object_cache_etc()/object_depot_init() now have arguments for the magazine capacity as well as the maximum number of full unused magazines. * By default, you might want to initialize both to zero, as then some hopefully usable defaults are computed. Otherwise (the only current example is the vm_page_mapping cache) you can just put in the values you'd want there. The page mapping cache uses larger values, as its objects are usually allocated and deleted in larger chunks. * Beware, though, I couldn't test these changes yet as Qemu didn't like to run today. I'll test these changes on another machine now. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35601 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
bd7645a1 |
|
20-Feb-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Made vm_page::state private and added accessor methods. * Added kernel tracing for page state transitions. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35538 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
dac21d8b |
|
18-Feb-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* 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
|
#
176f7588 |
|
17-Feb-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added warning to vm_map_physical_memory_vecs(). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35508 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
665e7ac6 |
|
16-Feb-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
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
|
#
0f2666ec |
|
15-Feb-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
_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
|
#
40bb9481 |
|
03-Feb-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Removed useless return parameter from vm_remove_all_page_mappings(). * Added vm_clear_page_mapping_accessed_flags() and vm_remove_all_page_mappings_if_unaccessed(), which combine the functionality of vm_test_map_activation(), vm_clear_map_flags(), and vm_remove_all_page_mappings(), thus saving lots of calls to translation map methods. The backend is the new method VMTranslationMap::ClearAccessedAndModified(). * Started to make use of the cached page queue and changed the meaning of the other non-free queues slightly: - Active queue: Contains mapped pages that have been used recently. - Inactive queue: Contains mapped pages that have not been used recently. Also contains unmapped temporary pages. - Modified queue: Contains unmapped modified pages. - Cached queue: Contains unmapped unmodified pages (LRU sorted). Unless we're actually low on memory and actively do paging, modified and cached queues only contain non-temporary pages. Cached pages are considered quasi free. They still belong to a cache, but since they are unmodified and unmapped, they can be freed immediately. And this is what vm_page_[try_]reserve_pages() do now when there are no more actually free pages at hand. Essentially this means that pages storing cached file data, unless mmap()ped, no longer are considered used and don't contribute to page pressure. Paging will not happen as long there are enough free + cached pages available. * Reimplemented the page daemon. It no longer scans all pages, but instead works the page queues. As long as the free pages situation is harmless, it only iterates through the active queue and deactivates pages that have not been used recently. When paging occurs it additionally scans the inactive queue and frees pages that have not been used recently. * Changed the page reservation/allocation interface: vm_page_[try_]reserve_pages(), vm_page_unreserve_pages(), and vm_page_allocate_page() now take a vm_page_reservation structure pointer. The reservation functions initialize the structure -- currently consisting only of a count member for the number of still reserved pages. vm_page_allocate_page() decrements the count and vm_page_unreserve_pages() unreserves the remaining pages (if any). Advantages are that reservation/ unreservation mismatches cannot occur anymore, that vm_page_allocate_page() can verify that the caller has indeed a reserved page left, and that there's no unnecessary pressure on the free page pool anymore. The only disadvantage is that the vm_page_reservation object needs to be passed around a bit. * Reworked the page reservation implementation: - Got rid of sSystemReservedPages and sPageDeficit. Instead sUnreservedFreePages now actually contains the number of free pages that have not yet been reserved (it cannot become negative anymore) and the new sUnsatisfiedPageReservations contains the number of pages that are still needed for reservation. - Threads waiting for reservations do now add themselves to a waiter queue, which is ordered by descending priority (VM priority and thread priority). High priority waiters are served first when pages become available. Fixes #5328. * cache_prefetch_vnode(): Would reserve one less page than allocated later, if the size wasn't page aligned. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35393 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
e65c4002 |
|
29-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Replaced the vm_page_allocate_page*() "pageState" parameter by a more general "flags" parameter. It encodes the target state of the page -- so that the page isn't unnecessarily put in the wrong page queue first -- a flag whether the page should be cleared, and one to indicate whether the page should be marked busy. * Added page state PAGE_STATE_CACHED. Not used yet. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35333 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
72382fa6 |
|
29-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Removed the page state PAGE_STATE_BUSY and instead introduced a vm_page::busy flag. The obvious advantage is that one can still see what state a page is in and even move it between states while being marked busy. * Removed the vm_page::is_dummy flag. Instead we mark marker pages busy, which in all cases has the same effect. Introduced a vm_page_is_dummy() that can still check whether a given page is a dummy page. * vm_page_unreserve_pages(): Before adding to the system reserve make sure sUnreservedFreePages is non-negative. Otherwise we'd make nonexisting pages available for allocation. steal_pages() still has the same problem and it can't be solved that easily. * map_page(): No longer changes the page state/mark the page unbusy. That's the caller's responsibility. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35331 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ab33f2d9 |
|
28-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
vm_create_null_area(): The area was created with B_NO_LOCK which would cause the wired count of manually mapped pages not to be decremented in delete_area(), leading to a "pages still has mappings" panic when the slab allocator's memory manager deleted areas. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35329 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
deee8524 |
|
26-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Introduced {malloc,memalign,free}_etc() which take an additional "flags" argument. They replace the previous special-purpose allocation functions (malloc_nogrow(), vip_io_request_malloc()). * Moved the I/O VIP heap to heap.cpp accordingly. * Added quite a bit of passing around of allocation flags in the VM, particularly in the VM*AddressSpace classes. * Fixed IOBuffer::GetNextVirtualVec(): It was ignoring the VIP flag and always allocated on the normal heap. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35316 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
cff6e9e4 |
|
26-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* The system now holds back a small reserve of committable memory and pages. The memory and page reservation functions have a new "priority" parameter that indicates how deep the function may tap into that reserve. The currently existing priority levels are "user", "system", and "VIP". The idea is that user programs should never be able to cause a state that gets the kernel into trouble due to heavy battling for memory. The "VIP" level (not really used yet) is intended for allocations that are required to free memory eventually (in the page writer). More levels are thinkable in the future, like "user real time" or "user system server". * Added "priority" parameters to several VMCache methods. * Replaced the map_backing_store() "unmapAddressRange" parameter by a "flags" parameter. * Added area creation flag CREATE_AREA_PRIORITY_VIP and slab allocator flag CACHE_PRIORITY_VIP indicating the importance of the request. * Changed most code to pass the right priorities/flags. These changes already significantly improve the behavior in low memory situations. I've tested a bit with 64 MB (virtual) RAM and, while not particularly fast and responsive, the system remains at least usable under high memory pressure. As a side effect the slab allocator can now be used as general memory allocator. Not done by default yet, though. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35295 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
b4e5e498 |
|
25-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
MemoryManager: * Added support to do larger raw allocations (up to one large chunk (128 pages)) in the slab areas. For an even larger allocation an area is created (haven't seen that happen yet, though). * Added kernel tracing (SLAB_MEMORY_MANAGER_TRACING). * _FreeArea(): Copy and paste bug: The meta chunks of the to be freed area would be added to the free lists instead of being removed from them. This would corrupt the lists and also lead to all kinds of misuse of meta chunks. object caches: * Implemented CACHE_ALIGN_ON_SIZE. It is no longer set for all small object caches, but the block allocator sets it on all power of two size caches. * object_cache_reserve_internal(): Detect recursion and don't wait in such a case. The function could deadlock itself, since HashedObjectCache::CreateSlab() does allocate memory, thus potentially reentering. * object_cache_low_memory(): - I missed some returns when reworking that one in r35254, so the function might stop early and also leave the cache in maintenance mode, which would cause it to be ignored by object cache resizer and low memory handler from that point on. - Since ReturnSlab() potentially unlocks, the conditions weren't quite correct and too many slabs could be freed. - Simplified things a bit. * object_cache_alloc(): Since object_cache_reserve_internal() does potentially unlock the cache, the situation might have changed and their might not be an empty slab available, but a partial one. The function would crash. * Renamed the object cache tracing variable to SLAB_OBJECT_CACHE_TRACING. * Renamed debugger command "cache_info" to "slab_cache" to avoid confusion with the VMCache commands. * ObjectCache::usage was not maintained anymore since I introduced the MemoryManager. object_cache_get_usage() would thus always return 0 and the block cache would not be considered cached memory. This was only of informational relevance, though. slab allocator misc.: * Disable the object depots of block allocator caches for object sizes > 2 KB. Allocations of those sizes aren't so common that the object depots yield any benefit. * The slab allocator is now fully self-sufficient. It allocates its bootstrap memory from the MemoryManager, and the hash tables for HashedObjectCaches use the block allocator instead of the heap, now. * Added option to use the slab allocator for malloc() and friends (USE_SLAB_ALLOCATOR_FOR_MALLOC). Currently disabled. Works in principle and has virtually no lock contention. Handling for low memory situations is yet missing, though. * Improved the output of some debugger commands. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35283 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
148637e9 |
|
22-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Use large slabs for the page mappings. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35247 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
8d1316fd |
|
22-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Replaced CACHE_DONT_SLEEP by two new flags CACHE_DONT_WAIT_FOR_MEMORY and CACHE_DONT_LOCK_KERNEL_SPACE. If the former is given, the slab memory manager does not wait when reserving memory or pages. The latter prevents area operations. The new flags add a bit of flexibility. E.g. when allocating page mapping objects for userland areas CACHE_DONT_WAIT_FOR_MEMORY is sufficient, i.e. the allocation will succeed as long as pages are available. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35246 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
8a65066a |
|
22-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
vm_soft_fault(): map_page() can fail for B_NO_LOCK areas, since it needs to allocate a page mapping. In that case we do at least have to mark the page not busy again. Furthermore we enforce the minimum page mappings object cache reserve, so we'll have more luck on the next fault. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35241 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
86c794e5 |
|
21-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
slab allocator: * Implemented a more elaborated raw memory allocation backend (MemoryManager). We allocate 8 MB areas whose pages we allocate and map when needed. An area is divided into equally-sized chunks which form the basic units of allocation. We have areas with three possible chunk sizes (small, medium, large), which is basically what the ObjectCache implementations were using anyway. * Added "uint32 flags" parameter to several of the slab allocator's object cache and object depot functions. E.g. object_depot_store() potentially wants to allocate memory for a magazine. But also in pure freeing functions it might eventually become useful to have those flags, since they could end up deleting an area, which might not be allowable in all situations. We should introduce specific flags to indicate that. * Reworked the block allocator. Since the MemoryManager allocates block-aligned areas, maintains a hash table for lookup, and maps chunks to object caches, we can quickly find out which object cache a to be freed allocation belongs to and thus don't need the boundary tags anymore. * Reworked the slab boot strap process. We allocate from the initial area only when really necessary, i.e. when the object cache for the respective allocation size has not been created yet. A single page is thus sufficient. other: * vm_allocate_early(): Added boolean "blockAlign" parameter. If true, the semantics is the same as for B_ANY_KERNEL_BLOCK_ADDRESS. * Use an object cache for page mappings. This significantly reduces the contention on the heap bin locks. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35232 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
15779f70 |
|
20-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
vm_get_page_mapping(): The translation map wasn't locked. For x86 the function is used only in one place and the missing locking would be harmless if it weren't for the per translation map physical page mapper. It is used to map the page table for the lookup. Concurrent access could corrupt its data structures, or, just as bad, the unlocked Query() could remap the page table used by a concurrent Map() or Unmap(), which would then manipulate the wrong page table. Potentially messing up kernel memory, this bug could obviously cause all kinds of kernel crashes and weird behavior. E.g. ticket #5138 is a likely candidate, as are triple faults. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35195 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
c40914bb |
|
19-Jan-2010 |
Rene Gollent <anevilyak@gmail.com> |
Fix build with VM_PAGE_FAULT_TRACING enabled. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35187 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
825566f8 |
|
19-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* 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
|
#
6379e53e |
|
19-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
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
|
#
3632eeed |
|
18-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* 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
|
#
f082f7f0 |
|
15-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* 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
|
#
bcc2c157 |
|
13-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
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
|
#
94632505 |
|
13-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* 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
|
#
a99debff |
|
13-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added TODOs. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35056 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
3b8c056d |
|
11-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
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
|
#
451ca8b4 |
|
11-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
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
|
#
afed2658 |
|
08-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* 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
|
#
aac9b8e4 |
|
08-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
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
|
#
bd0bff44 |
|
07-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
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
|
#
3cd20943 |
|
06-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* 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
|
#
cb8617c1 |
|
05-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
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
|
#
8d9e8ba5 |
|
02-Jan-2010 |
Stephan Aßmus <superstippi@gmx.de> |
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
|
#
16f50e33 |
|
02-Jan-2010 |
Stephan Aßmus <superstippi@gmx.de> |
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
|
#
1021fd28 |
|
01-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* 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
|
#
2e74d74f |
|
22-Dec-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* 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
|
#
1339ccf4 |
|
08-Dec-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* 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
|
#
522c2f19 |
|
07-Dec-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* 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
|
#
bcfdfff4 |
|
06-Dec-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
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
|
#
40cd019e |
|
06-Dec-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* 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
|
#
2c1886ae |
|
04-Dec-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* 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
|
#
38a97b2c |
|
04-Dec-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
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
|
#
f69032f2 |
|
03-Dec-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* 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
|
#
bbd97b4b |
|
03-Dec-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
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
|
#
35d94001 |
|
02-Dec-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* 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
|
#
def9898c |
|
02-Dec-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
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
|
#
f34a1dd5 |
|
02-Dec-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
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
|
#
e50cf876 |
|
02-Dec-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* 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
|
#
90d870c1 |
|
02-Dec-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* 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
|
#
a477e3cf |
|
01-Dec-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Finished renaming of vm_cache to VMCache. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34424 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
a99eb6b5 |
|
01-Dec-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
vm_area -> VMArea git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34423 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
b0db552c |
|
01-Dec-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Renamed vm_address_space to VMAddressSpace. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34422 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
b8a73945 |
|
27-Nov-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* 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
|
#
95235380 |
|
26-Nov-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* Minor clarification. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34307 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ebcdd1fc |
|
07-Nov-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* r33436 broke user_strlcpy() semantics: with a size of 0, "to" can be ignored, and it's still a valid call. * This fixes ktrace_printf() from userland. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33934 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
f1488adb |
|
15-Oct-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* While r33037 fixed the alignment of areas put into reserved areas, it actually broke their placement at the end of the reserved area, which was the main reason #4778 happened so often (it would have been more hidden else). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33598 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
4124f480 |
|
15-Oct-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* Reserved areas would also be created in existing reserved areas in case the space was becoming tight. This actually fixes #4778. * Fixed overflow problem in find_reserved_area(). * Cleaned up the test app, added license. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33597 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d5a396a6 |
|
14-Oct-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* r33037 broke the handling of reserved areas, more specifically, it ignored the RESERVED_AVOID_BASE flag of those, and introduced a way to fill them from the start. This caused #4778. * Turned IS_VALID_SPOT() macro into an inline function. * Removed already resolved TODO comment. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33581 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
44778a8a |
|
11-Oct-2009 |
Michael Lotz <mmlr@mlotz.ch> |
Introduce vm_map_physical_memory_vecs. It is like vm_map_physical_memory but takes a list of iovecs describing the physical pages to be mapped. With it one can map a set of physically disjoint pages into one linear virtual range. This is a private API right now, but we might want to make it public as map_physical_memory_vecs alongside map_physical_memory. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33523 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
aa6f54aa |
|
08-Oct-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Amended the {user,debug}_strlcpy() fix: Due to the strlcpy() semantics to always return the source string length, we can't really prevent an overflow of the source address. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33489 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
8a71915a |
|
05-Oct-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Made the {debug,user}_{mem,strl}cpy() and user_memset() functions deal with address overflows. Apparently at least the x86 string instructions generate a general protection fault instead of a page fault, and we only use the fault handler in the latter case (maybe we should change that, too). Fixes #4714. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33436 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
1bcca32a |
|
11-Sep-2009 |
Michael Lotz <mmlr@mlotz.ch> |
* Also take into account that the alignment due to B_ANY_KERNEL_BLOCK_ADDRESS can cause overflows. * Added a generic IS_VALID_SPOT() macro that checks for overflows and checks if the area will fit with the given constraints. * Use the macro to simplify the places where these checks are necessary. * Use the provided "end" limit instead of the address space end. It currently doesn't matter but makes more sense. * Rename newBase variables to alignedBase as that's what they are. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33061 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
e717a35b |
|
10-Sep-2009 |
Michael Lotz <mmlr@mlotz.ch> |
* Change the way we check for enough available space when searching for spots to insert areas so we don't overflow. * Consequently use the area end (base + size - 1) where appropriate which prevents overflows in a few places. * Properly check for reaching the address space end. * If we've already found a spot we don't need to recheck if we've found one. * Simplify the B_EXACT_ADDRESS checks down to a simpler single if statement instead of the four seperate ones. * Properly calculate the search end for B_EXACT_ADDRESS as well, it's also base + size - 1. * Block the full last page now that this actually works without overflowing. * Some style changes and added spacing. This should now really fix #2550. Previously the overflow protection didn't actually work because on allocation we overflowed and completely missed the protecting area. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33037 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
5332eb40 |
|
09-Sep-2009 |
Michael Lotz <mmlr@mlotz.ch> |
Style fix. I really tried hard, but still failed... git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33034 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
9aff7f15 |
|
09-Sep-2009 |
Michael Lotz <mmlr@mlotz.ch> |
Block the very last page of kernel address space. The problem here is that non of the VM functions handling areas are overflow safe. If an area is created that spans across the last page many places will run into an integer overflow. This mostly concerns the area allocation path in find_and_insert_area_slot() and also vm_create_anonymous_area() where the loop for mapping pages for B_FULL_LOCK areas overflows and runs more times than it should leading to #2550. This could be seen as a workaround. The real fix would be to make everything overflow safe. The thing is that this does also concern the user of the area which could easily have forgotten to check for overflows as well, so I am a bit uneasy with handing out areas that could easily lead to such hard to debug problems. Since this is really an edge case and this single step safes quite a bit of extra checks I'd actually be OK with keeping it that way. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33032 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
3794518c |
|
09-Sep-2009 |
Michael Lotz <mmlr@mlotz.ch> |
Also check for read-protection of an area. Adjusted naming from read-only to write-protected and read-protected. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33031 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
0f4242de |
|
09-Sep-2009 |
Michael Lotz <mmlr@mlotz.ch> |
Implement a vm_block_address_range() function which creates an area with no mapped pages and a non-read and non-write protection to block a certain address range from being used by anything. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33030 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
45ed4939 |
|
05-Aug-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* area_for() now also returns the area ID for kernel areas if they are accessible to the userland - this fixes #2405 (ie. MediaPlayer overlay now works). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32135 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ea2abd11 |
|
02-Aug-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Renamed the ROUNDOWN macro to ROUNDDOWN. Also changed the implementation of ROUNDUP to use '*' and '/' -- the compiler will optimize that for powers of two anyway and this implementation works for other numbers as well. * The thread::fault_handler use in C[++] code was broken with gcc 4. At least when other functions were invoked. Trying to trick the compiler wasn't a particularly good idea anyway, since the next compiler version could break the trick again. So the general policy is to use the fault handlers only in assembly code where we have full control. Changed that for x86 (save for the vm86 mode, which has a similar mechanism), but not for the other architectures. * Introduced fault_handler, fault_handler_stack_pointer, and fault_jump_buffer fields in the cpu_ent structure, which must be used instead of thread::fault_handler in the kernel debugger. Consequently user_memcpy() must not be used in the kernel debugger either. Introduced a debug_memcpy() instead. * Introduced debug_call_with_fault_handler() function which calls a function in a setjmp() and fault handler context. The architecture specific backend arch_debug_call_with_fault_handler() has only been implemented for x86 yet. * Introduced debug_is_kernel_memory_accessible() for use in the kernel debugger. It determines whether a range of memory can be accessed in the way specified. The architecture specific back end arch_vm_translation_map_is_kernel_page_accessible() has only been implemented for x86 yet. * Added arch_debug_unset_current_thread() (only implemented for x86) to unset the current thread pointer in the kernel debugger. When entering the kernel debugger we do some basic sanity checks of the currently set thread structure and unset it, if they fail. This allows certain commands (most importantly the stack trace command) to avoid accessing the thread structure. * x86: When handling a double fault, we do now install a special handler for page faults. This allows us to gracefully catch faulting commands, even if e.g. the thread structure is toast. We are now in much better shape to deal with double faults. Hopefully avoiding the triple faults that some people have been experiencing on their hardware and ideally even allowing to use the kernel debugger normally. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32073 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d3b44ccb |
|
29-Jul-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added explicit physical address parameter to vm_create_anonymous_area() and create_area_etc(). 0 for the default behavior. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31941 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
069b477d |
|
29-Jul-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Introduced CREATE_AREA_DONT_CLEAR create_area_etc() flag, which allows the call to fetch non-clear pages. * B_PHYSICAL_BASE_ADDRESS does now imply B_CONTIGUOUS. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31932 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
4cb7d2e5 |
|
29-Jul-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31915 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
5fbad060 |
|
17-Jul-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* Work-in-progress on a kernel profile service that can be evaluated from userland afterwards. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31621 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
3609af39 |
|
19-Jun-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* Renamed _kern_reserve_heap_address_range() to _kern_reserve_address_range(), and added a _kern_unreserve_address_range() as well. * The runtime loader now reserves the space needed for all its areas first to make sure there is enough space left for all areas of a single image. * This also fixes the final part of bug #4008. * Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31115 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
82db8a9e |
|
19-Jun-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* Added an "unmapAddressRange" argument to the file mapping syscall. This is the first part of making the runtime loader behave itself; it should already make Clockwerk run okay with any number of translators (even if not all of them will work yet). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31113 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
eb0262fc |
|
28-May-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Reworked vm_soft_fault() and friends: - While walking down the cache chain, we keep all upper caches locked. - When we have to unlock -- when waiting for a busy page or reading a page in -- we unlock completely, including the address space, and restart vm_soft_fault(). - Folded fault_get_page() and fault_find_page() into one. This simplifies and improves things considerably: - We no longer need dummy pages. - We no longer need vm_area::no_cache_change. - #2710 is fixed, since we no longer hold the address space lock while waiting. * vm_soft_fault(): When we have found our page, we first check whether a page is already mapped at the address. If it is already our page, we just change its protection. If not, we unmap it first. Fixes race conditions when multiple threads fault at the same address at the same time. * fault_get_page(): When copying a read-only page from a lower cache, no longer mark it active, since at least for the fault area it is shadowed from then on. * vm_set_area_protection(): Fixed potential overflow for in the vm_translation_map::protect() call. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30911 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
6a79745b |
|
27-May-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Disabled the stack traces on unhandled userland page faults. As was already known those can cause a deadlock. Besides, when the debug server is running, it prints an even nicer stack trace. Not removing the code yet to make things easier for architectures on which we don't have a userland yet. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30877 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d5ad7629 |
|
30-Apr-2009 |
Axel Dörfler <axeld@pinc-software.de> |
Fixed several problems of the prefetching code: * Did claim to have reserved pages when calling vm_page_allocate_page(), but didn't have any (copy&paste bug). We cannot use it without reserved pages, as we need to call vm_page_allocate_page() with a cache locked. * No longer use low_resource_state() to determine whether to precache or not, but use the new vm_page_num_used_pages() instead. * Also don't (try to) precache when the cache already has more than 2/3 of its pages to safe some unnecessary work. * The size to precache was limited to the file size incorrectly. * When precaching failed, the cache reference was not released. * The precaching started one page too late, causing bug #3835. * Reenabled precaching. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30515 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
996af6d9 |
|
28-Apr-2009 |
Stephan Aßmus <superstippi@gmx.de> |
Disable pre-fetching until we fix bug #3835. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30477 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
eb2bd0e8 |
|
27-Apr-2009 |
Stephan Aßmus <superstippi@gmx.de> |
axeld: * Implemented a way to do asynchronous pre-fetching when mapping files. * There are slight code duplications in some places that could benefit from cleaning up, but nothing too bad. * Implementing smarter ways to trigger prefetching and more analysis of the situations in the kernel would be nice. Currently up to 10 MB of every mapped file are pre-fetched without further analysis. * The speed improvement is nice for certain operations. On our test system (real hardware), Firefox took 9 seconds from being launched to display a window. Now it takes 5 seconds. Both measurements right after booting. The same system took 35 seconds from launching Haiku in the GRUB menu to displaying the Tracker desktop background image. Now it takes 27 seconds. * We didn't have the chance to check out the effects of this on the CD boot, but potentially, they could speed it up a lot. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30465 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
f9ae64e9 |
|
06-Apr-2009 |
Oliver Tappe <zooey@hirschkaefer.de> |
zooey + bonefish: * optimized unmapping of a single page that was rather inefficient for large areas git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29978 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
defc7c56 |
|
19-Mar-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* One should not rely on the comma operator being evaluated right-to-left as it was done in SAS/C... (yeah, that was ages ago). This fixes bug #2030. * Also, we should probably check if the area we're about to shrink/remove actually is a reserved area. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29605 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
24ace129 |
|
13-Mar-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* Worked over the "area" KDL command to make it more useful, and easier to use. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29503 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
e0b0a173 |
|
11-Mar-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* Cleanup, no functional change. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29478 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
aa4ba93e |
|
08-Mar-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Renamed src/system/kernel/device_manager/io_requests.{h,cpp} to IORequest.{h,cpp}. * Introduced public <io_requests.h> header. Currently it only declares the single function BFS uses. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29446 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
c33667d4 |
|
01-Feb-2009 |
Michael Lotz <mmlr@mlotz.ch> |
Fixing warnings under GCC4 in preparation to enable -Werror there as well: * Replaced the use of offsetof() for structs that aren't PODs. Add a offset_of_member() macro to util/khash.h because that's what it's used for in our cases. * Change the signature of add_debugger_command()/remove_debugger_command() on GCC > 2 to avoid the depricated conversion from string constants to char *. * Adding some "suggested" parenthesis. I know that not everyone likes that, but it pointed out at least one bug that is fixed here as well. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29113 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
b2cfc2b1 |
|
23-Oct-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Added kernel tracing for page faults. * vm_clone_area() does now set the B_SHARED_AREA flag on both the source and the cloned area. This is necessary, since it would no longer be guaranteed that areas are backed by leaf caches only (after fork()ing), which doesn't work with our cache merging strategy. Fixes #2605. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28296 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
59dbd26f |
|
20-Oct-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Moved more debug macros to kernel_debug_config.h. * Turned the checks for all those macros to "#if"s instead of "#ifdef"s. * Introduced macro KDEBUG_LEVEL which serves as a master setting. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28248 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
1894a0a9 |
|
20-Oct-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Consistently use KDEBUG. It is always defined and therefore must be checked with "#if". git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28247 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
47c40a10 |
|
19-Oct-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Prefixed memset_physical() and memcpy_to_physical() with "vm_", added vm_memcpy_from_physical() and vm_memcpy_physical_page(), and added respective functions to the vm_translation_map operations. The architecture specific implementation can now decide how to implement them most efficiently. Added generic implementations that can be used, though. * Changed vm_{get,put}_physical_page(). The former no longer accepts flags (the only flag PHYSICAL_PAGE_DONT_WAIT wasn't needed anymore). Instead it returns an implementation-specific handle that has to be passed to the latter. Added vm_{get,put}_physical_page_current_cpu() and *_debug() variants, that work only for the current CPU, respectively when in the kernel debugger. Also adjusted the vm_translation_map operations accordingly. * Made consequent use of the physical memory operations in the source tree. * Also adjusted the m68k and ppc implementations with respect to the vm_translation_map operation changes, but they are probably broken, nevertheless. * For x86 the generic physical page mapper isn't used anymore. It is suboptimal in any case. For systems with small memory it is too much overhead, since one can just map the complete physical memory (that's not done yet, though). For systems with large memory it counteracts the VM strategy to reuse the least recently used pages. Since those pages will most likely not be mapped by the page mapper anymore, it will keep remapping chunks. This was also the reason why building Haiku in Haiku was significantly faster with only 256 MB RAM (since that much could be kept mapped all the time). Now we're using a different strategy: We have small pools of virtual page slots per CPU that are used for the physical page operations (memset_physical(), memcpy_*_physical()) with CPU-pinned thread. Furthermore we have four slots per translation map, which are used to map page tables. These changes speed up the Haiku image build in Haiku significantly. On my Core2 Duo 2.2 GHz 2 GB machine about 40% to 20 min 40 s (KDEBUG disabled, block cache debug disabled). Still more than factor 3 slower than FreeBSD and Linux, though. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28244 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
901f1930 |
|
17-Oct-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Moved memset_physical() to vm.cpp and made it available in the kernel. * Added memcpy_to_physical(). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28219 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
1b6eff28 |
|
11-Oct-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Replaced the vm_get_physical_page() "flags" PHYSICAL_PAGE_{NO,CAN}_WAIT into an actual flag PHYSICAL_PAGE_DONT_WAIT. * Pass the flags through to the chunk mapper callback. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27979 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d654f56a |
|
11-Oct-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Added kernel tracing for the page daemon and the page writer. * Added some commented out debug output in vm.cpp. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27971 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
4eaa43ac |
|
11-Oct-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Added "flags" parameter to VMCache::Read(). * Use the new VMCache::Read() flags parameter to directly read into the physical page in the page fault handler instead of mapping it first. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27966 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
4129f846 |
|
08-Oct-2008 |
François Revol <revol@free.fr> |
- add team id on a TRACE() - try to accomodate for low ram systems by making the first kernel heap allocation smaller git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27943 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
7805eb0c |
|
27-Sep-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Changed the handling for hardware-caused terminal signals: * No longer send a SIGKILL when a page fault occurred, there was no signal handler, and the debugger told us to continue as usual. Instead we send a SIGSEGV. Instead in handle_signal() when not in the main thread and there's no handler for the signal, we first send the main thread a SIGKILL before letting the thread die. So in cases where the main thread caused an unhandled page fault, the team will die from the SIGSEGV, now. This fixes bug #2773. * For the other hardware-caused signals we do now do the same as in case of page faults, i.e. we first check whether the thread has a handler for the signal in question. If so, we don't notify the debugger, but send the signal right away. * B_GENERAL_PROTECTION_FAULT is translated to SIGILL now. Seems better than SIGKILL. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27757 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
1cd8c4cc |
|
26-Sep-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Let the boot loader set the kernel image's name. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27754 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
0dc4d1e5 |
|
26-Sep-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Reverted r27685, r27676, r27665, and r27664, the changes related to letting the boot loader provide full paths for the pre-loaded images. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27753 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
b34e395e |
|
21-Sep-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
The boot loader does now set the names of the images it loads to the full paths. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27665 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ca7cb625 |
|
17-Sep-2008 |
Axel Dörfler <axeld@pinc-software.de> |
* Implemented a (private for now) get_system_info_etc() call, that can retrieve various system information. * Implemented retrieving some VM stats via this call. * The VM now maintains a page fault counter, and sets system_info::page_faults accordingly. * Added a (pretty simple) "vmstat" command line app. * Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27597 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
6f3ee1f1 |
|
08-Sep-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
When mapping a file into memory we do now immediately map all active pages into the team's address space. Doing that is relatively cheap and saves later page faults. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27380 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
1e906305 |
|
21-Aug-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Added a "flags" parameter to vm_create_anonymous_area() and create_area_etc(). * When the new flag CREATE_AREA_DONT_WAIT is specified, the functions don't wait for memory or pages to become available. They fail immediately instead. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27117 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
1cda5944 |
|
20-Aug-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added object_cache_set_minimum_reserve() which sets the minimal number of free objects an object cache should try to have ready. If the number of free objects drops below the threshold, a new urgent priority thread is asked to asynchronously resize the object cache (pretty similar to the heap grower thread). Such a mechanism is necessary for code paths that are supposed to free pages, but may need memory themselves (like the swap support). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27100 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
90cd1b25 |
|
08-Aug-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
vm_remove_all_page_mappings(): Decrement the mapped pages count only, if the page was really mapped before. Fixes bug #2585. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26876 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
a9d7be07 |
|
07-Aug-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Implemented mprotect(). A vm_area does now have an optional array specifying the protection of each page (4 bits per page). * Added no-op implementation of posix_madvise(). * Replaced a few "addr_t size" parameters by "size_t size". git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26871 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
3394ebd3 |
|
06-Aug-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Improved some output and coding style. * If a segment violation occurs, we do now check whether the thread in question has a handler for SIGSEGV. If so, we just send it the signal. Otherwise we notify the debugger as before. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26851 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
8d12bd13 |
|
05-Aug-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Moved the incrementing/decrementing of vm_page::wired_count into dedicated functions. * Introduced gMappedPagesCount variable which counts the total number of physical pages that are mapped. * Added vm_page_get_stats() which fills in the memory related part of the system_info structure. Used and cached pages are computed differently, now. The "available" (== not committed) memory is no longer used for the computation as it doesn't say anything about the actually used/free pages (with swap support enabled it is even less meaningful, since we first commit swap space when possible). We do also consider the memory used by the block cache as cached pages, now. All in all these changes should fix the memory statistics reported by get_system_info(), IOW bug #2574. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26837 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
57f2b5a0 |
|
05-Aug-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Changed the meaning of the {KERNEL,USER}_STACK_SIZE macros to not include the guard pages. Adjusted the kernel and boot loader code accordingly -- the guard pages size is added/not removed respectively. The stack size passed to _kern_spawn_thread() is now the actually usable size, and it is no longer possible to specify a size smaller than or equal to the guard pages size. * vm_create_anonymous_area(): Precommit two pages maximum -- a stack with only one page usable size obviously doesn't need two pages. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26819 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
39ec9b48 |
|
03-Aug-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
vm_page_fault(): Only put the address space, if we actually got one. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26774 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
c421c138 |
|
02-Aug-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
vm_create_anonymous_area(): * Moved reservation of memory for the "locked" cases upfront. Particularly if the would-be area is a kernel area, we don't want the address space to be write locked while doing that, since that would block the low memory handler. * For full lock areas the pages are reserved upfront, too. The reasoning is similar. Reserve the pages needed by the translation map backend for mapping the area pages there too. * Moved the cache locking/unlocking out of the individual cases. All want to have the cache locked the whole time, now. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26741 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
27245755 |
|
02-Aug-2008 |
Axel Dörfler <axeld@pinc-software.de> |
* Renamed kernel_startup to gKernelStartup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26731 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
e6f3de9a |
|
31-Jul-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added TODO -- food for thoughts. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26711 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
4aeadff0 |
|
26-Jul-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Removed pointless check. vm_page_allocate_page() only returns NULL, when an invalid page state was supplied. The comment was misleading too, as the pages weren't reserved upfront. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26650 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
7a9d5c2e |
|
25-Jul-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added TODOs in lock_memory_etc. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26629 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
2dad5fa7 |
|
24-Jul-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Added "boolean getNewReference" parameter to the vm_address_space* versions of the AddressSpaceReadLocker constructor and SetTo(). When true it will get a new reference to the address space. * Changed vm_soft_fault(): Now it gets the address space as a parameter (for page faults getting it happens in vm_page_fault()). This should fix lock_memory_etc() for other teams -- it used the correct address space before, but the invoked vm_soft_fault() always used the current team's address space. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26628 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
c586076d |
|
24-Jul-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Patch by Zhao Shuai with changes by myself: * Init swap support in main(). * Added "bool swappable" parameter to VMCacheFactory::CreateAnonymousCache(). A cache supporting swapping is created when true. Adjusted invocations accordingly. * The page writer does now write non-locked swappable pages (when memory is low). * Fixed header guard of VMAnonymousNoSwapCache.h. * Swap support is compiled conditionally, controlled by the ENABLE_SWAP_SUPPORT in src/system/kernel/vm/VMAnonymousCache.h. It is disabled ATM. Since no swap files are added, it wouldn't have much effect anyway. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26625 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
6e60a6ac |
|
23-Jul-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added function get_memory_map_etc() which works similar to get_memory_map(), but has a saner semantics and allows specifying a team. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26600 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
b4395038 |
|
23-Jul-2008 |
Axel Dörfler <axeld@pinc-software.de> |
* Replaced the sAreaHashLock with an rw_lock. * As this was the last user of the READ_COUNT/WRITE_COUNT definitions in vm_priv.h, I removed those as well. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26582 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
e6bd90c5 |
|
23-Jul-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* bfs_fsync() was the only place which could cause the fs_vnode_ops::write_pages() to be called with fsReenter = true. Since this is no longer the case, the argument has become superfluous. For read_pages() it always was. Removed the argument from the functions and all functions that propagated it. * Some whitespace at the end of lines was removed. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26579 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
4ed05c68 |
|
23-Jul-2008 |
Axel Dörfler <axeld@pinc-software.de> |
* Replaced the simplistic semaphore based R/W lock in the vm_address_space with the new rw_lock locking primitive. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26578 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
5c99d639 |
|
22-Jul-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Merged branch haiku/branches/developer/bonefish/vm into trunk. This introduces the following relevant changes: * VMCache: - Renamed vm_cache to VMCache, merged it with vm_store and made it a C++ class with virtual methods (replacing the store operations). Turned the different store implementations into subclasses. - Introduced MergeStore() callback, changed semantics of Commit(). - Changed locking and referencing semantics. A reference can only be acquired/released with the cache locked. An unreferenced cache is deleted and a mergeable cache merged when it is unlocked. This removes the "busy" state of a cache and simplifies the page fault code. * Added VMAnonymousCache, which will implement swap support (work by Zhao Shuai). It is not integrated and used yet, though. * Enabled the mutex/recursive lock holder asserts. * Fixed DoublyLinkedList::Swap(). * Generalized the low memory handler to a low resource handler. And made semaphores and reserved memory handled resources. Made vm_try_resource_memory() optionally wait (with timeout), and used that feature to reserve memory for areas. ... git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26572 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
df1b333a |
|
18-Jul-2008 |
Axel Dörfler <axeld@pinc-software.de> |
No wethers in here anymore. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26487 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
6db6b628 |
|
16-Jul-2008 |
Axel Dörfler <axeld@pinc-software.de> |
* Added B_PHYSICAL_BASE_ADDRESS address specification for anonymous areas. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26456 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
736352dc |
|
16-Jul-2008 |
Axel Dörfler <axeld@pinc-software.de> |
* Added [un]lock_memory_etc() versions that accept a team_id as first argument. This allows drivers to lock the memory outside of the original team context. * create_area_etc() got a struct team as first argument, but that should have been a team_id. * Removed delete_area_etc() - there is already vm_delete_area() doing the same thing. * Renamed vm_get_address_space_by_id() to vm_get_address_space(), as there is no other method of getting an address space. * Removed erroneous white space. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26455 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
b64e66fb |
|
08-Jul-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Changes related to the "caches" command: * The table used for sorting the caches could be too small for the number of caches in the system. We never checked that, which could cause a crash or triple faults when invoking the command. * We now allocate the table as an area. Also increased the table size to 102400 entries. * Also print the committed memory for non-RAM caches, if they are the root cache of a cache tree that has committed memory. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26333 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
e5f7642c |
|
04-Jul-2008 |
Michael Lotz <mmlr@mlotz.ch> |
Remove a few unused variables. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26249 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
b8a66215 |
|
04-Jul-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
fault_find_page(): When the source of the top cache is busy, we may find our own dummy page. This is equivalent to not finding a page at all. Fixes #2471. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26248 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
af637076 |
|
04-Jul-2008 |
Michael Lotz <mmlr@mlotz.ch> |
* Avoid calling vm_unreserve_memory() if there is no change in the commited size. Removes a bit of overhead (call and mutex_lock / mutex_unlock). * Don't fail if there is exactly enough memory available to satisfy the reserve request. Not that it would really matter as it's rather an edge case... git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26246 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d9a109d8 |
|
29-Jun-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
"caches" also prints the total number of pages assigned to caches and the total amount of committed memory. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26165 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
e1b630c5 |
|
28-Jun-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Replaced the global cache pages hash table by an IteratableSplayTree per cache. * Changed the strategy vm_cache_acquire_page_cache_ref() uses to ensure that the cache isn't deleted while trying to get a reference. Instead of the global cache pages hash table lock, it holds the global cache list lock now. We acquire + release this lock in delete_cache() after removing all pages and just before deleting the object. * Some small optimizations using the property that the cache's pages are ordered, now (vm_cache_resize(), vm_page_write_modified_page_range(), vm_page_schedule_write_page_range()). * Replaced some code counting a cache's pages by simply using vm_cache::page_count. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26160 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
df7096a4 |
|
18-Jun-2008 |
Michael Lotz <mmlr@mlotz.ch> |
* Added malloc_nogrow() function that does allocation without triggering or waiting for a heap grow. * Use that nogrow version in the VM code to avoid a deadlock with the address space lock when a grow operation would try to create an area while a malloc happened from such a function in the VM. * When waiting for a grow to happen, notify the waiting thread from the grower also if it failed to allocate a new heap. Otherwise a thread would just sit there and wait until another thread requested growing too and that one succeeded (or just forever in the worst case). * Make the dedicated grow heap growable too. If the current grow heaps run low on memory it will instruct the grower to allocate a new grow heap. This reduces the likelyhood of running out of memory with no way to grow to a minimum. As the growing is done asynchronously it is still possible to happen, but it is highly unlikely as the grow heap is solely used to allocate memory in the process of creating new heap areas and it will even try using normal public memory if the dedicated memory has run out. * Reduced the dedicated grow heap from 2 to 1MB. As it can now grow itself, it doesn't need to last so long. * Extract heap creation into it's own function that does area creation and heap attach and use this function for growing normal and grow heaps. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26009 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
f5b3a6a7 |
|
05-Jun-2008 |
Michael Lotz <mmlr@mlotz.ch> |
* Initialize all static mutexes in the kernel through a MUTEX_INITIALIZER() and remove the then unneeded mutex_init() for them. * Remove the workaround for allowing uninitialized mutexes on kernel startup. As they are all initialized statically through the MUTEX_INITIALIZER() now this is not needed anymore. * An uninitialized mutex will now cause a panic when used to find possibly remaining cases. * Remove now unnecessary driver_settings_init_post_sem() function. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25812 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
0e82c8d5 |
|
27-May-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Improved the "caches" command: * List the sum of pages used by a cache tree in the line printed for the root cache. * Also print the amount of committed memory per cache (and the sum for the tree), and allow sorting the list by it ("-c" switch). * Added usage text. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25675 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
6607b17d |
|
23-May-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Pimped up the "caches" command. Now it prints the caches in trees with additional info (offset, size, used pages, areas), sorting the trees by used pages. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25633 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
fe8878fa |
|
23-May-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Implemented unmapping of partial areas (mmap()/munmap()). Review welcome. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25629 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
0f448d21 |
|
22-May-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Added vm_page_write_modified_page_range(), which is similar to vm_page_write_modified_pages(), save that it only writes pages in the given range. * Added vm_page_schedule_write_page_range() which schedules all modified pages in the given cache's range for writing by the page writer. * Added _kern_sync_memory() syscall and the msync() POSIX function. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25620 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
7da0a81c |
|
21-May-2008 |
Axel Dörfler <axeld@pinc-software.de> |
Patch by Jan Klötzke (with additional TODO comments): * Add a "fault_callback" to the thread structure which is called when a unhandled page fault happens in user space. A SIGSEGV will only be sent if the callback returns "true". git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25609 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
54153234 |
|
13-May-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Fixed build with tracing turned on. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25483 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
58148e2e |
|
11-May-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added new private area protection flag B_KERNEL_AREA, which prevents all changes to the area (delete, resize, clone) from userland. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25450 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d59239b3 |
|
09-May-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Also align the given size to pages when unmapping memory. Fixes munmap() for non-aligned sizes. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25399 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
06b580d7 |
|
08-May-2008 |
Axel Dörfler <axeld@pinc-software.de> |
Replaced the sAvailableMemoryLock benaphore with a mutex. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25379 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
7cbf8fdd |
|
07-May-2008 |
Axel Dörfler <axeld@pinc-software.de> |
First part of the vm86 work by Jan Klötzke: * Allow userland teams to create areas below 1 MB when requested specifically. * Note, this is a temporary solution - see the comments in the code. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25358 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
0c615a01 |
|
01-May-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Removed old mutex implementation and renamed cutex to mutex. * Trivial adjustments of code using mutexes. Mostly removing the mutex_init() return value check. * Added mutex_lock_threads_locked(), which is called with the threads spinlock being held. The spinlock is released while waiting, of course. This function is useful in cases where the existence of the mutex object is ensured by holding the threads spinlock. * Changed the two instances in the VFS code where an IO context of another team needs to be locked to use mutex_lock_threads_locked(). Before it required a semaphore-based mutex implementation. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25283 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
184de764 |
|
30-Apr-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Replaced the vm_cache mutex by a cutex. This should save quite a few semaphores. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25277 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
6cef245e |
|
22-Apr-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Detemplatized ConditionVariable{Entry}. Merged them with their respective Private* base class. * Changed sigwait() and sigsuspend() to use thread_block() instead of a condition variable. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25100 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
3cf7ecd1 |
|
13-Apr-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Added <sys/mman.h> header. It declares only mmap() and munmap() yet and defines the macros needed by them. * Renamed syscall sys_vm_map_file() to _kern_map_file() and changed the path to an FD parameter. Changed vm_map_file() accordingly and adjusted the kernel ELF loader and the runtime loader. * Added syscall _kern_unmap_memory(). * Added bool unmapAddressRange parameter to vm_create_anonymous_area() and map_backing_store(). If true and the address specification is B_EXACT_ADDRESS, all areas in the specified address range will be deleted (unless an area is covered only partially). * Introduced B_SHARED_AREA flag, which is set on areas that have been created by {vm,_user}_map_file() with REGION_NO_PRIVATE_MAP. When fork()ing those areas won't be copied CoW, but rather be cloned. This is needed for mmap() MAP_SHARED. * {vm,_user}_map_file() also accept an FD argument < 0, in which case an anonymous area is created. * Implemented mmap() and munmap(). Currently there's the restriction that we can't partially unmap areas. Otherwise the functions should be rather compliant. We also support the non-POSIX extension MAP_ANONYMOUS. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24964 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
9583c41d |
|
05-Apr-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added TODO regarding potential deadlock. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24820 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
6b536693 |
|
01-Apr-2008 |
Axel Dörfler <axeld@pinc-software.de> |
* Renamed vm_get_available_memory() to vm_available_memory() to fit better into our usual naming scheme. * Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24745 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
c32f7874 |
|
26-Mar-2008 |
Axel Dörfler <axeld@pinc-software.de> |
* Added new KDL command "string" that dumps a string given a pointer. * Use parse_expression() where appropriate. * Removed extraneous white space. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24593 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
41f8d416 |
|
25-Mar-2008 |
Axel Dörfler <axeld@pinc-software.de> |
Applied patch by Rene Gollent: * Add a cached_pages field to the system_info structure, and change the meaning of the used_pages field to not include cached pages. * Provide the needed info using the new calls vm_get_available_memory(), and vm_page_num_available_pages(). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24571 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
00265801 |
|
20-Mar-2008 |
Rene Gollent <anevilyak@gmail.com> |
Leave tracing disabled by default though. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24497 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
7f9a9ff6 |
|
20-Mar-2008 |
Rene Gollent <anevilyak@gmail.com> |
Fix broken TRACE statement. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24496 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
4495cd43 |
|
20-Mar-2008 |
Axel Dörfler <axeld@pinc-software.de> |
* Fixed warnings, mostly due to NULL changes. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24487 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d1189f0b |
|
08-Mar-2008 |
Michael Lotz <mmlr@mlotz.ch> |
Naive implementation of transfer_area(). It follows the suggested sematics of the resolved ToDo, but could probably be made more efficient. Instead of transfering the area, the area is cloned into the target teams' address space and the original is deleted. This generates a new area_id for the transfered area (as suggested by the ToDo). Updated syscall prototypes according to the status_t to area_id return type change. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24320 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
5c4d1c5e |
|
10-Feb-2008 |
Michael Lotz <mmlr@mlotz.ch> |
Complete rework of the heap implementation. Freelists are now part of the pages and pages are now kept in lists as well. This allows to return free pages once a bin does not need them anymore. Partially filled pages are kept in a sorted linked list so that allocation will always happen on the fullest page - this favours having full pages and makes it more likely lightly used pages will get completely empty so they can be returned. Generally this now goes more in the direction of a slab allocator. The allocation logic has been extracted, so a heap is now simply attachable to a region of memory. This allows for multiple heaps and for dynamic growing. In case the allocator runs out of free pages, an asynchronous growing thread is notified to create a new area and attach a new heap to it. By default the kernel heap is now set to 16MB and grows by 8MB each time all heaps run full. This should solve quite a few issues, like certain bins just claiming all pages so that even if there is free space nothing can be allocated. Also it obviously does aways with filling the heap page by page until it overgrows. I think this is now a well performing and scalable allocator we can live with for quite some time. It is well tested under emulation and real hardware and performs as expected. If problems come up there is an extensive sanity checker that can be enabled by PARANOID_VALIDATION that covers most aspects of the allocator. For normal operation this is not necessary though and is therefore disabled by default. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23939 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
9835c090 |
|
07-Feb-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added a boolean "force" parameter to thread_yield(). When true, the function has the old behavior. When false, it just calls the scheduler without any priority adjustment or other stuff. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23906 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
72f7b290 |
|
23-Jan-2008 |
Stephan Aßmus <superstippi@gmx.de> |
Limit the number of stack frames we print. Infinite recursions or, even worse, cyclic stack frames would be seriously annoying. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23712 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
c6ee79ce |
|
16-Jan-2008 |
Axel Dörfler <axeld@pinc-software.de> |
* vm_create_anonymous_area() now accepts B_ANY_KERNEL_BLOCK_ADDRESS. * As a temporary work-around for the current slab allocator's area usage, I added the CACHE_LARGE_SLAB flag, which will force the allocator to use larger areas. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23564 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
abf34add |
|
16-Jan-2008 |
Axel Dörfler <axeld@pinc-software.de> |
* B_ANY_KERNEL_BLOCK_ADDRESS now aligns the memory on the next power of two value greater or equal its size (actually untested, but at least Haiku still boots with these changes :-)). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23563 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
c87ef6db |
|
15-Jan-2008 |
Axel Dörfler <axeld@pinc-software.de> |
Made Haiku behave better when you have more memory: * with 1 GB or more, the semaphore limit is now 131072 instead of 65536. * double the heap when there is 1 GB or more (64 MB). * the low memory handler now also watches semaphore usage; in the end, we need a low resource handler, not a low memory handler. * create_sem_etc() no longer calls vfs_free_unused_vnodes() directly as this could actually deadlock (at least because the address space is a R/W lock, not a recursive lock). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23538 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
7ce6a420 |
|
11-Dec-2007 |
Michael Lotz <mmlr@mlotz.ch> |
Make the initial size of the slab depend on the CPU count. This avoids running out of initial space with more than two CPUs. I haven't fully tracked down the usage of this space, probably it is used to allocate some per CPU construct. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23115 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
3d268eda |
|
10-Nov-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* Extracted file_map API out of the file cache - it's now an optional service that can be used by file systems. * Changed the way the file cache works: instead of reading/writing to the underlying device directly, it can now be used for any data source, ie. also network file systems. * As a result, the former pages_io() moved to the VFS layer, and can now be called by a file system via {read|write}_file_io_vec_pages() (naming suggestions are always welcomed :-)). It now gets an FD, and uses that to communicate with the device (via its fs_{read|write}_pages() hooks). * The file_cache_{read|write}() functions must now be called without holding an I/O relevant file system lock. That allows the file cache to prepare the pages without colliding with the page writer, IOW the "mayBlock" flag can go into the attic again (yay!). * This also results in a much better performance when the system does I/O and is low on memory, as the page writer can now finally write back some pages, and that even without maxing out the CPU :) * The API changes put slightly more burden on the fs_{read|write}_pages() hooks, but in combination with the file_map it's still pretty straight forward. It just will have to dispatch the call to the underlying device directly, usually it will just call its fs_{read|write}_pages() hooks via the above mentioned calls. * Ported BFS and FAT to the new API, the latter has not been tested, though. * Also ported the API changes to the fs_shell. I also completely removed its file cache level page handling - the downside is that device access is no longer cached (ie. depends on the host OS now), the upside is that the code is greatly simplified. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22886 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
90f87904 |
|
23-Oct-2007 |
François Revol <revol@free.fr> |
Some m68k fixes. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22692 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
215a91d1 |
|
11-Oct-2007 |
Axel Dörfler <axeld@pinc-software.de> |
No need to print and try NULL at all. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22505 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
013f781f |
|
10-Oct-2007 |
Axel Dörfler <axeld@pinc-software.de> |
vm_test_map_{modification|activation}(), vm_clear_map_flags(), and 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
|
#
477c9d1d |
|
09-Oct-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* vm_set_area_protection() would remap the whole area instead of just the page 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
|
#
80f54692 |
|
06-Oct-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* struct vnode is an opaque type now, removed void* where it was used incorrectly. * Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22461 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
0e183340 |
|
06-Oct-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* Mapping a page might actually need memory - since we usually have locks that 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
|
#
9d8c2090 |
|
04-Oct-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* vm_remove_all_page_mappings() now returns an accumulation of the flags of 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
|
#
3e9513aa |
|
03-Oct-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* fs_{write|read}_pages() now has an additional argument "mayBlock". * 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
|
#
b062823d |
|
29-Sep-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* register_low_memory_handler() was called too early by several kernel 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
|
#
a6778735 |
|
28-Sep-2007 |
Axel Dörfler <axeld@pinc-software.de> |
bonefish+axeld: * We now have a page writer that takes some pages from the modified queue and writes it back every few seconds. It can be triggered by the page scanner to do that more often, though. That mechanism can be greatly improved once we have our I/O scheduler working. * Removed vm_page_write_modified_page() again - it was all "eaten up" by the page writer. * Reworked vm_page_write_modified_pages() a bit: it now uses vm_test_map_modification() and vm_clear_map_flags() instead of the iterating over all areas which wouldn't even work correctly. The code is much simpler now, too. * You usually put something to the tail of a queue, and remove the contents from the head, not vice versa - changed queue implementation to reflect this. * Additionally, there is now a enqueue_page_to_head() if you actually want the opposite. * vm_page_requeue() allows you to move a page in a queue to the head or tail. * Replaced vm_clear_map_activation() with vm_clear_map_flags() which allows you to clear other flags than PAGE_ACCESSED. * The page scanner dumps now some arguments with each run. * Removed the old disabled pageout_daemon() from NewOS. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22348 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
e6dc7903 |
|
26-Sep-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* vm.h no longer includes vm_types.h - only those that actually need access to the private VM types are including vm_types.h now. * Removed vm_page, vm_area, vm_cache, and vm_address_space typedefs; it's cleaner this way, and the actual types are only used in C++ files now, anyway. * And that caused changes in many files... * Made commpage.h self-containing. * Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22329 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
8692ec02 |
|
26-Sep-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* Renamed vm_page_write_modified() to vm_page_write_modifed_pages() and introduced a new vm_page_write_modified_page(). * Resolved a TODO: vm_page_write_modified_pages() did not mark a to be written page busy but unlocked its cache which could let someone else steal that page in the mean time. * Moved the logic when to move a page to the active or inactive queue to a new function move_page_to_active_or_inactive_queue(). * Moved page_state_to_string() to vm_page(); it's now also used by the "page" and "page_queue" KDL commands. * Made the output of the "page_queue list" command more useful. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22323 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
8e0f884c |
|
26-Sep-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* Since the page scanner and thief can work more effectively when no vm_caches are locked, there is now a vm_page_reserve_pages() call to ensure upfront that there is a page for me when I need it, and may have locked some caches. * The vm_soft_fault() routine now makes use of that feature. * vm_page_allocate_page() now resets the vm_page::usage_count, so that the file cache does not need to do this in read_chunk_into_cache() and write_chunk_to_cache(). * In cache_io() however, it need to update the usage_count - and it does that now. Since non-mapped caches don't have mappings, the page scanner will punish the cache pages stronger than other pages which is accidently just what we want. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22319 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
6d4aea47 |
|
25-Sep-2007 |
Axel Dörfler <axeld@pinc-software.de> |
bonefish+axeld: * Removed the vm_cache/vm_store ref_count duality that besides being a bit ugly also created the page dameon cache retrieval problem: now, only areas (and cache consumers) retrieve a reference to the store (and therefore, the vnode). The page daemon doesn't need to care about this at all anymore, and the pseudo references of the vm_cache could be removed again. * Rearranged deletion of vnodes such that its ID can be reused directly after fs_remove_vnode() has been called. * vm_page_allocate_page() no longer panics when it runs out of pages, but just waits for new pages to become available using the new sFreeCondition condition variable - to make sure this happens in an acceptable time frame, it'll trigger a run of the low memory handlers. * Implemented a page_thief() that steals inactive pages from caches and puts them into the free queue. It runs as a low memory handler. * The file cache now sets the usage count on the pages it inserts into the cache (needs some rework though, cache_io() doesn't do it yet). * Instead of panicking, the kernel will currently dead lock in low memory situations, since BFS does a bit too much in bfs_release_vnode(). * Some minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22315 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
8c657126 |
|
25-Sep-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* Removed unused vm_page::busy_{reading|writing} fields. * Fixed vm_page_allocate_page_run(): it did not take the pageState into account, and would therefore return uninitialized memory (ie. B_CONTIGUOUS areas would contain garbage). Now, it stores if a page is cleared in a new vm_page::is_cleared field. * Some cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22306 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
87689e25 |
|
03-Sep-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* sMappingLock is now a mutex instead of a spinlock. * The vm_translation_map is now correctly held in all of the vm_ mapping functions. * Removed the old vm_daemons.c file - there is now a new vm_daemons.cpp which contains the beginnings of our new page daemon. So far, it's pretty static and not much tested. What it currently does is to rescan all pages in the system with a two-handed clock algorithm and push pages into the modified and inactive lists. * These inactive pages aren't really stolen yet, even though their mappings are removed (ie. their next access will cause a page fault). This should slow down Haiku a bit more, great, huh? :-) * The page daemon currently only runs on low memory situations, though. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22156 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d2056c99 |
|
02-Sep-2007 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Added "caches" debugger command (to be enable by defining DEBUG_CACHE_LIST) that prints an unspectacular list of pointers to all existing caches. Feel free to extend. * Enhanced MultiAddressSpaceLocker: - It supports choosing between read and write lock per address space, now. - Added AddAreaCacheAndLock(), which adds the address spaces of all areas that are attached to a given area's cache, locks them, and locks the cache. It makes sure that the area list didn't change in the meantime and optionally also that all areas have their no_cache_change flags cleared. * Changed vm_copy_on_write_area() to take a cache instead of an area, requiring it to be locked and all address spaces of affected areas to be read-locked, plus all areas' no_cache_change flags to be cleared. Callers simply use MultiAddressSpaceLocker:: AddAreaCacheAndLock() to do that. This resolves an open TODO, that the areas' base, size, and protection fields were accessed without their address spaces being locked. * vm_copy_area() does now always insert a cache for the target area. Not doing that would cause source and target area being attached to the same cache in case the target protection was read-only. This would make them behave like cloned areas, which would lead to trouble when one of the areas would be changed to writable later. * Fixed the !writable -> writable case in vm_set_area_protection(). It would simply change the protection of all mapped pages for this area, including ones from lower caches, thus causing later writes to the area to be seen by areas that shouldn't see them. This fixes a problem with software breakpoints in gdb. They could cause other programs to be dropped into the debugger. * resize_area() uses MultiAddressSpaceLocker::AddAreaCacheAndLock() now, too, and could be compacted quite a bit. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22152 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
22e95c59 |
|
31-Aug-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* creating (or dividing) reserved areas did not acquire a ref to an address space - but they were released upon deletion. It's probably not really needed, but now all reserved areas also grab a reference to their address space. * Rearranged team tear down to be a bit more sane: the I/O context is removed first (where semaphores/areas/ports/whatever might still be used), and the address space is deleted last. * delete_area() can now remove its address space reference again (due to the two changes above), and therefore fixes bug #1374. * cleaned up vm_address_space.c a bit (no functional change there, though). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22130 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
9d22ffbe |
|
20-Aug-2007 |
Axel Dörfler <axeld@pinc-software.de> |
Fixed bug #1413: * vm_soft_fault() no longer touches the page source cache in case fault_get_page() failed. * fault_find_page() now unlocks and releases the cache if reading in a page failed. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22016 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
066a5574 |
|
15-Aug-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* vm_soft_fault() no longer sets all pages it touches to "active"; instead, it now honours if the page was already in the "modified" list before. Also, the source page (which is either mapped directly or copied to the target page) is no longer marked busy before its final destiny is decided (it didn't have any effect, anyway, since we had its cache locked for the whole time, but it now preserves the modified state). This fixes bug #1369. * vm_cache_write_modified() now filters out temporary caches (it's currently called on area deletion). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21971 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
5c806b5d |
|
12-Aug-2007 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
map_backing_store() would deadlock in error case for REGION_PRIVATE_MAP. Closes #1379. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21914 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
279c6b76 |
|
09-Aug-2007 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Use condition variables when waiting for busy pages or busy caches. * Removed a few instances where the page state was set busy directly after allocating it. This is a no-op, since a page is always busy after allocation. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21875 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
a2057fac |
|
08-Aug-2007 |
Axel Dörfler <axeld@pinc-software.de> |
Since get_memory_map() can run with interrupts turned off, it can't put up it's reference to the vm_address_space - luckily, it doesn't even need a reference, since it always runs in the current address space, which cannot go away for obvious reasons. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21865 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
69bee56c |
|
08-Aug-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* get_memory_map() leaked vm_address_space references * fixes a dead lock in vm_soft_fault() - the locking scheme enforces you to lock the address space before a vm_cache, not the other way, around. Since we need to lock the cache that has our page in fault_get_page(), we violated that scheme by relocking the address space in order to get access to the vm_area. Now, we read lock the address space during the whole page fault; added a TODO that explains why this might not really be desirable, if we can avoid it (the only way would be to reverse that locking scheme which would potentially cause the more busy vm_cache locks to be held longer). * vm_copy_area() uses the MultiAddressSpaceLocker, but actually forget to call Lock() on it... * delete_area() leaks vm_address_space references - but fixing this currently causes other problems to be investigated; I'll open a bug for that. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21862 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
5af1dda7 |
|
07-Aug-2007 |
Axel Dörfler <axeld@pinc-software.de> |
bonefish+axeld: * Removed the ref_count from vm_areas. You now always need to have the address space locked (read or write, depending on what you do) when dealing with areas. * Added helper classes for locking the address space: AddressSpace{Read|Write}Locker, and MultiAddressSpaceLocker which can lock several spaces at once and makes sure no dead locks can happen. * resize_area() is now using the MultiAddressSpaceLocker instead of no locking at all; ie. it should now be safely to use. * Disabled transfer_area() for now; it will be changed to work like an atomic clone_area()/delete_area(), that is, it will hand out a new ID for the transfered area. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21848 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
2ac748da |
|
06-Aug-2007 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Changed the signatures of fault_get_page() and fault_find_page(), so that an error can be propagated back to vm_soft_fault(). * Added boolean restart reference parameter to fault_find_page() which is set to true whenever a condition is it encountered that requires to start fault_find_page() from the very beginning. fault_get_page() checks the flag and executes fault_find_page() in a loop, now. * Removed the panic()s+TODOs in fault_find_page() when a cache became busy. The restart feature is used in this case. * fault_find_page(): If after the loop we haven't found a page yet, and after locking the right cache one turned up, we restart the function, too, thus avoiding double insertion of a page into a cache. * Fixed potential dead-lock in fault_get_page(): After inserting a clean page into a cache other than the top cache (read fault on copy-on-write area not backed by a file (e.g. the heap)) the dummy page was removed from the to be locked top cache while we still held a lock for the lower cache, thus inverting the locking direction required by the cache locking policy (top -> bottom). * fault_get_page(): In case of a write access and a readable page found in a lower cache, vm_cache_remove_consumer() could have replaced our dummy page with a real page from a collapsed lower cache while we had unlocked both caches. We didn't check for this condition and always inserted our freshly allocated page, thus potentially inserting a duplicate page into the top cache. We do the check now and discard our page, when another page turned up. Fixes bug #1359. * fault_get_page(), same if block: Removed unused case for removal of the dummy page from a non-top cache. We only ever insert it into the top cache and it should not be moved to another cache. Added an assert. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21841 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
0a75dab5 |
|
03-Aug-2007 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
fault_find_page(): Fixed a race condition in case of reading the page from the store into the top cache, which could lead to pages inserted multiple times into the cache. We don't insert a dummy page in this case anymore. Instead we mark a freshly allocated page busy and insert that one. That's exactly the approach the file cache uses too. This does probably make the whole dummy page special handling in the file cache obsolete. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21816 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
e9012605 |
|
02-Aug-2007 |
Axel Dörfler <axeld@pinc-software.de> |
vfs_get_vnode_cache() was changed (read: fixed) since r18716; it was wrong to acquire the extra vnode reference, and actually prevented unmounting from working - which it now does again. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21806 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
6e09c567 |
|
30-Jul-2007 |
Axel Dörfler <axeld@pinc-software.de> |
area_for() in the kernel can now also find user areas in case you are coming from a user team. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21746 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d6dfbc4d |
|
26-Jul-2007 |
Axel Dörfler <axeld@pinc-software.de> |
Minor cleanup in comments. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21714 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
6d1c6815 |
|
19-Jul-2007 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
axeld + bonefish: * More conditional debug code (wrt page transitions between caches). * Replaced debugger command cache_chain by a nicer cache_tree. * While handling a soft fault: When we temporarily unlock a cache, it can theoretically become busy. One such occurrence is now handled properly, two more panic() ATM, though should be fixed. * When merging caches, we do now always replace a dummy page in the upper cache, not only when the concurrent page fault is a read fault. This prevents a page from the lower (to be discarded) cache from still remaining mapped (causing a panic). * When merging caches and replacing a dummy page, we were trying to remove the dummy page from the wrong cache (causing a panic). The Haiku kernel seems now to run shockingly stable. ATM, we have more than two hours uptime of a system booted and running over network. We didn't manage to get it down by fully building Pe, downloading, unzipping, and playing with various stuff. Someone should finally fix all those app server drawing bugs, though (hint, hint! ;-)). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21672 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
58f6e8e5 |
|
17-Jul-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* Merged vm_cache_ref and vm_cache to a single structure (Axel & Ingo). * Renamed vm_cache.c to vm_cache.cpp git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21642 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
25f46ea4 |
|
30-Jun-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* Reserving areas never put down their reference of their address space when removed in several cases. * vfs_get_vnode_cache() now always gives out a reference to the cache it returns; if it needs to allocate a new one, the vnode owns one reference, and the caller another. * therefore, file_cache_create() now owns a reference to its vm_cache_ref, and frees it in file_cache_delete(). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21533 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
0cb94db5 |
|
21-Jun-2007 |
Axel Dörfler <axeld@pinc-software.de> |
Ingo and I fixed a couple of VM bugs in a late night debugging session: * vm_copy_on_write_area() now does no longer overwrite the ref_count, but keeps it's reference to the cache until it has unlocked it. * It now also locks its reference from the start, preventing any other thread to interfere. * vm_cache_remove_consumer() now detects if it has to remove a foreign busy page itself in order to preserve a mapped page. * vm_soft_fault() now keeps a reference to the cache that owns the page to be mapped until it has actually mapped it. * vm_unmap_pages() removed the mappings of all pages of the area instead of only those that are within the requested range. * Kept (disabled) debug output for convenience. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21482 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d9be8bc0 |
|
08-Jun-2007 |
Stefano Ceccherini <stefano.ceccherini@gmail.com> |
Got rid of a global, hope no one minds git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21349 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
1c86f489 |
|
03-Jun-2007 |
Stefano Ceccherini <stefano.ceccherini@gmail.com> |
Renamed a couple of variables, for easier reading... git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21319 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
698b6d71 |
|
29-Apr-2007 |
Hugo Santos <hugosantos@nowhere.fake> |
cache/slab: when CACHE_DURING_BOOT is specified, use vm_allocate_early to obtain pages for slabs, and create the associated areas on post bootup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20913 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
6bad4934 |
|
28-Apr-2007 |
Hugo Santos <hugosantos@nowhere.fake> |
pushed the slab init a bit deeper. added a object cache based allocator, including a bootstrap mechanism to have it init during bootup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20896 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
be1f4326 |
|
23-Apr-2007 |
Axel Dörfler <axeld@pinc-software.de> |
Don't allow creating areas with a size of 0 bytes, courtesy of Vasilis Kaoutsis. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20789 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
30959210 |
|
16-Apr-2007 |
Travis Geiselbrecht <geist@foobox.com> |
asm optimized user_memcpy(), which should help somewhat, since the old version was a byte-by-byte copy. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20723 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
1407f23d |
|
03-Apr-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* The test for existing mappings in vm_remove_consumer() was a bit too aggressive; if the page is currently copied, the source page still has mappings. * vm_copy_on_write_area() did not set the cache type for the upper cache. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20530 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
3a1532ef |
|
29-Mar-2007 |
Axel Dörfler <axeld@pinc-software.de> |
In case the source cache of the current vm_cache_ref was in the process of being merged in vm_cache_remove_consumer(), fault_find_page() tried again with the current vm_cache_ref, but didn't realize it might have had inserted a busy page in this cache already. This fixes a deadlock, as this page would never get unbusy again. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20470 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
94d37a4b |
|
30-Mar-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* map_backing_store() did not set the private mapping's cache to CACHE_TYPE_RAM. * Some more debug helpers. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20469 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
673a63dc |
|
30-Mar-2007 |
Axel Dörfler <axeld@pinc-software.de> |
Added more checks regarding page movement for debugging purposes. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20468 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
c0c59f5b |
|
22-Mar-2007 |
Axel Dörfler <axeld@pinc-software.de> |
Accidently unmapped the wrong pages in case of COW after the last commit... git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20408 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
c6a7ff7a |
|
23-Mar-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* The new vm_page_mappings weren't updated correctly in many cases. * Added a comment to vm_remove_all_page_mappings() that shows that we need to change the mapping spinlock into a mutex. * Pointed out some potential problems in the code. * Added vm_page_at_index(), vm_clear_map_activation(), and vm_test_map_activation() in preparation of the page scanner rewrite. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20407 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
529bf404 |
|
21-Mar-2007 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
In a copy-on-write situation a page from a lower cache must always be mapped fully read-only (for both kernel and userland). Previously a kernel read access to a yet unmapped r/w accessible userland address would cause the page from the lower cache to be mapped with write permission for userland (on x86 also for the kernel) thus e.g. allowing a fork()ed child process to write to the parent process' memory. Fixes bugs #113 and #928. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20402 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
f19d32ef |
|
11-Mar-2007 |
Axel Dörfler <axeld@pinc-software.de> |
Fixed warning. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20369 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
6e601ee8 |
|
11-Mar-2007 |
Axel Dörfler <axeld@pinc-software.de> |
get_memory_map() now panics (and fails) in case it was called on unmapped memory as suggested by Ingo; before it would just fill the physical pages with NULL pointers. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20364 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
bf4604c3 |
|
09-Mar-2007 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Fixed incorrect loop conditions in [un]lock_memory(). If the given start address wasn't aligned and numBytes was a multiple of the page size, the last page was ignored. A subsequent get_memory_map() would return NULL as physical address for that page, if it hadn't been mapped before (that function looks generally suspicious, IMHO). E.g. reads from a device into an unaligned buffer that hadn't been touched before would hit that problem. Fixes bug #1075. Might also fix other reported problems (like #1056), since this bug could have cause all kinds of weird behavior and crashes. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20362 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
1594e83f |
|
08-Mar-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* All mapped pages that are not wired (ie. locked) now have a vm_page_mapping object that points to both, the page and the area the page is in. This will allow a page scanner to steal unused pages when necessary. * The locking is currently done with a spinlock which we might want to have another look at one day. * dump_page() and dump_area_struct() now dump the page mappings as well. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20356 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ab0ad5e9 |
|
01-Mar-2007 |
Axel Dörfler <axeld@pinc-software.de> |
Implemented printing the stack trace in vm_page_fault() for PPC as well. Not tested, though. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20284 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
00be6a4c |
|
01-Mar-2007 |
Axel Dörfler <axeld@pinc-software.de> |
And of course, we shouldn't test newArea->cache_type before it was set... git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20283 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
528e40c0 |
|
01-Mar-2007 |
Axel Dörfler <axeld@pinc-software.de> |
Of course, we need to query the address space of the source area, not the one of the target. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20282 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
0c123327 |
|
01-Mar-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* vm_map_physical_memory() now sets the wiring/locking type of the area created to B_FULL_LOCK. * vm_clone_area() now respects the source area's wiring and inherits it. This should fix bug #1055. * vm_cache::type is now duplicated in vm_area::cache_type - this allows looking it up without having to lock a vm_cache_ref; this also solves a locking bug in vm_unmap_pages() in this regard. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20281 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
5eb9da35 |
|
01-Mar-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* The KDL commands cache/cache_ref will now also print the type of the cache. * Made the output look a bit more like that of the other commands. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20279 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ca954b78 |
|
28-Feb-2007 |
Axel Dörfler <axeld@pinc-software.de> |
Another work-in-progress towards having extra structures per mapping per page: * vm_area and vm_page now have a new field "mappings" where they will store lists of vm_page_mapping structures. vm_page::ref_count is gone, as it's no longer needed (it was never updated correctly, anyway). * vm_caches now have a type field, ie. CACHE_TYPE_RAM for anonymous areas - this makes the stores a bit less independent, but is quite handy in several places. * Added new vm_map_page() and vm_unmap_pages() functions to be used whenever you map in or unmap pages into/from an area. They don't do much more than handling vm_page::wired_count correctly right now, though (ie. B_LAZY_LOCK is now working as expected as well). * Moved the device fault handler to vm_map_physical_memory(); it was not really used as a fault handler, anyway. * Didn't notice Ingo's changes to the I/O space region broke lock_memory(). It now checks the type of the area that contains the memory, and doesn't lock anymore if not needed which solves the problem in a platform independent way. * Implemented lock_memory() and unlock_memory() for real: they now change the vm_page::wired_count member to identify pages that shouldn't be paged out. * vm_area_for() now uses vm_area_lookup() internally. * Fixed various potential overflow conditions with areas that reach 0xffffffff. * Creating anonymous areas with B_FULL_LOCK no longer causes vm_soft_fault() to be called, instead, the pages are allocated and mapped (via vm_map_page()) directly. * Removed the _vm_ prefix for create_area_struct() and create_reserved_area_struct(). * Fixed a bug in vm_page_write_modified() that would not have enqueued pages that failed to be written to the modified queue again when needed. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20251 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
3eca8585 |
|
27-Feb-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* Moved the early startup VM allocation functions from vm_page.c to vm.cpp. * Renamed them, made everything static besides vm_allocate_early() (previous vm_alloc_from_kernel_args()) which now allows you to specify a different virtual than physical size, and therefore makes vm_alloc_virtual_from_kernel_args() superfluous (which isn't exported anymore, and is now called allocate_early_virtual()). * Enabled printing a stack trace on serial output on team crash - it doesn't hurt for now, anyway. * Cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20244 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
b2002754 |
|
07-Feb-2007 |
Axel Dörfler <axeld@pinc-software.de> |
Flushing the translation map is done automatically on unlock. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20097 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
fe70b87d |
|
31-Jan-2007 |
Axel Dörfler <axeld@pinc-software.de> |
Fixed a couple of issues in our VM: * we now always flush the TLBs after having unmapped some pages. * vm_soft_fault() could traverse to a source cache while it was being collapsed by vm_cache_remove_consumer() - this is now no longer possible as the latter marks the cache as busy when doing so, and the former now tests this flag and locks the cache (via the new fault_acquire_locked_source() function). * if fault_acquire_locked_source() fails with B_BUSY, the current cache is locked again, and tested again for the page - as it might have been moved upwards to it with the destruction of its former source. * The cache delivering the page for vm_soft_fault() is now locked until the end; it can no longer go away before having actually mapped the page into the area. * This also fixes the issue where pages would get lost as vm_soft_fault() put the page in the active list, no matter if its cache still existed. * Also, we now keep a reference of to a cache in case a dummy page is inserted; this makes again sure that it doesn't go away during the execution of vm_soft_fault() (which could even add this page to the free list...). * divided vm_soft_fault() into several smaller functions which should make it much more readable. * Added a "cache_chain" KDL command that dumps the whole chain until the bottom when giving a pointer to a vm_cache as parameter. * now usually call vm_cache_acquire_ref() before map_backing_store(), even though it shouldn't be really needed (I added it for debugging purposes). * Some minor cleanup. * NOTE: a major problem still persists: when removing a vm_cache, it's possible that some of its pages are still mapped, and there is currently no mechanism to get rid of these mappings! I've added TODO comments into vm_cache.c where appropriate. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20028 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
3901c6aa |
|
22-Jan-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* "db/ds/dw/dl" now print all isprint() characters, not only isalnum(). * Also, the output no longer has the leading "0x" to ease reading. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19906 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
7954a14f |
|
22-Jan-2007 |
Axel Dörfler <axeld@pinc-software.de> |
Add a little hack to the "dw/db/ds/dl" commands that allows you to dump the contents of a physical memory location. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19898 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
f212f3ba |
|
17-Jan-2007 |
Bruno G. Albuquerque <bga@bug-br.org.br> |
Fix build with TRACE enabled. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19848 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
e9ffbbf3 |
|
15-Jan-2007 |
Axel Dörfler <axeld@pinc-software.de> |
Moved locking into map_backing_store() - it now gets a vm_cache_ref instead of a vm_store, so that this can be done safely. It was also needed, as it would call vm_cache_release_ref() on failure which requires you to have no vm_cache_ref locks around (as it might deadlock in this case). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19806 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
63ac6cdc |
|
14-Jan-2007 |
Jérôme Duval <korli@users.berlios.de> |
fix gcc4 build git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19802 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
f39acd67 |
|
14-Jan-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* Made vm_area_lookup() part of the kernel private API. * "sc"/"where"/"bt" now prints the area where the function of the stack frame is located in case there is no other information (using the above function). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19800 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
647b1f70 |
|
14-Jan-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* vm_copy_on_write_area() did not always correctly divide the ref_count of the two cache_refs - it needs to count the consumers of the lower cache to find its actual number of references; the upper cache could still be in use by someone else. * There were several locking bugs in the VM code; since cache_ref::cache can change, we must not access it without having the cache_ref locked. * As a result, map_backing_store() now requires you to have the lock of the store's cache_ref held. * And therefore, some functions in vm_cache.c must no longer lock the cache_ref on their own, but require the caller to have it locked already. * Added the -s option to the cache/cache_ref KDL commands: it will only print the requested structure, and not its counterpart (useful if accessing one structure results in a page fault, as was possible previously). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19796 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ff718caf |
|
13-Jan-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* Maintain the vm_cache::virtual_size field in all cases. * Fixed dumping the area list of a cache I broke with the previous commit. * Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19789 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
81d5ce45 |
|
13-Jan-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* Merged "cache"/"cache_ref" commands, as you usually want to have all the info, anyway (you can still use both commands, but you'll see always the same output). * The cache_ref's area list now also prints the owner of the area. * Added "-p" option to "cache"/"cache_ref" that will show the pages of the cache; if you omit it, it will now only present you a page counter. * Nicer output for the commands above. * Added "dl" to display memory in 64 bit values. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19787 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
dc688434 |
|
12-Jan-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* Added the possibility to pre-commit pages for areas that can overcommit. * This is now used for userland stack - they now always pre-commit two pages, enough to initialize TLS and copy the user-thread-exit stub to that area. * Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19776 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d1b0be94 |
|
12-Jan-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* Private and temporary vm_caches now maintain their new virtual_base field, which allows them to commit substantially less memory (we we're committing about 40 MB (!) too much after a complete system boot). This means you'll run out of memory less likely now. * fill_area_info() no longer filters out kernel protection flags - we may want to keep filtering them when called from userland, though, dunno. * Added new debugger command "avail" which shows how much memory has been committed, and how much is regarded as free space. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19771 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
b5428267 |
|
19-Dec-2006 |
Axel Dörfler <axeld@pinc-software.de> |
This should fix the most often found kernel crash (on bootup): * vm_soft_fault() did not take into account that a cache's source can change while traversing a cache chain. * Now, we grab a reference to every cache we get before locking it, and * no longer get the cache's source without having the cache locked. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19571 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
c4546ea0 |
|
18-Dec-2006 |
Travis Geiselbrecht <geist@foobox.com> |
A fix for the double-fault on bootup: -Turns out the area removal routine had a massive race condition inside vm_put_area(). Basically the area was removed from the address space's area list before the pages were unmapped, so the vm could (and would) recycle the space before the pages were finally unmapped. It was completely reproducable on my machine during initialization of a bunch of storage drivers that were bringing the locked_pool module into and out of existence, which caused a thread to be spawned and stopped in rapid sucession. On a dual processor machine, it was possible for the new thread to be started up while the old one was still shutting down, and the kernel stack of the new one would get wiped out. Note, there still is a page ref counting problem with this area removal code. It doesn't decrement the ref count of the page as it unmaps it. Will have to figure that out. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19549 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
c3a89b90 |
|
17-Dec-2006 |
Travis Geiselbrecht <geist@foobox.com> |
fix the 'cache_ref' and 'cache' kdl commands git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19546 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
0ad660a1 |
|
02-Nov-2006 |
Axel Dörfler <axeld@pinc-software.de> |
Remap all preloaded executables read-only and executable. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19180 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
bcf2f813 |
|
10-Oct-2006 |
Axel Dörfler <axeld@pinc-software.de> |
* Fixed a big memory leak: vm_delete_areas() did not put the reference of the address space of reserved areas - IOW address spaces were never freed upon team exit. * dump_cache() now prints a list of the cache's consumers. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19040 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
a7181e95 |
|
10-Oct-2006 |
Axel Dörfler <axeld@pinc-software.de> |
Accidently turned on printing stack traces with the last commit. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19037 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
0b8e0bfc |
|
10-Oct-2006 |
Axel Dörfler <axeld@pinc-software.de> |
Some cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19036 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d593e74a |
|
10-Oct-2006 |
Axel Dörfler <axeld@pinc-software.de> |
First steps towards being able of collapse vm_cache objects after forking: * a vm_cache now maintains a list of its "consumer" caches. * introduced to new functions that add/remove consumer to a cache (instead of only maintaining the vm_cache::source field). * fixed the incorrect reference counting when doing copy-on-write; we kept one ref too many of the lower cache. * minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19035 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
c40fe37f |
|
30-Aug-2006 |
Axel Dörfler <axeld@pinc-software.de> |
* Reverted the changes r17693 made to vfs_get_vnode_cache(); instead, vm_create_vnode_cache() will now grab a reference to the vnode as well if successful. This way, vfs_get_vnode_cache() now actually works how it should: it will now always grab a reference to the cache and its underlying vnode. This removes an extra reference to the vnode (and vm_cache) that got ignored before and prevented volumes to be unmounted (or file caches to be removed). Thanks to Korli for pointing this out. * file_cache_create() is now aware of that extra vnode reference and releases it; unmounting volumes is now working again as it should. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18716 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
acac7c68 |
|
01-Jun-2006 |
Axel Dörfler <axeld@pinc-software.de> |
_vm_map_file() did in fact not work correctly, but the main problem was vfs_get_vnode_cache() which did not acquire an extra reference to the cache_ref when the cache had to be created. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17693 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
a9fa017d |
|
01-Jun-2006 |
Axel Dörfler <axeld@pinc-software.de> |
map_backing_store() did not acquire a cache ref in case it created a private mapping, but it connected the vm_cache objects, so if it failed later, and thus called vm_cache_release_ref() the object could have been freed accidently. Most uses of map_backing_store() explicetly acquired a cache_ref *after* the call was successful, but _vm_map_file() did not do this. _vm_map_file() might still not work correctly, though, need to have a closer look at it. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17692 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
01fdd314 |
|
17-May-2006 |
Axel Dörfler <axeld@pinc-software.de> |
Some GCC 4.1.0 related build fixes (under Linux/PPC). Doesn't build yet, though. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17500 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
573c4336 |
|
30-Apr-2006 |
Axel Dörfler <axeld@pinc-software.de> |
Implemented quite a hack to solve the lockless get_memory_map() problem (bug #349): when called with interrupts turned off, get_memory_map() will now call the new vm_translation_map_ops::query_interrupt() call. Under PPC, this is trivial (at least right now), but on x86 we need to make sure we have access to the page table entry, ie. we need to create an area that points to its own page table entry, so that we can map in the page table entry containing the address we're looking for. It's not really nice, feel free to come up with a cleaner solution :-) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17280 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
97e06971 |
|
12-Apr-2006 |
Axel Dörfler <axeld@pinc-software.de> |
Added a "reenter" parameter to the {read|write}_pages() functions to give file systems a chance to know if they have locked already. This fixes a locking problem in BFS where one thread tried to acquire two read locks (where someone else trying to acquire a write lock would have caused a dead lock). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17108 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
8645479b |
|
11-Apr-2006 |
Axel Dörfler <axeld@pinc-software.de> |
* cache_io() could insert a second page at the same position in the vm_cache since it unlocked the cache while waiting on a busy page. Now, we're filling the pending request before unlocking the cache. * Fixed the deadlock I mentioned in the last commit: if a page fault happens at the same time we're trying to read/write from/to a page, we no longer fight for the BFS inode lock, but eventually doing the job twice if needed. Will need to go over the "write modified" functions to make sure they are behaving as well. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17091 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
5ba2a383 |
|
23-Mar-2006 |
Axel Dörfler <axeld@pinc-software.de> |
Improved the filter capabilities of the "ports", "port", "sems", and "areas" debugger commands. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16870 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
db823da5 |
|
19-Mar-2006 |
Axel Dörfler <axeld@pinc-software.de> |
* Even though our current heap is a temporary solution, the heap size depends now on the amount of memory installed in the system. Ie. if you have only 128 MB the kernel heap will be only half in size. * Minor cleanup in vm_page.c, renamed some variables to match our style guide. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16838 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
5f0bf2a3 |
|
18-Mar-2006 |
Axel Dörfler <axeld@pinc-software.de> |
We now track how many pages are in a vm_cache. Therefore, the area_info.ram_size now reflects the number of pages in the areas cache, instead of just the size of the area. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16834 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
66b7a0f4 |
|
17-Mar-2006 |
Axel Dörfler <axeld@pinc-software.de> |
Renamed the _kern_init_heap_address_range() syscall to _kern_reserve_heap_address_range() and made it more powerful. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16825 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
b420ef64 |
|
06-Mar-2006 |
Axel Dörfler <axeld@pinc-software.de> |
* Many VM area creation functions just panicked when a vm_store, vm_cache, or vm_cache_ref couldn't be created, instead of cleaning up and returning an appropriate error. * vm_cache_ref_create() no returns a status_t instead of the vm_cache_ref (as that's part of the vm_cache anyway). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16602 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d97476d1 |
|
24-Jan-2006 |
Axel Dörfler <axeld@pinc-software.de> |
The userland stack trace no longer accesses the stack of the crashed application unsafe. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16071 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
1777154c |
|
09-Jan-2006 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Fixed tracing build. * In reserve_boot_loader_ranges() we skip ranges that lie without the kernel address space (we failed and panic()ed before). The architecture specific code has to deal with those, if they are of any importance. * sAvailableMemoryLock.sem was not set to -1 in vm_init() so code executed after semaphores were available but before the semaphore was created caused semaphore 0 to be acquired. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15889 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
70226007 |
|
30-Dec-2005 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Don't know what kernel_args::bootdir_addr was originally intended for, but it's not initialized anymore. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15745 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
6aeb5994 |
|
27-Dec-2005 |
Axel Dörfler <axeld@pinc-software.de> |
Fixed printing stack trace of crashed apps. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15680 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
0c199207 |
|
21-Dec-2005 |
Axel Dörfler <axeld@pinc-software.de> |
Improved debug output, added missing owner info to _dump_area(). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15653 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
7a3e1b69 |
|
21-Dec-2005 |
Axel Dörfler <axeld@pinc-software.de> |
Slightly improved debug output. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15652 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ebe5949e |
|
21-Dec-2005 |
Axel Dörfler <axeld@pinc-software.de> |
The debugger command "areas" can now restrict the list by team ID. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15650 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
c1b57240 |
|
21-Dec-2005 |
Axel Dörfler <axeld@pinc-software.de> |
My last commit broken vm_clone_area(): it didn't grab a reference to its cache, and therefore, let the kernel crash easily. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15649 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
db39fa28 |
|
21-Dec-2005 |
Axel Dörfler <axeld@pinc-software.de> |
Moved the headers of the different store implementations into the VM source directory; they are not used outside the VM. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15648 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ea2cd27e |
|
21-Dec-2005 |
Axel Dörfler <axeld@pinc-software.de> |
* Fixed the strange vm_cache_ref reference count mechanism: now, a fresh vm_cache_ref starts with a reference count of 1. When acquiring a vm_cache, you no longer need to worry if that should go through the vm_store, or not; as it now always does. * map_backing_store() no longer needs to play with the vm_cache_ref references. * that simplified some code. * vfs_get_vnode_cache() now grabs a reference to the cache, if successful. * better balanced vnode ownership on vnode_store creation (vnode_store released the vnode before if its creation failed). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15641 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
79f73dbc |
|
20-Dec-2005 |
Axel Dörfler <axeld@pinc-software.de> |
* vm_page::offset is now called cache_offset and is now an uint32 instead of off_t; this saves 4 bytes per page. To compensate the loss of bytes, the offset is now stored in page size units, that's enough to address 2^44 or 16 TB (which is now the maximal supported file size!). * Renamed vm_page::ppn to physical_page_number. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15637 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d608540b |
|
20-Dec-2005 |
Axel Dörfler <axeld@pinc-software.de> |
Separated vm_address_space.h from vm.h. Some more cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15614 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
96e01a27 |
|
20-Dec-2005 |
Axel Dörfler <axeld@pinc-software.de> |
* Merged vm_virtual_map with vm_address_space - there was no reason to have them apart (this even saves a pointer from vm_virtual_map to its address space) * aspace -> address_space * vm_create_address_space() did not check if creating the semaphore succeeded * Removed team::kaspace - was not really needed (introduced a new vm_kernel_address_space() function that doesn't grab a reference to the address space) * Removed vm_address_space::name - it was just a copy of the team name, anyway, and there is always only one address space per team * Removed aspace_id - the address space is now using the team_id * Some cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15609 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
9d845483 |
|
19-Dec-2005 |
Axel Dörfler <axeld@pinc-software.de> |
Got rid of two ToDo-items: instead of clearing the PAGE_MODIFIED flag after having written the page, we now do it before, so that it cannot lose any changed data anymore; it doesn't matter if the page is written to while writing it back, the worst thing that can happen is that we write the same page twice. Also, we don't rely on the PAGE_MODIFIED bit anymore, we now check all mappings of that page to find all modified pages, no matter how far the (currently disabled) page daemon had come. Also, destroying an area will now result in writing back changed pages - this is only really important for memory mapped files, though, and should probably be avoided for other vm_store types. Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15597 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
41e866f3 |
|
16-Dec-2005 |
Axel Dörfler <axeld@pinc-software.de> |
The block cache now registers and uses a low memory handler that will flush unused blocks when needed. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15561 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
51a3c450 |
|
13-Dec-2005 |
Axel Dörfler <axeld@pinc-software.de> |
The short story: we now have MTRR support on Intel and AMD CPUs (the latter has not yet been tested, though - I'll do this after this commit): * Removed the arch_memory_type stuff from vm_area; since there are only 8 memory ranges on x86, it's simply overkill. The MTRR code now remembers the area ID and finds the MTRR that way (it could also iterate over the existing MTRRs). * Introduced some post_modules() init functions. * If the other x86 CPUs out there don't differ a lot, MTRR functionality might be put back into the kernel. * x86_write_msr() was broken, it wrote the 64 bit number with the 32 bit words switched - it took me some time (and lots of #GPs) to figure that one out. * Removed the macro read_ebp() and introduced a function x86_read_ebp() (it's not really a time critical call). * Followed the Intel docs on how to change MTRRs (symmetrically on all CPUs with caches turned off). * Asking for memory types will automatically change the requested length to a power of two - note that BeOS seems to behave in the same, although that's not really very clean. * fixed MTRRs are ignored for now - we should make sure at least, though, that they are identical on all CPUs (or turn them off, even though I'd prefer the BIOS stuff to be uncacheable, which we don't enforce yet, though). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15528 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
2ed21b85 |
|
12-Dec-2005 |
Axel Dörfler <axeld@pinc-software.de> |
Some work in progress of the MTRR support. Shouldn't do any harm yet :-) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15525 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
7c0a9357 |
|
12-Dec-2005 |
Axel Dörfler <axeld@pinc-software.de> |
Preparation for MTRR support, code is completely untested, though. The CPU specific MTRR code will be in modules. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15520 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
2bea891d |
|
24-Nov-2005 |
Axel Dörfler <axeld@pinc-software.de> |
Debug output change: vm_page_fault() doesn't kill the team anymore, it just sends a SIGSEGV signal (and lets the debugger handle the rest). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15145 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
e432cef2 |
|
25-Aug-2005 |
Axel Dörfler <axeld@pinc-software.de> |
Updated a few more hash functions to be able to deal with negative numbers. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14067 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
099ceb8f |
|
21-Aug-2005 |
Axel Dörfler <axeld@pinc-software.de> |
map_physical_memory() and its backend vm_map_physical_memory() did not map in the pages, ie. they considered the areas to be B_LAZY_LOCK. But that doesn't really make sense and potentially cause page faults where you wouldn't expect them (and where it's not a good idea to trigger them). Reworked display_mem() (used by the dw/db/ds commands in the kernel debugger) to be a bit more sane, improved formatting, and allows it to work on non-existing memory without a panic. The "area" debugger command now also accepts an address (contained by the area) as argument - and it will now always print out an error message if no matching area could be found. Replaced all dprintf() calls to kprintf() calls for the kernel debugger functions. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14042 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
eab435cd |
|
05-Aug-2005 |
Axel Dörfler <axeld@pinc-software.de> |
vfs_get_vnode_cache() now only allocates a new cache if requested: this prevents the system to allocate caches for files that don't use or have a file cache (ie. only those can be mmap()ed!). Therefore, cache_prefetch() no longer crashes when trying to prefetch files without a file cache. read_into_cache() no longer does anything if the requested size is 0. Fixed a bug in cache_prefetch_vnode(): if the cache couldn't be retrieved, it put the vnode, but didn't own it (the caller does). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13904 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
b72cf260 |
|
01-Aug-2005 |
Axel Dörfler <axeld@pinc-software.de> |
Renamed vfs_vnode_acquire_ref() to vnode_acquire_vnode(). Removed vfs_vnode_release_ref(), as vfs_put_vnode() already does the same thing. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13867 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
230a037e |
|
19-Jul-2005 |
Axel Dörfler <axeld@pinc-software.de> |
Fixed a bad bug in vm_copy_on_write_area(): the area's cache offset was not taken into account when remapping the pages read-only; it could have overwritten valid page mappings this way. This was also the reason for the Terminal to crash - it does now work as it should, although some keys don't work (like tab completion)). vm_copy_area() no longer always sets B_KERNEL_WRITE_AREA if no kernel protection was specified, but mirrors the userland protection (for example, the x86 MMU is not able to have a page writable in kernel but not in userland). This caused some areas to be read/write when read-only would have been enough. vm_copy_area() now panics when vm_copy_on_write_area() fails - that's of course no real solution, but it's bettern than letting it silently fail. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13768 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
b7a96f02 |
|
30-Jun-2005 |
Axel Dörfler <axeld@pinc-software.de> |
Now fills in system_info::cpu_infos[] (ie. CPU activity) by looking at the active time of the idle thread. IOW Pulse now works :-) Renamed the idle thread/stack to start with 1 instead of 0 (first idle thread will be called "idle thread 1"). Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13373 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
e970b839 |
|
30-Jun-2005 |
Axel Dörfler <axeld@pinc-software.de> |
Disabled B_USER_CLONEABLE_AREA for now - maybe this should be handled via kernel settings later. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13372 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
b84688be |
|
13-Jun-2005 |
Axel Dörfler <axeld@pinc-software.de> |
Added a basic low memory handler service. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13090 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
62d69616 |
|
16-May-2005 |
Axel Dörfler <axeld@pinc-software.de> |
Renamed vm.c to vm.cpp and made all the changes to let it compile without errors. Also made the VM headers C++ safe. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12694 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
271ac910a4cfdefa6393c1e7cb5e3a665404757d |
|
09-Jan-2015 |
Adrien Destugues <pulkomandy@gmail.com> |
Remove useless includes of khash.h * These files were already converted to BOpenHashTable. * For #9552.
|
#
8068b64b5c33e0c8bd6d3fcabfd3ebac3a422d2b |
|
13-Nov-2014 |
PulkoMandy <pulkomandy@pulkomandy.tk> |
Fix build with guarded heap on x86_64 * Type mismatch.
|
#
601b2f7eda4d25b46e7d17e212d22954f28bd0fe |
|
21-Oct-2014 |
Henry Harrington <henry.harrington@gmail.com> |
vm: Try harder to allocate early physical pages. * On UEFI, pages are allocated top-down; previously, VM would fail to allocate early pages due to running into pages allocated at the top and assume it had run out of pages to map. Signed-off-by: Jessica Hamilton <jessica.l.hamilton@gmail.com>
|
#
7ca277b9caaec8e873309354e3c7fe8453c34b64 |
|
28-Oct-2014 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
vm_soft_fault(): remove unused wiredRange parameter
|
#
078a965f65b5f56ecb3f0c72fc97a36238509ca8 |
|
28-Oct-2014 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
vm_soft_fault(): Avoid deadlock waiting for wired ranges * VMArea::AddWaiterIfWired(): Replace the ignoreRange argument by a flags argument and introduce (currently only) flag IGNORE_WRITE_WIRED_RANGES. If specified, ranges wired for writing are ignored. Ignoring just a single specified range doesn't cut it in vm_soft_fault(), and there aren't any other users of that feature. * vm_soft_fault(): When having to unmap a page of a lower cache, this page cannot be wired for writing. So we can safely ignore all writed-wired ranges, instead of just our own. We even have to do that in case there's another thread that concurrently tries to write-wire the same page, since otherwise we'd deadlock waiting for each other.
|
#
8ef857d85cf4da2a445e72e2a79e6b35d70992ed |
|
28-Oct-2014 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
vm_soft_fault(): Avoid inconsistent state when seeing wired page When we encounter a wired page that we'd have to unmap to map our newly allocated one, we need to get rid of the latter before unlocking everything and waiting for the wired page. Otherwise we'd leave things in an inconsistent state (a page from an upper cache shadowing a mapped page from a lower cache).
|
#
70d3bd5592c0989c9bf45519330cee72e3dde652 |
|
28-Oct-2014 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
vm_soft_fault(): Missing DEBUG_PAGE_ACCESS_END() ... in case we'd need to unmap a page that is wired. Fixes the immediate issue of #10977. There's a problem remaining (as discussed in comment 1): If two threads want to wire the same page at the same time (which led to the assertion being triggered), they will now deadlock, waiting for each other to remove the pre-registered VMAreaWiredRange.
|
#
95e97463d265c9f4a6e43265ef0f1f63a0825b21 |
|
14-Sep-2014 |
Paweł Dziepak <pdziepak@quarnos.org> |
kernel: add generic wrapper for accessing user memory This patch adds user_access() which can be used to gracefully handle page faults that may happen when accessing user memory. It is used by arch_cpu_user{memcpy, memset, strlcpy}() to allow using optimized functions from the standard library. Currently only x64 uses this, but nothing really is arch specific here. Signed-off-by: Paweł Dziepak <pdziepak@quarnos.org>
|
#
819824e020bf6ab001077b4ae48de9f33d778349 |
|
26-Jan-2014 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel/{x86, vm}: Add more error checks in VM initialization
|
#
d02aaee17e007631fcfa91a012ec7b6386927012 |
|
15-Dec-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel, libroot: Add more memory info in system_info system_info now contains all information previously available only through __get_system_info_etc(B_MEMORY_INFO, ...).
|
#
781671ad5ba04baf1c1a9a6365ae3f6ea7a9ab95 |
|
10-Dec-2013 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
dump_mapping_info(): Remove problematic initializer Fixes gcc 2 build.
|
#
c259766f94e7cfbe9318eda438d89f62a5099949 |
|
10-Dec-2013 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
KDL "mapping" command: Allow specifying a thread ID ... instead of only a team ID.
|
#
5d3978dbe7351942a45066d3f0b70ce8973144b4 |
|
10-Dec-2013 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
KDL "mapping" command: Fix argument check It wasn't possible to actually specify the second argument (team ID).
|
#
7b83ce1142f92bfe60462d33ffd3a215944c7319 |
|
04-Dec-2013 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Add KDL command "mapping" * VMTranslationMap: - Add DebugPrintMappingInfo(): Given a virtual address it is supposed to print the paging structure information for that address. To be implemented by derived classes. - Add DebugGetReverseMappingInfo(): Given a physical addresss it is supposed to find all virtual addresses mapped to it. To be implemented by derived classes. * X86VMTranslationMapPAE: Implement the new methods DebugPrintMappingInfo() and DebugGetReverseMappingInfo(). * Add KDL command "mapping". It supports both virtual address lookups and reverse lookups.
|
#
2b269f2e4788e02c615ab744bf45cc4274dd1f3b |
|
12-Nov-2013 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
unlock_memory_etc(): Fix address space reference leak unlock_memory_etc() is supposed to release the address space reference lock_memory_etc() acquired. It didn't do that, though.
|
#
93fb0ff0565694c4cfd752e5550680bf86aeb37e |
|
12-Nov-2013 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
vm: lock_memory_etc(): Fix error case In case something went wrong, call unlock_memory_etc() with the rounded base address instead of with the original address. If the original address wasn't page aligned, unlock_memory_etc() would otherwise try to unlock an additional page.
|
#
e5f65913828a6ca3d252f149ccb113e90a8532ef |
|
11-Nov-2013 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
VM: vm_memset_physical(): Correct length parameter type
|
#
8614737f7111ab63672b04299280005000907b81 |
|
15-Apr-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
elf: restore correct region protection after relocation
|
#
feae2b5a0000c39fe690528e5f1a9a6ba36c5c78 |
|
09-Apr-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
vm: force userland to use B_RANDOMIZED_* address specifications
|
#
bf65fc1dfe8daefa37b83d5551a85ec8fd65a8d5 |
|
09-Apr-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
vm: remove B_RANDOMIZED_IMAGE_ADDRESS address specification This address specification is actually not needed since PIC images can be located anywhere. Only their size is restriced but that is the compiler and linker concern. Thanks to Alex Smith for pointing that out.
|
#
d4823423996b12ff7332be5dcf97c35c295129a2 |
|
05-Apr-2013 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
VM: Fix vm_block_address_range() area protection B_ALREADY_WIRED, which was erroneously passed for the area protection parameter to map_backing_store(), has the value 7 which implies user readable and writable. Hence the address ranges around 0xdeadbeef and 0xcccccccc could actually be read and written from anywhere.
|
#
65ed4fa908cce8864aee0905014bb802857d601d |
|
03-Apr-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
vm: implement B_RANDOMIZED_IMAGE_ADDRESS address specification On some 64 bit architectures program and library images have to be mapped in the lower 2 GB of the address space (due to instruction pointer relative addressing). Address specification B_RANDOMIZED_IMAGE_ADDRESS ensures that created area satisfies that requirement.
|
#
966f207668d19610dae34d5331150e3742815bcf |
|
06-Mar-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
x86: enable data execution prevention Set execute disable bit for any page that belongs to area with neither B_EXECUTE_AREA nor B_KERNEL_EXECUTE_AREA set. In order to take advanage of NX bit in 32 bit protected mode PAE must be enabled. Thus, from now on it is also enabled when the CPU supports NX bit. vm_page_fault() takes additional argument which indicates whether page fault was caused by an illegal instruction fetch.
|
#
b3e4c67739c7cc1e70dce20110fdeaea44155e1a |
|
26-Feb-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
vm: implement B_RANDOMIZED_ANY_ADDRESS address specification Randomized equivalent of B_ANY_ADDRESS. When a free space is found (as in B_ANY_ADDRESS) the base adress is then randomized using _RandomizeAddress pretty much like it is done in B_RANDOMIZED_BASE_ADDRESS.
|
#
f9bab525f6dc0e5ed6a164ebd9b3a9dde9c6ba6f |
|
25-Feb-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
vm: implement B_RANDOMIZED_BASE_ADDRESS address specification B_RAND_BASE_ADDRESS is basically B_BASE_ADDRESS with non-deterministic created area's base address. Initial start address is randomized and then the algorithm looks for a large enough free space in the interval [randomized start, end]. If it fails then the search is repeated in the interval [original start, randomized start]. In case it also fails the algorithm falls back to B_ANY_ADDRESS (B_RANDOMIZED_ANY_ADDRESS when it is implemented) just like B_BASE_ADDRESS does. Randomization range is limited by kMaxRandomize and kMaxInitialRandomize.
|
#
d1f280c80529d5f0bc55030c2934f9255bc7f6a2 |
|
01-Apr-2012 |
Hamish Morrison <hamishm53@gmail.com> |
Add support for pthread_attr_get/setguardsize() * Added the aforementioned functions. * create_area_etc() now takes a guard size parameter. * The thread_info::stack_base/end range now refers to the usable range only.
|
#
4efc3430a040f033cdda576d1b32a762252afc24 |
|
14-Aug-2012 |
Alex Smith <alex@alex-smith.me.uk> |
Fixed possible NULL dereference in vm_page_fault. This bug was introduced by changing IS_USER_ADDRESS to check against USER_BASE AND USER_TOP rather than just !IS_KERNEL_ADDRESS. Faults on addresses outside both the user and kernel address spaces (i.e. the gap between user and kernel) would result in addressSpace being NULL, but addressSpace was being used without checking for NULL at one point.
|
#
25871c6895b536640b3d9f453e95219a54b84d20 |
|
04-Aug-2012 |
Alex Smith <alex@alex-smith.me.uk> |
Removed Thread::fault_callback, no longer necessary now that vm86 is gone.
|
#
6e2f6d1ace7490a200dcff70c52acf2af59c5bc3 |
|
29-Jul-2012 |
Alex Smith <alex@alex-smith.me.uk> |
Changed cookie type for get_next_area_info() to ssize_t. The cookie is used to store the base address of the area that was just visited. On 64-bit systems, int32 is not sufficient. Therefore, changed to ssize_t which retains compatibility on x86 while expanding to a sufficient size on x86_64.
|
#
c3f0fd28cda13d70a8c092003609442e4e29cf78 |
|
12-Jul-2012 |
Alex Smith <alex@alex-smith.me.uk> |
Fixed formatting of output in some debugger commands. Currently all debugger commands assume 32-bit pointers when formatting their output. This means that on x86_64 the output is incorrectly formatted. Fixed this by adding a B_PRINTF_POINTER_WIDTH definition (16 on 64-bit, 8 on 32-bit), and using this to correctly format the output. Not all commands have been fixed yet, but all VM, slab, VFS, team, thread and image commands should be correct.
|
#
5e9bb17da7b9cdd76ff9072486fab90688cf8c36 |
|
08-Jul-2012 |
Alex Smith <alex@alex-smith.me.uk> |
Renamed remaining i386_* functions to x86_* for consistency.
|
#
3b802628b8e2aa14eb4c674d0a8cf900f522baa1 |
|
09-Jul-2012 |
Alex Smith <alex@alex-smith.me.uk> |
Support ELF64 in the kernel. This has been done by adding typedefs in elf_common.h to the correct ELF structures for the architecture, and changing all Elf32_* uses to those types. I don't know whether image loading works as I cannot test it yet, there may be some 64-bit safety issues around. However, symbol lookup for the kernel is working correctly.
|
#
c15176264b7fa5b4e20b4692d30ed9403fd9c71b |
|
06-Jul-2012 |
Alex Smith <alex@alex-smith.me.uk> |
Compile APIC and timer code for x86_64, and create an area for the IDT.
|
#
ab7726a2c4bafe6e4d4937c1fb6c80f9281d9fbc |
|
06-Jul-2012 |
Alex Smith <alex@alex-smith.me.uk> |
Temporary fix for create_preloaded_image_areas. Will be replaced with a typedef later on.
|
#
11d35d1b9b453cf95392b2ae8fa0941266e85d78 |
|
05-Jul-2012 |
Alex Smith <alex@alex-smith.me.uk> |
Fixed tracing printf formats in VM code.
|
#
fb8447d59586d40fc8987ede4795ebda64354839 |
|
02-Jul-2012 |
Rene Gollent <anevilyak@gmail.com> |
Fix ticket #8650. - Replace arch_cpu_user_strlcpy() and arch_cpu_user_memset() with x86 assembly versions. These correctly handle the fault handler, which had broken again on gcc4 for the C versions, causing stack corruption in certain error cases. The other architectures will still need to have corresponding asm variants added in order for them to not run into the same issue though.
|
#
294711f98c107cf2d9d05b7fc34cd863e87bd358 |
|
27-Jun-2012 |
Alex Smith <alex@alex-smith.me.uk> |
Changed {,u}int64 to be long rather than long long on x86_64.
|
#
f1244978152350f9cc010e766d09c2e9ad34dfce |
|
22-Jun-2012 |
Alex Smith <alex@alex-smith.me.uk> |
Added an ELF64 version of preloaded_image. * There is now 2 structures, preloaded_elf32_image and preloaded_elf64_image, which both inherit from preloaded_image. * For now I've just hardcoded in use of preloaded_elf32_image, but the bootloader ELF code will shortly be converted to use templates which use the appropriate structure. The kernel will be changed later when I add ELF64 support to it. * All kernel_args data is now compatible between 32-bit and 64-bit kernels.
|
#
192af9e0afd2f3d0cbaf5c935480343a70c8ff53 |
|
20-Jun-2012 |
Alex Smith <alex@alex-smith.me.uk> |
Changed addr_range to use uint64. I've tested this change on x86, causing no issues. I've checked over the code for all other platforms and made the necessary changes and to the best of my knowledge they should also still work, but I haven't actually built and tested them. Once I've completed the kernel_args changes the other platforms will need testing.
|
#
4be4fc6b1faddbd037146214a0011d320842b4f3 |
|
15-Jun-2012 |
Alex Smith <alex@alex-smith.me.uk> |
More 64-bit compilation/safety fixes.
|
#
c40f31867bed1703736b0cc9193d017b60568da0 |
|
16-Jan-2012 |
Jérôme Duval <jerome.duval@gmail.com> |
Fix with enabled tracing.
|
#
6ef7d359c7b8dc970e0dbc7d7e2baa67f00d3695 |
|
11-Dec-2011 |
Michael Lotz <mmlr@mlotz.ch> |
ASSERT() that there really aren't any wired pages.
|
#
af09f123d3df57e2fd9fef9ac9edbfe55c61a431 |
|
11-Dec-2011 |
Michael Lotz <mmlr@mlotz.ch> |
Create the right cache type ([non-]swappable) on copy on write. When forking a team, copy on write areas (and therefore caches) are created for all the areas in the parent team, but they were always created as swappable. If the parent team had some B_FULL_LOCK areas, which aren't swappable, the wrong type of cache would be created which lead to them not being mergeable later on (causing a panic). Comments about a possibly cleaner way to figure out the cache type would be welcome.
|
#
ded69b4c3ac474489a2f3d8a9ae11c8d03453ef0 |
|
06-Dec-2011 |
Michael Lotz <mmlr@mlotz.ch> |
Only the to be protected range needs to be non-wired. When setting memory protection, only ensure/wait for the range that needs to be protected to not be wired instead of requiering the whole area to be non-wired. The memory protection is done page wise and having some parts of the area wired shouldn't preclude other parts to be protected.
|
#
1fe24d0cd0b547a771c00f6fca8f50ba6ca2fb2c |
|
03-Dec-2011 |
Michael Lotz <mmlr@mlotz.ch> |
Add heap with guard pages to detect out of bound reads/writes. This is a very simple heap implementation that allocates memory so that the end of each allocation always coincides with a page end and is followed by a guard page which is marked non-present. Out of bounds access (both read and write) therefore cause a crash (unhandled page fault). Note that this allocator is neither speed nor space efficient, indeed it wastes huge amounts of pages and address space so it is quite easy to hit limits. It is intended as a pure debug feature.
|
#
7418dbd90806ceb5702ad20c73b143928b75e212 |
|
03-Dec-2011 |
Michael Lotz <mmlr@mlotz.ch> |
Introduce debug page wise kernel area protection functions. This adds a pair of functions vm_prepare_kernel_area_debug_protection() and vm_set_kernel_area_debug_protection() to set a kernel area up for page wise protection and to actually protect individual pages respectively. It was already possible to read and write protect full areas via area protection flags and not mapping any actual pages. For areas that actually have mapped pages this doesn't work however as no fault, at which the permissions could be checked, is generated on access. These new functions use the debug helpers of the translation map to mark individual pages as non-present without unmapping them. This allows them to be "protected", i.e. causing a fault on read and write access. As they aren't actually unmapped they can later be marked present again. Note that these are debug helpers and have quite a few restrictions as described in the comment above the function and is only useful for some very specific and constrained use cases.
|
#
5247333d36970134729fdbf67e2120b56d0308dc |
|
13-Nov-2011 |
Michael Lotz <mmlr@mlotz.ch> |
Don't do the heap size calculation when using the slab as heap. The initial heap size calculation only applies to the legacy/debug heap, so it isn't needed when using the slab as kernel heap.
|
#
f8154d172da77bd77316f14c76d428bae7376323 |
|
02-Nov-2011 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
mmlr (distracted) + bonefish: * Turn VMCache::consumers C list into a DoublyLinkedList. * Use object caches for the different VMCache types and the VMCacheRefs. The purpose is to reduce slab area fragmentation. * Requires the introduction of a pure virtual VMCache::DeleteObject() method, implemented in the derived classes. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43133 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ffb6929a3b30dd9367feb64368e7c50448ff59dd |
|
31-Oct-2011 |
Michael Lotz <mmlr@mlotz.ch> |
bonefish+mmlr: Move blocking the 0xcccccccc and 0xdeadbeef address ranges from heap to VM init so that it also works when used in the slab allocator. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43047 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
02cd58f41875fb5291b1e700ed203de8fa5f0c4c |
|
27-Jun-2011 |
Michael Lotz <mmlr@mlotz.ch> |
Move resizing the page_protections before resizing the cache to avoid a needless resize operation that has to be undone and may fail when doing so. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42332 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
3fb17998a7e288589614d76a9f39c42b7a4c73b6 |
|
27-Jun-2011 |
Michael Lotz <mmlr@mlotz.ch> |
When resizing an area that has individual page protections (set via mprotect), we have to enlarge/shrink the array that holds them and assign a protection value for the additional pages as necessary. Otherwise we'll access invalid memory when looking up page protections for enlarged areas and get random protection values. Experienced with QEMU that sets page protections via mprotect on heap memory. When the heap was later enlarged, write access to the additional memory would result in permission denied errors and crashes. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42330 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
6244ea505189b422b5a246323427d66fa9ee90a6 |
|
21-Jun-2011 |
Michael Lotz <mmlr@mlotz.ch> |
Fix range check. The previous check would produce an off by one error making the last byte of an unmapped-but-still-there page non-readable (i.e. from B_NO_LOCK areas), causing such reads to fail in KDL. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42276 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
36dc99a3237d35b1591fbdb1662ab083126ed5c5 |
|
12-Jun-2011 |
Rene Gollent <anevilyak@gmail.com> |
Add private get_memory_properties() syscall which allows one to retrieve the address protection bits as well as the wiring flags for an arbitrary address in a team's address space. Will be used in the debugger for the purposes of the memory inspector/editor, in order to determine whether it can in fact allow editing for the currently inspected address range. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42129 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
24df65921befcd0ad0c5c7866118f922da61cb96 |
|
11-Jun-2011 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Merged signals-merge branch into trunk with the following changes: * Reorganized the kernel locking related to threads and teams. * We now discriminate correctly between process and thread signals. Signal handlers have been moved to teams. Fixes #5679. * Implemented real-time signal support, including signal queuing, SA_SIGINFO support, sigqueue(), sigwaitinfo(), sigtimedwait(), waitid(), and the addition of the real-time signal range. Closes #1935 and #2695. * Gave SIGBUS a separate signal number. Fixes #6704. * Implemented <time.h> clock and timer support, and fixed/completed alarm() and [set]itimer(). Closes #5682. * Implemented support for thread cancellation. Closes #5686. * Moved send_signal() from <signal.h> to <OS.h>. Fixes #7554. * Lots over smaller more or less related changes. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42116 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d78e0dc9d7d54ad07d6d73bda810b34ade1c5807 |
|
23-Jan-2011 |
Rene Gollent <anevilyak@gmail.com> |
CID 10326 - remove superfluous for loop. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40277 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
4535495d80c86e19e2610e7444a4fcefe3e0f8e6 |
|
10-Jan-2011 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Merged the signals branch into trunk, with these changes: * The team and thread kernel structures have been renamed to Team and Thread respectively and moved into the new BKernel namespace. * Several (kernel add-on) sources have been converted from C to C++ since private kernel headers are included that are no longer C compatible. Changes after merging: * Fixed gcc 2 build (warnings mainly in the scary firewire bus manager). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40196 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ce30d635e3bd49a8c0e8407b8b9ec6cc16d10e66 |
|
17-Oct-2010 |
Ithamar R. Adema <ithamar.adema@team-embedded.nl> |
* fix outdated commented dprintf (still useful for local debugging) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38990 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
b9447668707741085389f650383b018d33d7d0bf |
|
10-Jul-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Moved the vm_page initialization from vm_page.cpp:vm_page_init() to the new vm_page::Init(). * Made vm_page::wired_count private and added accessor methods. * Added VMCache::fWiredPagesCount (the number of wired pages the cache contains) and accessor methods. * Made more use of vm_page::IsMapped(). * vm_copy_on_write_area(): Added vm_page_reservation* parameter that can be used to request a special handling for wired pages. If given the wired pages are replaced by copies and the original pages are moved to the upper cache. * vm_copy_area(): - We don't need to do any wired ranges handling, if the source area is a B_SHARED_AREA, since we don't touch the area's mappings in this case. - We no longer wait for wired ranges of the concerned areas to disappear. Instead we use the new vm_copy_on_write_area() feature and just let it copy the wired pages. This fixes #6288, an issue introduced with the use of user mutexes in libroot: When executing multiple concurrent fork()s all but the first one would wait on the fork mutex, which (being a user mutex) would wire a page that the vm_copy_area() of the first fork() would wait for. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37460 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
fbcffaefd394deb4fb1d8b6fa8268823342b20f1 |
|
23-Jun-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Fixed non-x86 builds. __get_memory_map_haiku() must be the default. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37237 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
2a25d16d3321358f74112a184c5f917e0fc69195 |
|
23-Jun-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* get_memory_map(): Changed parameters types to fixed-width types. * Added BeOS compatibility wrappers for get_memory_map(), map_physical_memory(), and create_area(). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37232 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ef4fd448b5dc65bec12580a645fc202789b157f7 |
|
23-Jun-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
vm_create_anonymous_area(): Optimized the B_32_BIT_{FULL_LOCK,CONTIGUOUS} cases for B_HAIKU_PHYSICAL_BITS > 32 and accessible physical memory < 4 GB. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37231 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
9fb2d73772382ea2ccfb62e912f9bfb9c39ac26d |
|
23-Jun-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Replaced B_32_BIT_MEMORY by B_32_BIT_FULL_LOCK and B_32_BIT_CONTIGUOUS, so the constraint can be expressed more precisely. ATM B_32_BIT_FULL_LOCK is implemented as B_32_BIT_CONTIGUOUS when B_HAIKU_PHYSICAL_BITS > 32, though. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37226 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
91af25d302d49ee3d83cb554e14954082e2ecf28 |
|
21-Jun-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
vm_create_anonymous_area(): * Fixed check: If a low *or* high address restriction is given, we need to force B_CONTIGUOUS wiring. * Optimization: Contiguous single-page allocation can be allocated as full-lock, if the no low/high address restrictions are given. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37203 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
be87d0a03e67ba3a186b1b86f0169b611c9d0ef2 |
|
21-Jun-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Added area creation "lock" constant B_32_BIT_MEMORY for physically contiguous memory < 4 GB. * vm_create_anonymous_area(): Implemented support for B_LOMEM and B_32_BIT_MEMORY. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37200 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
13638944dbc6efe0623b2623fb6eb5c8a69cb34c |
|
21-Jun-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Removed never read VMCache::scan_skip. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37195 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
94226016cc6697177bd098b2c189657d02d65d50 |
|
21-Jun-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Mark caches of null areas temporary, so we don't try to write back modified pages when deleting the area. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37194 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
c955359cb6cf3e66b961fadc7f07552abdec4dad |
|
18-Jun-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added vm_available_not_needed_memory_debug(), a vm_available_not_needed_memory() version that can be called from within the kernel debugger. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37167 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
377ecfe797a9f1009dd38702151d2a8c84723018 |
|
14-Jun-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Renamed cache_type_to_string() to vm_cache_type_to_string() and made in kernel private. * Moved dumping code from dump_cache() to new VMCache::Dump(). * Override VMCache::Dump() in VMVnodeCache to also print the vnode. * Removed no longer needed VMCache::GetLock(). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37138 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
a8ad734f1c698917badb15e1641e0f38b3e9a013 |
|
14-Jun-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Introduced structures {virtual,physical}_address_restrictions, which specify restrictions for virtual/physical addresses. * vm_page_allocate_page_run(): - Fixed conversion of base/limit to array indexes. sPhysicalPageOffset was not taken into account. - Takes a physical_address_restrictions instead of base/limit and also supports alignment and boundary restrictions, now. * map_backing_store(), VM[User,Kernel]AddressSpace::InsertArea()/ ReserveAddressRange() take a virtual_address_restrictions parameter, now. They also support an alignment independent from the range size. * create_area_etc(), vm_create_anonymous_area(): Take {virtual,physical}_address_restrictions parameters, now. * Removed no longer needed B_PHYSICAL_BASE_ADDRESS. * DMAResources: - Fixed potential overflows of uint32 when initializing from device node attributes. - Fixed bounce buffer creation TODOs: By using create_area_etc() with the new restrictions parameters we can directly support physical high address, boundary, and alignment. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37131 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
1d26c7248fcd916adadc03b5fd59cfc4f2adfaa5 |
|
10-Jun-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
vm_page_allocate_page_run(): Added parameter "limit", specifying the upper physical address limit for the page run to allocate. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37086 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
641b3c82df3ef9e3611eb73989db338e97eb5780 |
|
09-Jun-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Renamed allocate_early_physical_page() to vm_allocate_early_physical_page() and made it public. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37072 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
2ea7b17cf341036024bd84c4f791f332b2e15e48 |
|
09-Jun-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* vm_allocate_early(): Replace "bool blockAlign" parameter by a more flexible "addr_t aligmnent". * X86PagingMethod32Bit::PhysicalPageSlotPool::InitInitial(), generic_vm_physical_page_mapper_init(): Use vm_allocate_early()'s alignment feature instead of aligning by hand. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37070 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
061851635545cd19bdd711282e63aee9f9a6379b |
|
06-Jun-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Debug output of map_backing_store(), vm_map_physical_memory[_vecs](): Print the potential input parameter (virtual address) rather than its address. As suggested by Andreas Faerber in #6141. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37029 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
1ba89e67eda21e7ad9e1ec57a53ae0a3436b8721 |
|
05-Jun-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Removed no-op VMTranslationMap::InitPostSem() and VMAddressSpace::InitPostSem(). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37025 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
2e04c067f9469ab67f3904287341fe4b01493b0a |
|
04-Jun-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Patch by Andreas Faerber: vm_free_unused_boot_loader_range(): Don't free any memory beyond the given range. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37010 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
1d578e15fe5b5c3ff62866ae81aef529d00d7762 |
|
02-Jun-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Fixed more address types related issues. Mostly printf() or comparison warnings, but also some oversights from earlier changes. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37000 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
435c43f5912b109e7d5cf682865d2061e62fad8c |
|
02-Jun-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Introduced type generic_io_vec, which is similar to iovec, but uses types that are wide enough for both virtual and physical addresses. * DMABuffer, IORequest, IOScheduler,... and code using them: Use generic_io_vec and generic_{addr,size}_t where necessary. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36997 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
64d79eff7290437d24b1a420537c3ed5c144ab96 |
|
27-May-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Changed physical_entry::{address,size} to phys_{addr,size}_t and changed map_physical_memory()'s physicalAddress parameter type from void* to phys_addr_t. This breaks source compatibility, but -- as long as phys_{addr,size}_t remain 32 bit wide -- keeps binary compatibility with BeOS. * Adjusted all code using the affected interfaces (Oh what fun!). Added a few TODOs in places where the wrong types (e.g. void* for physical addresses are used). Looks like quite a few drivers aren't 64 bit safe and others will break with PAE. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36960 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
147133b76cbb1603bdbff295505f5b830cb4e688 |
|
25-May-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* First run through the kernel's private parts to use phys_{addr,size}_t where appropriate. * Typedef'ed page_num_t to phys_addr_t and used it in more places in vm_page.{h,cpp}. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36937 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
f51bcfb25be138f58194c8e4fc86ae87f3ecb3c2 |
|
18-May-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added a heap_init_post_area() which is called right after areas can be created, and moved the heap's grow and VIP heap initialization to it. Should fix #5956. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36855 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
13fa4c845ac5f1e2167a30fcc4cee3925ec6619e |
|
06-May-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Introduced new area creation flag CREATE_AREA_DONT_COMMIT_MEMORY. map_backing_store() doesn't commit memory when this flag is given. * Used the new flag vm_copy_area(): We no longer commit memory for read-only areas. This prevents read-only mapped files from suddenly requiring memory after fork(). Might improve the situation on machines with very little RAM a bit. We should probably mark writable copies over-committing, since the usual case is fork() + exec() where the child normally doesn't need more than a few pages until calling exec(). That would significantly reduce the memory requirement for jamming the Haiku tree. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36651 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
7b926f5135dae9be57910a468456d5cc5b17137d |
|
05-May-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Allocate memory for the DEBUG_CACHE_LIST debug feature only when there's plenty available. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36634 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
7198f76564e4b062401bb95f6ddf540bbf9e8625 |
|
05-May-2010 |
Axel Dörfler <axeld@pinc-software.de> |
* During early kernel startup, we must not create areas without the CREATE_AREA_DONT_WAIT flag; waiting at this point is not allowed. * I hope I found all occurences, but there might be some areas left (note, only those that don't use B_ALREADY_WIRED are problematic). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36624 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
6f2772b1355a561fda836fb896110d59071580aa |
|
02-May-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
vm_map_physical_memory(): When alreadyWired we have to explicitly set the memory type for the mapped pages. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36590 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
c1be1e0761d0904d99dabd3d1638d94802b4b600 |
|
01-May-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* VMTranslationMap::Map()/Protect(): Added "memoryType" parameter. Not implemented for any architecture yet. * vm_set_area_memory_type(): Call VMTranslationMap::ProtectArea() to change the memory type for the already mapped pages. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36574 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
3b0c1b5227ab487b1963faea4d046cba4d0622ff |
|
01-May-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* VMArea: Made memory_type private and added setter and getter methods. * Don't set the VMArea's memory type in arch_vm_set_memory_type(), but let the callers do that. * vm_set_area_memory_type(): Does nothing, if the memory type doesn't change. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36573 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
907886143fe5656bb1ae0e616a9286b0ca8538c6 |
|
01-May-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Changed some parameters of VM syscalls from int to uint32, mostly for sake of consistency. * Moved the B_OVERCOMMITTING_AREA flag from B_KERNEL_AREA_FLAGS to B_USER_AREA_FLAGS, since we really allow it to be passed from userland. * Most VM syscalls check the provided protection against B_USER_AREA_FLAGS instead of B_USER_PROTECTION, now. This way they allow for B_OVERCOMMITTING_AREA as well. * _user_map_file(), _user_set_memory_protection(): Check the protection like the other syscalls do and use fix_protection() instead of doing that manually. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36572 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
278f7e57cda2ed43a21583538c749ce577604d89 |
|
30-Apr-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
map_backing_store(): Also consider the B_OVERCOMMITTING_AREA for private maps. The new cache will be created in over-committing mode. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36550 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
c1b8ab4ef0e809dd58158876c310ffebb13e38df |
|
26-Apr-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
vm_create_anonymous_area(): Allocate the page run for B_CONTIGUOUS areas before locking the address space. That gives us a bit more flexibility in vm_page_allocate_page_run(). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36486 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ccb3f07a141d506eb15c264034b6fbda94fe37f1 |
|
22-Apr-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
get_memory_map_etc(): Setting the return value to B_BUFFER_OVERFLOW in the loop causes the function to return before setting the _numEntries. The overflow case is checked at the end of the function anyway, so we can just break out. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36425 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ba16e4ec610c79f250d60c4746e4c86fb542d031 |
|
20-Apr-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
cut_area(): We should only resize RAM caches. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36372 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d97b5913aa2e755ec90cd4ad836c267aa517643c |
|
13-Apr-2010 |
Axel Dörfler <axeld@pinc-software.de> |
* Fixed incorrect indentation. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36258 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
e506fde883c37e843879cbef193f3caa10703bd3 |
|
13-Apr-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
wait_if_address_range_is_wired() was leaking a cache reference. Fixes #5710. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36237 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
c3676b54bfd2e06b73646d1846b2ab0272cb96e2 |
|
13-Apr-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Added vm_debug_copy_page_memory() which copies memory from a potentially not mapped page. * debug_{mem,strl}cpy(): - Added "team" parameter for specifying the address space the address are to be interpreted in. - When the standard memcpy() (with fault handler) fails, fall back to vm_debug_copy_page_memory(). * Added debug_is_debugged_team(): Predicate returning true, if the supplied team_id refers to the same team debug_get_debugged_thread() belongs to. * Added DebuggedThreadSetter class for scope-based debug_set_debugged_thread(). Made use of it in several debugger functions. * print_demangled_call() (x86): Fixed unsafe memory access. Allows KDL stack traces to work correctly again, even if the page daemon has already unmapped the concerned pages. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36230 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
aa26d107902039f78a211ce68d93f01b0117ad72 |
|
12-Apr-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
delete_area(): When the address space is the kernel address space, we need to pass stricter allocation flags to VMAddressSpace::{Remove,Delete}Area() or could deadlock otherwise. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36188 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
349039ff2e745b4b4e5870757e670ed51e0128e4 |
|
11-Apr-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added vm_[un]wire_page(), which are essentially versions of [un]lock_memory_etc() optimized for a single page. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36156 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
4f774c503c464ae50bfd3c710d78c372f9ca03e2 |
|
04-Apr-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* VMArea::Unwire(addr_t, size_t, bool): Don't delete the removed range, but return it. * lock_memory_etc(): On error the VMAreaWiredRange object could be leaked. * [un]lock_memory_etc(): Call VMArea::Unwire() with the cache locked and explicitly delete the range object after unlocking the cache to avoid potential deadlocks. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36035 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
369111e741ab2164041a0f3b4c1b4a6112d3532e |
|
05-Apr-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Removed the VMArea::Wire() version that has to allocate a VMAreaWiredRange. Since the requirement is that the area's top cache is locked, allocating memory isn't allowed. * lock_memory_etc(): Create the VMAreaWiredRange object explicitly before locking the area's top cache. Fixes #5680 (deadlocks when using the slab as malloc() backend). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36033 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
550376ffb83d09c9cdffdff7b9ab067d9fd70312 |
|
03-Apr-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* vm_delete_areas(): Changed return type to void (was status_t and not used). * _user_map_file(), _user_unmap_memory(): Verify that the address (if given) is page aligned. * Reworked memory locking (wiring): - VMArea does now have a list of wired memory ranges and supports waiting for a range to be removed. - vm_soft_fault(): - Added "wirePage" parameter that, if given, makes the function wire the page and return it. - Added "wiredRange" parameter (for calls from lock_memory_etc()) and made sure we never unmap wired pages. This could e.g. happen when a page from a lower cache was read-mapped and a write fault occurred. Now in such a situation the function waits for the page to be unwired and restarts. - All functions that manipulate areas in a way that could affect wired ranges do now either require the caller to make sure there are no wired ranges in the way or do that themselves. Added a few wait_if_*_is_wired() helper functions for that purpose. - lock_memory_etc(): - Does now also work correctly when the range spans more than one area. - Adds VMAreaWiredRanges to the affected VMAreas and retains an address space reference (so that the address space won't be deleted as long as a wired range exists). - Resolved TODO: The area's caches are now locked when increment_page_wired_count() is called. - Resolved TODO: The race condition due to missing locking after looking up the page mapping is now prevented. We hold the cache locks (in case the page is already mapped) and the new vm_soft_fault() parameter allows us to get the page wired. - unlock_memory_etc(): Changes symmetrical to those in lock_memory_etc() and resolved all TODOs. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36030 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d80af65fd8482496750e9120bf2c902e6f70e6df |
|
18-Mar-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
The "page" and the "cache" kernel debugger commands set a few temporary variables, now. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35903 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
98248b16126b11894695569f8c162e1cd7ac24d1 |
|
12-Mar-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Let the compiler decide whether to inline or not. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35821 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d40a9355605dff41924273711f9dc9df6da496d2 |
|
02-Mar-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Boot loader (x86 mmu.cpp): * Made the page table allocation more flexible. Got rid of sMaxVirtualAddress and added new virtual_end address to the architecture specific kernel args. * Increased the virtual space we reserve for the kernel to 16 MB. That should suffice for quite a while. The previous 2 MB were too tight when building the kernel with debug info. * mmu_init(): The way we were translating the BIOS' extended memory map to our physical ranges arrays was broken. Small gaps between usable memory ranges would be ignored and instead marked allocated. This worked fine for the boot loader and during the early kernel initialization, but after the VM has been fully set up it frees all physical ranges that have not been claimed otherwise. So those ranges could be entered into the free pages list and would be used later. This could possibly cause all kinds of weird problems, probably including ACPI issues. Now we add only the actually usable ranges to our list. Kernel: * vm_page_init(): The pages of the ranges between the usable physical memory ranges are now marked PAGE_STATE_UNUSED, the allocated ranges PAGE_STATE_WIRED. * unmap_and_free_physical_pages(): Don't free pages marked as unused. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35726 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ff59ce680df5d2032ea5a11c666688269225f033 |
|
24-Feb-2010 |
Axel Dörfler <axeld@pinc-software.de> |
* The low resource handler now empties the cache depot's magazines; before, they were never freed unless the cache was destroyed (I just wondered why my system would bury >1G in the magazines). * Made the magazine capacity variable per cache, ie. for larger objects, it's not a good idea to have 64*CPU buffers lying around in the worst case. * Furthermore, the create_object_cache_etc()/object_depot_init() now have arguments for the magazine capacity as well as the maximum number of full unused magazines. * By default, you might want to initialize both to zero, as then some hopefully usable defaults are computed. Otherwise (the only current example is the vm_page_mapping cache) you can just put in the values you'd want there. The page mapping cache uses larger values, as its objects are usually allocated and deleted in larger chunks. * Beware, though, I couldn't test these changes yet as Qemu didn't like to run today. I'll test these changes on another machine now. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35601 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
bd7645a12ab594d5eb1c6d6a70c3a82a429410dd |
|
20-Feb-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Made vm_page::state private and added accessor methods. * Added kernel tracing for page state transitions. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35538 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
dac21d8bfe3fcb0ee34a4a0c866c2474bfb8b155 |
|
18-Feb-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* 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
|
#
176f7588ebeee0d1fba3267c72aa6d85e63ab1cd |
|
17-Feb-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added warning to vm_map_physical_memory_vecs(). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35508 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
665e7ac62997b2a64794dd8e94daff2fad437dc2 |
|
16-Feb-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
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
|
#
0f2666ecc22a7625923af8cbef3fddcac160129c |
|
15-Feb-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
_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
|
#
40bb94819e6c39d72ab29edc1a0dcd80b15b8b42 |
|
03-Feb-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Removed useless return parameter from vm_remove_all_page_mappings(). * Added vm_clear_page_mapping_accessed_flags() and vm_remove_all_page_mappings_if_unaccessed(), which combine the functionality of vm_test_map_activation(), vm_clear_map_flags(), and vm_remove_all_page_mappings(), thus saving lots of calls to translation map methods. The backend is the new method VMTranslationMap::ClearAccessedAndModified(). * Started to make use of the cached page queue and changed the meaning of the other non-free queues slightly: - Active queue: Contains mapped pages that have been used recently. - Inactive queue: Contains mapped pages that have not been used recently. Also contains unmapped temporary pages. - Modified queue: Contains unmapped modified pages. - Cached queue: Contains unmapped unmodified pages (LRU sorted). Unless we're actually low on memory and actively do paging, modified and cached queues only contain non-temporary pages. Cached pages are considered quasi free. They still belong to a cache, but since they are unmodified and unmapped, they can be freed immediately. And this is what vm_page_[try_]reserve_pages() do now when there are no more actually free pages at hand. Essentially this means that pages storing cached file data, unless mmap()ped, no longer are considered used and don't contribute to page pressure. Paging will not happen as long there are enough free + cached pages available. * Reimplemented the page daemon. It no longer scans all pages, but instead works the page queues. As long as the free pages situation is harmless, it only iterates through the active queue and deactivates pages that have not been used recently. When paging occurs it additionally scans the inactive queue and frees pages that have not been used recently. * Changed the page reservation/allocation interface: vm_page_[try_]reserve_pages(), vm_page_unreserve_pages(), and vm_page_allocate_page() now take a vm_page_reservation structure pointer. The reservation functions initialize the structure -- currently consisting only of a count member for the number of still reserved pages. vm_page_allocate_page() decrements the count and vm_page_unreserve_pages() unreserves the remaining pages (if any). Advantages are that reservation/ unreservation mismatches cannot occur anymore, that vm_page_allocate_page() can verify that the caller has indeed a reserved page left, and that there's no unnecessary pressure on the free page pool anymore. The only disadvantage is that the vm_page_reservation object needs to be passed around a bit. * Reworked the page reservation implementation: - Got rid of sSystemReservedPages and sPageDeficit. Instead sUnreservedFreePages now actually contains the number of free pages that have not yet been reserved (it cannot become negative anymore) and the new sUnsatisfiedPageReservations contains the number of pages that are still needed for reservation. - Threads waiting for reservations do now add themselves to a waiter queue, which is ordered by descending priority (VM priority and thread priority). High priority waiters are served first when pages become available. Fixes #5328. * cache_prefetch_vnode(): Would reserve one less page than allocated later, if the size wasn't page aligned. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35393 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
e65c400299386f99a251395ff2e59572705d7e49 |
|
29-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Replaced the vm_page_allocate_page*() "pageState" parameter by a more general "flags" parameter. It encodes the target state of the page -- so that the page isn't unnecessarily put in the wrong page queue first -- a flag whether the page should be cleared, and one to indicate whether the page should be marked busy. * Added page state PAGE_STATE_CACHED. Not used yet. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35333 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
72382fa6291e810be2949a70abd8f274f92dbd2c |
|
29-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Removed the page state PAGE_STATE_BUSY and instead introduced a vm_page::busy flag. The obvious advantage is that one can still see what state a page is in and even move it between states while being marked busy. * Removed the vm_page::is_dummy flag. Instead we mark marker pages busy, which in all cases has the same effect. Introduced a vm_page_is_dummy() that can still check whether a given page is a dummy page. * vm_page_unreserve_pages(): Before adding to the system reserve make sure sUnreservedFreePages is non-negative. Otherwise we'd make nonexisting pages available for allocation. steal_pages() still has the same problem and it can't be solved that easily. * map_page(): No longer changes the page state/mark the page unbusy. That's the caller's responsibility. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35331 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ab33f2d9611c642b87122590965cdd7ae0c916d0 |
|
28-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
vm_create_null_area(): The area was created with B_NO_LOCK which would cause the wired count of manually mapped pages not to be decremented in delete_area(), leading to a "pages still has mappings" panic when the slab allocator's memory manager deleted areas. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35329 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
deee8524b7534d9b586cbcbf366d0660c9769a8e |
|
26-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Introduced {malloc,memalign,free}_etc() which take an additional "flags" argument. They replace the previous special-purpose allocation functions (malloc_nogrow(), vip_io_request_malloc()). * Moved the I/O VIP heap to heap.cpp accordingly. * Added quite a bit of passing around of allocation flags in the VM, particularly in the VM*AddressSpace classes. * Fixed IOBuffer::GetNextVirtualVec(): It was ignoring the VIP flag and always allocated on the normal heap. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35316 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
cff6e9e406132a76bfc20cb35ff5228dd0ba94d8 |
|
26-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* The system now holds back a small reserve of committable memory and pages. The memory and page reservation functions have a new "priority" parameter that indicates how deep the function may tap into that reserve. The currently existing priority levels are "user", "system", and "VIP". The idea is that user programs should never be able to cause a state that gets the kernel into trouble due to heavy battling for memory. The "VIP" level (not really used yet) is intended for allocations that are required to free memory eventually (in the page writer). More levels are thinkable in the future, like "user real time" or "user system server". * Added "priority" parameters to several VMCache methods. * Replaced the map_backing_store() "unmapAddressRange" parameter by a "flags" parameter. * Added area creation flag CREATE_AREA_PRIORITY_VIP and slab allocator flag CACHE_PRIORITY_VIP indicating the importance of the request. * Changed most code to pass the right priorities/flags. These changes already significantly improve the behavior in low memory situations. I've tested a bit with 64 MB (virtual) RAM and, while not particularly fast and responsive, the system remains at least usable under high memory pressure. As a side effect the slab allocator can now be used as general memory allocator. Not done by default yet, though. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35295 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
b4e5e4982360e684c5a13d227b9a958dbe725554 |
|
25-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
MemoryManager: * Added support to do larger raw allocations (up to one large chunk (128 pages)) in the slab areas. For an even larger allocation an area is created (haven't seen that happen yet, though). * Added kernel tracing (SLAB_MEMORY_MANAGER_TRACING). * _FreeArea(): Copy and paste bug: The meta chunks of the to be freed area would be added to the free lists instead of being removed from them. This would corrupt the lists and also lead to all kinds of misuse of meta chunks. object caches: * Implemented CACHE_ALIGN_ON_SIZE. It is no longer set for all small object caches, but the block allocator sets it on all power of two size caches. * object_cache_reserve_internal(): Detect recursion and don't wait in such a case. The function could deadlock itself, since HashedObjectCache::CreateSlab() does allocate memory, thus potentially reentering. * object_cache_low_memory(): - I missed some returns when reworking that one in r35254, so the function might stop early and also leave the cache in maintenance mode, which would cause it to be ignored by object cache resizer and low memory handler from that point on. - Since ReturnSlab() potentially unlocks, the conditions weren't quite correct and too many slabs could be freed. - Simplified things a bit. * object_cache_alloc(): Since object_cache_reserve_internal() does potentially unlock the cache, the situation might have changed and their might not be an empty slab available, but a partial one. The function would crash. * Renamed the object cache tracing variable to SLAB_OBJECT_CACHE_TRACING. * Renamed debugger command "cache_info" to "slab_cache" to avoid confusion with the VMCache commands. * ObjectCache::usage was not maintained anymore since I introduced the MemoryManager. object_cache_get_usage() would thus always return 0 and the block cache would not be considered cached memory. This was only of informational relevance, though. slab allocator misc.: * Disable the object depots of block allocator caches for object sizes > 2 KB. Allocations of those sizes aren't so common that the object depots yield any benefit. * The slab allocator is now fully self-sufficient. It allocates its bootstrap memory from the MemoryManager, and the hash tables for HashedObjectCaches use the block allocator instead of the heap, now. * Added option to use the slab allocator for malloc() and friends (USE_SLAB_ALLOCATOR_FOR_MALLOC). Currently disabled. Works in principle and has virtually no lock contention. Handling for low memory situations is yet missing, though. * Improved the output of some debugger commands. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35283 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
148637e9d081dca4371b93dac198b366c014eabf |
|
22-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Use large slabs for the page mappings. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35247 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
8d1316fd23616f6dac131a0eba5dab08acc6e76d |
|
22-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Replaced CACHE_DONT_SLEEP by two new flags CACHE_DONT_WAIT_FOR_MEMORY and CACHE_DONT_LOCK_KERNEL_SPACE. If the former is given, the slab memory manager does not wait when reserving memory or pages. The latter prevents area operations. The new flags add a bit of flexibility. E.g. when allocating page mapping objects for userland areas CACHE_DONT_WAIT_FOR_MEMORY is sufficient, i.e. the allocation will succeed as long as pages are available. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35246 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
8a65066a1118e111cc8a9c3505e5689e53f3e5c4 |
|
22-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
vm_soft_fault(): map_page() can fail for B_NO_LOCK areas, since it needs to allocate a page mapping. In that case we do at least have to mark the page not busy again. Furthermore we enforce the minimum page mappings object cache reserve, so we'll have more luck on the next fault. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35241 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
86c794e5c10f1b2d99d672d424a8637639c703dd |
|
21-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
slab allocator: * Implemented a more elaborated raw memory allocation backend (MemoryManager). We allocate 8 MB areas whose pages we allocate and map when needed. An area is divided into equally-sized chunks which form the basic units of allocation. We have areas with three possible chunk sizes (small, medium, large), which is basically what the ObjectCache implementations were using anyway. * Added "uint32 flags" parameter to several of the slab allocator's object cache and object depot functions. E.g. object_depot_store() potentially wants to allocate memory for a magazine. But also in pure freeing functions it might eventually become useful to have those flags, since they could end up deleting an area, which might not be allowable in all situations. We should introduce specific flags to indicate that. * Reworked the block allocator. Since the MemoryManager allocates block-aligned areas, maintains a hash table for lookup, and maps chunks to object caches, we can quickly find out which object cache a to be freed allocation belongs to and thus don't need the boundary tags anymore. * Reworked the slab boot strap process. We allocate from the initial area only when really necessary, i.e. when the object cache for the respective allocation size has not been created yet. A single page is thus sufficient. other: * vm_allocate_early(): Added boolean "blockAlign" parameter. If true, the semantics is the same as for B_ANY_KERNEL_BLOCK_ADDRESS. * Use an object cache for page mappings. This significantly reduces the contention on the heap bin locks. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35232 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
15779f70b9425e2191c59908d699ae5437a9b9fc |
|
20-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
vm_get_page_mapping(): The translation map wasn't locked. For x86 the function is used only in one place and the missing locking would be harmless if it weren't for the per translation map physical page mapper. It is used to map the page table for the lookup. Concurrent access could corrupt its data structures, or, just as bad, the unlocked Query() could remap the page table used by a concurrent Map() or Unmap(), which would then manipulate the wrong page table. Potentially messing up kernel memory, this bug could obviously cause all kinds of kernel crashes and weird behavior. E.g. ticket #5138 is a likely candidate, as are triple faults. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35195 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
c40914bbf517a6ddd4e55507b64646052f830526 |
|
19-Jan-2010 |
Rene Gollent <anevilyak@gmail.com> |
Fix build with VM_PAGE_FAULT_TRACING enabled. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35187 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
825566f82f652d82ffaf3f0deca0a2bcda1e02c2 |
|
19-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* 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
|
#
6379e53e2dd7021ba0e35d41c276dfe94c079596 |
|
19-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
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
|
#
3632eeedb954ead74b9cbdfcd664ff3dcb6eba57 |
|
18-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* 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
|
#
f082f7f019941732f1d2b99f627fbeeeec3746af |
|
15-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* 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
|
#
bcc2c157a1c54f5169de1e7a3e32c49e92bbe0aa |
|
13-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
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
|
#
946325051bcbdb05b1bf2466ed03bed13f36bf59 |
|
13-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* 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
|
#
a99debff88c7686224888f37a408cab2a8376e7b |
|
13-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added TODOs. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35056 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
3b8c056da097f1b7386f013726bb3ad13ea2ef98 |
|
11-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
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
|
#
451ca8b4b43e650a8c6cd7edd7f59640ebfee7f9 |
|
11-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
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
|
#
afed2658f4ef3e3df5ff8390d1d7a51b5b897a9e |
|
08-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* 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
|
#
aac9b8e4af076987756b680efd68e31e4cae3aee |
|
08-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
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
|
#
bd0bff449fc5d807afe3531aa6fac39a49b3b898 |
|
07-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
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
|
#
3cd2094396dde9ca42263c535041a95d5f0d5fff |
|
06-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* 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
|
#
cb8617c1d4562a7569e73b60c9c0f2001e63abb1 |
|
05-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
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
|
#
8d9e8ba5b70f37507b4e950e31c595a58861137e |
|
02-Jan-2010 |
Stephan Aßmus <superstippi@gmx.de> |
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
|
#
16f50e3394442f855189d8c795ab6fbc08479fb6 |
|
02-Jan-2010 |
Stephan Aßmus <superstippi@gmx.de> |
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
|
#
1021fd28262697dbbbe1d54a868f0672900c78f3 |
|
01-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* 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
|
#
2e74d74f4f6d3023650b9525a425f760ea86f007 |
|
22-Dec-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* 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
|
#
1339ccf411dd372ce69edd091e46349c179b4cf1 |
|
08-Dec-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* 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
|
#
522c2f19d458245474fcaf5b0254e0099906b117 |
|
07-Dec-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* 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
|
#
bcfdfff497aba5fa87a98f60788297b6381b5681 |
|
06-Dec-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
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
|
#
40cd019ea0415011db2a82c736e716a22ca842cc |
|
06-Dec-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* 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
|
#
2c1886aeae1be8dc6bb9656701b2aab5bf3311ca |
|
04-Dec-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* 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
|
#
38a97b2c36a42758a143aef034e0a3fc70440934 |
|
04-Dec-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
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
|
#
f69032f22b9fdf7ea2a3287e162abe39882ce373 |
|
03-Dec-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* 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
|
#
bbd97b4bb41cc03735528962ff53d89a2a2d7ff2 |
|
03-Dec-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
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
|
#
35d940014e100b8ca09eaf294b86fb9ef905b1e0 |
|
02-Dec-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* 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
|
#
def9898c9b96d366f32c39f0143e265442bd429a |
|
02-Dec-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
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
|
#
f34a1dd5d701373687b6f3f0e6e76bd2b1ae6007 |
|
02-Dec-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
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
|
#
e50cf8765be50a7454c9488db38b638cf90805af |
|
02-Dec-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* 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
|
#
90d870c1556bdc415c7f41de5474ebebb0ceebdd |
|
02-Dec-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* 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
|
#
a477e3cf200097774f88ed4e4134f87674a2a063 |
|
01-Dec-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Finished renaming of vm_cache to VMCache. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34424 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
a99eb6b56f61bd847d246e44885618fdeaa313a1 |
|
01-Dec-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
vm_area -> VMArea git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34423 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
b0db552cd921ff16d61400ee5a5f855f392e8b87 |
|
01-Dec-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Renamed vm_address_space to VMAddressSpace. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34422 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
b8a73945cf1374711b8175918ca3ced29bb97c62 |
|
27-Nov-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* 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
|
#
95235380f19105a88cbad905a55b2889ea3a3ba9 |
|
26-Nov-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* Minor clarification. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34307 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ebcdd1fc612df8f9ab32c08709ffd2323ded44e9 |
|
07-Nov-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* r33436 broke user_strlcpy() semantics: with a size of 0, "to" can be ignored, and it's still a valid call. * This fixes ktrace_printf() from userland. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33934 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
f1488adbf702d0ed3c467eceb082c7172a6972e7 |
|
15-Oct-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* While r33037 fixed the alignment of areas put into reserved areas, it actually broke their placement at the end of the reserved area, which was the main reason #4778 happened so often (it would have been more hidden else). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33598 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
4124f4801ba281731fe2aa841835d31c9d886e52 |
|
15-Oct-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* Reserved areas would also be created in existing reserved areas in case the space was becoming tight. This actually fixes #4778. * Fixed overflow problem in find_reserved_area(). * Cleaned up the test app, added license. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33597 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d5a396a60b95b76ded7336f02d825ec80ab79a5d |
|
14-Oct-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* r33037 broke the handling of reserved areas, more specifically, it ignored the RESERVED_AVOID_BASE flag of those, and introduced a way to fill them from the start. This caused #4778. * Turned IS_VALID_SPOT() macro into an inline function. * Removed already resolved TODO comment. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33581 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
44778a8a28abfacb4504e5b37b8e1fb760736e4a |
|
11-Oct-2009 |
Michael Lotz <mmlr@mlotz.ch> |
Introduce vm_map_physical_memory_vecs. It is like vm_map_physical_memory but takes a list of iovecs describing the physical pages to be mapped. With it one can map a set of physically disjoint pages into one linear virtual range. This is a private API right now, but we might want to make it public as map_physical_memory_vecs alongside map_physical_memory. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33523 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
aa6f54aa24c3b1cfb4f8864dafd0e1a135fdb7f4 |
|
08-Oct-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Amended the {user,debug}_strlcpy() fix: Due to the strlcpy() semantics to always return the source string length, we can't really prevent an overflow of the source address. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33489 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
8a71915a9df58aca2347b87f6ee4f7d60516786e |
|
05-Oct-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Made the {debug,user}_{mem,strl}cpy() and user_memset() functions deal with address overflows. Apparently at least the x86 string instructions generate a general protection fault instead of a page fault, and we only use the fault handler in the latter case (maybe we should change that, too). Fixes #4714. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33436 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
1bcca32a9e8f1e1c4e213af86bf34b9d58c9e55a |
|
11-Sep-2009 |
Michael Lotz <mmlr@mlotz.ch> |
* Also take into account that the alignment due to B_ANY_KERNEL_BLOCK_ADDRESS can cause overflows. * Added a generic IS_VALID_SPOT() macro that checks for overflows and checks if the area will fit with the given constraints. * Use the macro to simplify the places where these checks are necessary. * Use the provided "end" limit instead of the address space end. It currently doesn't matter but makes more sense. * Rename newBase variables to alignedBase as that's what they are. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33061 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
e717a35b6ffe7f0750cb8bda2ea44bb01522ac60 |
|
10-Sep-2009 |
Michael Lotz <mmlr@mlotz.ch> |
* Change the way we check for enough available space when searching for spots to insert areas so we don't overflow. * Consequently use the area end (base + size - 1) where appropriate which prevents overflows in a few places. * Properly check for reaching the address space end. * If we've already found a spot we don't need to recheck if we've found one. * Simplify the B_EXACT_ADDRESS checks down to a simpler single if statement instead of the four seperate ones. * Properly calculate the search end for B_EXACT_ADDRESS as well, it's also base + size - 1. * Block the full last page now that this actually works without overflowing. * Some style changes and added spacing. This should now really fix #2550. Previously the overflow protection didn't actually work because on allocation we overflowed and completely missed the protecting area. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33037 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
5332eb402bba7af78d895ff71dde15ff86aa4d09 |
|
09-Sep-2009 |
Michael Lotz <mmlr@mlotz.ch> |
Style fix. I really tried hard, but still failed... git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33034 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
9aff7f1593f547ec37b28a17e342994a66992999 |
|
09-Sep-2009 |
Michael Lotz <mmlr@mlotz.ch> |
Block the very last page of kernel address space. The problem here is that non of the VM functions handling areas are overflow safe. If an area is created that spans across the last page many places will run into an integer overflow. This mostly concerns the area allocation path in find_and_insert_area_slot() and also vm_create_anonymous_area() where the loop for mapping pages for B_FULL_LOCK areas overflows and runs more times than it should leading to #2550. This could be seen as a workaround. The real fix would be to make everything overflow safe. The thing is that this does also concern the user of the area which could easily have forgotten to check for overflows as well, so I am a bit uneasy with handing out areas that could easily lead to such hard to debug problems. Since this is really an edge case and this single step safes quite a bit of extra checks I'd actually be OK with keeping it that way. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33032 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
3794518c2dc674bd7c507bd81759e88df6dec6d7 |
|
09-Sep-2009 |
Michael Lotz <mmlr@mlotz.ch> |
Also check for read-protection of an area. Adjusted naming from read-only to write-protected and read-protected. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33031 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
0f4242de4031fba2e3f596c273a271cc782063f0 |
|
09-Sep-2009 |
Michael Lotz <mmlr@mlotz.ch> |
Implement a vm_block_address_range() function which creates an area with no mapped pages and a non-read and non-write protection to block a certain address range from being used by anything. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33030 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
45ed4939f982689d2d719e9e3decf1d6b194fe02 |
|
05-Aug-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* area_for() now also returns the area ID for kernel areas if they are accessible to the userland - this fixes #2405 (ie. MediaPlayer overlay now works). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32135 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ea2abd110bd6a4518a954477562e2dd94a5fef9d |
|
02-Aug-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Renamed the ROUNDOWN macro to ROUNDDOWN. Also changed the implementation of ROUNDUP to use '*' and '/' -- the compiler will optimize that for powers of two anyway and this implementation works for other numbers as well. * The thread::fault_handler use in C[++] code was broken with gcc 4. At least when other functions were invoked. Trying to trick the compiler wasn't a particularly good idea anyway, since the next compiler version could break the trick again. So the general policy is to use the fault handlers only in assembly code where we have full control. Changed that for x86 (save for the vm86 mode, which has a similar mechanism), but not for the other architectures. * Introduced fault_handler, fault_handler_stack_pointer, and fault_jump_buffer fields in the cpu_ent structure, which must be used instead of thread::fault_handler in the kernel debugger. Consequently user_memcpy() must not be used in the kernel debugger either. Introduced a debug_memcpy() instead. * Introduced debug_call_with_fault_handler() function which calls a function in a setjmp() and fault handler context. The architecture specific backend arch_debug_call_with_fault_handler() has only been implemented for x86 yet. * Introduced debug_is_kernel_memory_accessible() for use in the kernel debugger. It determines whether a range of memory can be accessed in the way specified. The architecture specific back end arch_vm_translation_map_is_kernel_page_accessible() has only been implemented for x86 yet. * Added arch_debug_unset_current_thread() (only implemented for x86) to unset the current thread pointer in the kernel debugger. When entering the kernel debugger we do some basic sanity checks of the currently set thread structure and unset it, if they fail. This allows certain commands (most importantly the stack trace command) to avoid accessing the thread structure. * x86: When handling a double fault, we do now install a special handler for page faults. This allows us to gracefully catch faulting commands, even if e.g. the thread structure is toast. We are now in much better shape to deal with double faults. Hopefully avoiding the triple faults that some people have been experiencing on their hardware and ideally even allowing to use the kernel debugger normally. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32073 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d3b44ccb1470db823a443d0f9b32e09bfa0d0a9c |
|
29-Jul-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added explicit physical address parameter to vm_create_anonymous_area() and create_area_etc(). 0 for the default behavior. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31941 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
069b477dd77f60067206414b78a0edb23404482f |
|
29-Jul-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Introduced CREATE_AREA_DONT_CLEAR create_area_etc() flag, which allows the call to fetch non-clear pages. * B_PHYSICAL_BASE_ADDRESS does now imply B_CONTIGUOUS. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31932 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
4cb7d2e55de051dfa8e7b7ca9c6f74960e2fc719 |
|
29-Jul-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31915 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
5fbad060b393d0ea6d13c0800c28b313de3add93 |
|
17-Jul-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* Work-in-progress on a kernel profile service that can be evaluated from userland afterwards. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31621 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
3609af391d646e2629e70e7b214a79ed57578ffc |
|
19-Jun-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* Renamed _kern_reserve_heap_address_range() to _kern_reserve_address_range(), and added a _kern_unreserve_address_range() as well. * The runtime loader now reserves the space needed for all its areas first to make sure there is enough space left for all areas of a single image. * This also fixes the final part of bug #4008. * Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31115 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
82db8a9e159b60e775b4cab31d54ac40fe95de53 |
|
19-Jun-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* Added an "unmapAddressRange" argument to the file mapping syscall. This is the first part of making the runtime loader behave itself; it should already make Clockwerk run okay with any number of translators (even if not all of them will work yet). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31113 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
eb0262fc4cc8209ed0ae4274ca637145a2de6b3f |
|
28-May-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Reworked vm_soft_fault() and friends: - While walking down the cache chain, we keep all upper caches locked. - When we have to unlock -- when waiting for a busy page or reading a page in -- we unlock completely, including the address space, and restart vm_soft_fault(). - Folded fault_get_page() and fault_find_page() into one. This simplifies and improves things considerably: - We no longer need dummy pages. - We no longer need vm_area::no_cache_change. - #2710 is fixed, since we no longer hold the address space lock while waiting. * vm_soft_fault(): When we have found our page, we first check whether a page is already mapped at the address. If it is already our page, we just change its protection. If not, we unmap it first. Fixes race conditions when multiple threads fault at the same address at the same time. * fault_get_page(): When copying a read-only page from a lower cache, no longer mark it active, since at least for the fault area it is shadowed from then on. * vm_set_area_protection(): Fixed potential overflow for in the vm_translation_map::protect() call. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30911 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
6a79745b4cd9383b148206a7ee997d0a29327f45 |
|
27-May-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Disabled the stack traces on unhandled userland page faults. As was already known those can cause a deadlock. Besides, when the debug server is running, it prints an even nicer stack trace. Not removing the code yet to make things easier for architectures on which we don't have a userland yet. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30877 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d5ad762913429ae34478222a0c87199be0709439 |
|
30-Apr-2009 |
Axel Dörfler <axeld@pinc-software.de> |
Fixed several problems of the prefetching code: * Did claim to have reserved pages when calling vm_page_allocate_page(), but didn't have any (copy&paste bug). We cannot use it without reserved pages, as we need to call vm_page_allocate_page() with a cache locked. * No longer use low_resource_state() to determine whether to precache or not, but use the new vm_page_num_used_pages() instead. * Also don't (try to) precache when the cache already has more than 2/3 of its pages to safe some unnecessary work. * The size to precache was limited to the file size incorrectly. * When precaching failed, the cache reference was not released. * The precaching started one page too late, causing bug #3835. * Reenabled precaching. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30515 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
996af6d99709d3e2a89f45f1b5d7ab41ad48d82f |
|
28-Apr-2009 |
Stephan Aßmus <superstippi@gmx.de> |
Disable pre-fetching until we fix bug #3835. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30477 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
eb2bd0e8e3689998717f91d8b9023296e3f32e78 |
|
27-Apr-2009 |
Stephan Aßmus <superstippi@gmx.de> |
axeld: * Implemented a way to do asynchronous pre-fetching when mapping files. * There are slight code duplications in some places that could benefit from cleaning up, but nothing too bad. * Implementing smarter ways to trigger prefetching and more analysis of the situations in the kernel would be nice. Currently up to 10 MB of every mapped file are pre-fetched without further analysis. * The speed improvement is nice for certain operations. On our test system (real hardware), Firefox took 9 seconds from being launched to display a window. Now it takes 5 seconds. Both measurements right after booting. The same system took 35 seconds from launching Haiku in the GRUB menu to displaying the Tracker desktop background image. Now it takes 27 seconds. * We didn't have the chance to check out the effects of this on the CD boot, but potentially, they could speed it up a lot. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30465 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
f9ae64e9a5bb77002b1e29f0f3326ce64ebdc841 |
|
06-Apr-2009 |
Oliver Tappe <zooey@hirschkaefer.de> |
zooey + bonefish: * optimized unmapping of a single page that was rather inefficient for large areas git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29978 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
defc7c56fb93b6b4cafa306edac002a6d3a6b123 |
|
19-Mar-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* One should not rely on the comma operator being evaluated right-to-left as it was done in SAS/C... (yeah, that was ages ago). This fixes bug #2030. * Also, we should probably check if the area we're about to shrink/remove actually is a reserved area. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29605 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
24ace12957601208c260bb9a826a8902a5003d0f |
|
13-Mar-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* Worked over the "area" KDL command to make it more useful, and easier to use. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29503 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
e0b0a173b6d5f152b8073746885b4ac06cf93e84 |
|
11-Mar-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* Cleanup, no functional change. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29478 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
aa4ba93e25c1c63730ba69e04d3d96c3253924fd |
|
08-Mar-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Renamed src/system/kernel/device_manager/io_requests.{h,cpp} to IORequest.{h,cpp}. * Introduced public <io_requests.h> header. Currently it only declares the single function BFS uses. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29446 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
c33667d400856680a8e0122300861eda77d1847a |
|
01-Feb-2009 |
Michael Lotz <mmlr@mlotz.ch> |
Fixing warnings under GCC4 in preparation to enable -Werror there as well: * Replaced the use of offsetof() for structs that aren't PODs. Add a offset_of_member() macro to util/khash.h because that's what it's used for in our cases. * Change the signature of add_debugger_command()/remove_debugger_command() on GCC > 2 to avoid the depricated conversion from string constants to char *. * Adding some "suggested" parenthesis. I know that not everyone likes that, but it pointed out at least one bug that is fixed here as well. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29113 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
b2cfc2b1c0696ecab857119653ce033372935bc1 |
|
23-Oct-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Added kernel tracing for page faults. * vm_clone_area() does now set the B_SHARED_AREA flag on both the source and the cloned area. This is necessary, since it would no longer be guaranteed that areas are backed by leaf caches only (after fork()ing), which doesn't work with our cache merging strategy. Fixes #2605. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28296 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
59dbd26f5f41a6c1272f6cac9c8cda4b19b79097 |
|
20-Oct-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Moved more debug macros to kernel_debug_config.h. * Turned the checks for all those macros to "#if"s instead of "#ifdef"s. * Introduced macro KDEBUG_LEVEL which serves as a master setting. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28248 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
1894a0a98b5b2102f83c00b7273ba7654334f469 |
|
20-Oct-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Consistently use KDEBUG. It is always defined and therefore must be checked with "#if". git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28247 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
47c40a10a10dc615e078754503f2c19b9f98c38d |
|
19-Oct-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Prefixed memset_physical() and memcpy_to_physical() with "vm_", added vm_memcpy_from_physical() and vm_memcpy_physical_page(), and added respective functions to the vm_translation_map operations. The architecture specific implementation can now decide how to implement them most efficiently. Added generic implementations that can be used, though. * Changed vm_{get,put}_physical_page(). The former no longer accepts flags (the only flag PHYSICAL_PAGE_DONT_WAIT wasn't needed anymore). Instead it returns an implementation-specific handle that has to be passed to the latter. Added vm_{get,put}_physical_page_current_cpu() and *_debug() variants, that work only for the current CPU, respectively when in the kernel debugger. Also adjusted the vm_translation_map operations accordingly. * Made consequent use of the physical memory operations in the source tree. * Also adjusted the m68k and ppc implementations with respect to the vm_translation_map operation changes, but they are probably broken, nevertheless. * For x86 the generic physical page mapper isn't used anymore. It is suboptimal in any case. For systems with small memory it is too much overhead, since one can just map the complete physical memory (that's not done yet, though). For systems with large memory it counteracts the VM strategy to reuse the least recently used pages. Since those pages will most likely not be mapped by the page mapper anymore, it will keep remapping chunks. This was also the reason why building Haiku in Haiku was significantly faster with only 256 MB RAM (since that much could be kept mapped all the time). Now we're using a different strategy: We have small pools of virtual page slots per CPU that are used for the physical page operations (memset_physical(), memcpy_*_physical()) with CPU-pinned thread. Furthermore we have four slots per translation map, which are used to map page tables. These changes speed up the Haiku image build in Haiku significantly. On my Core2 Duo 2.2 GHz 2 GB machine about 40% to 20 min 40 s (KDEBUG disabled, block cache debug disabled). Still more than factor 3 slower than FreeBSD and Linux, though. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28244 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
901f1930e117a09793b2f4feff24d104bea5c577 |
|
17-Oct-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Moved memset_physical() to vm.cpp and made it available in the kernel. * Added memcpy_to_physical(). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28219 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
1b6eff280f4afcf4d7c9dc9ccdc3a65f4e6ca0fd |
|
11-Oct-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Replaced the vm_get_physical_page() "flags" PHYSICAL_PAGE_{NO,CAN}_WAIT into an actual flag PHYSICAL_PAGE_DONT_WAIT. * Pass the flags through to the chunk mapper callback. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27979 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d654f56af243580068a6260e11e5c832b325d291 |
|
11-Oct-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Added kernel tracing for the page daemon and the page writer. * Added some commented out debug output in vm.cpp. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27971 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
4eaa43ac48bb4936de09b85827893c9beb90b51c |
|
11-Oct-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Added "flags" parameter to VMCache::Read(). * Use the new VMCache::Read() flags parameter to directly read into the physical page in the page fault handler instead of mapping it first. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27966 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
4129f846032ae0cdec1fe55000520c1b87c11152 |
|
08-Oct-2008 |
François Revol <revol@free.fr> |
- add team id on a TRACE() - try to accomodate for low ram systems by making the first kernel heap allocation smaller git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27943 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
7805eb0cc29e1762d9c0bb207f5f9a910f292bf7 |
|
27-Sep-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Changed the handling for hardware-caused terminal signals: * No longer send a SIGKILL when a page fault occurred, there was no signal handler, and the debugger told us to continue as usual. Instead we send a SIGSEGV. Instead in handle_signal() when not in the main thread and there's no handler for the signal, we first send the main thread a SIGKILL before letting the thread die. So in cases where the main thread caused an unhandled page fault, the team will die from the SIGSEGV, now. This fixes bug #2773. * For the other hardware-caused signals we do now do the same as in case of page faults, i.e. we first check whether the thread has a handler for the signal in question. If so, we don't notify the debugger, but send the signal right away. * B_GENERAL_PROTECTION_FAULT is translated to SIGILL now. Seems better than SIGKILL. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27757 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
1cd8c4cc089ffb3623a1ff761549a100cb1b4cce |
|
26-Sep-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Let the boot loader set the kernel image's name. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27754 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
0dc4d1e5ca08e5fe65c04f40f2628c29a9f4b5e0 |
|
26-Sep-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Reverted r27685, r27676, r27665, and r27664, the changes related to letting the boot loader provide full paths for the pre-loaded images. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27753 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
b34e395eaf2875c4e87b31c8ac45ff0646920744 |
|
21-Sep-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
The boot loader does now set the names of the images it loads to the full paths. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27665 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ca7cb625b9769be2657365e2137197bdc3a9692d |
|
17-Sep-2008 |
Axel Dörfler <axeld@pinc-software.de> |
* Implemented a (private for now) get_system_info_etc() call, that can retrieve various system information. * Implemented retrieving some VM stats via this call. * The VM now maintains a page fault counter, and sets system_info::page_faults accordingly. * Added a (pretty simple) "vmstat" command line app. * Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27597 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
6f3ee1f1670b8cb3d3981d5769d866a2e69c8ef5 |
|
08-Sep-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
When mapping a file into memory we do now immediately map all active pages into the team's address space. Doing that is relatively cheap and saves later page faults. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27380 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
1e90630527225143d9321738152bba9194f5ef3f |
|
21-Aug-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Added a "flags" parameter to vm_create_anonymous_area() and create_area_etc(). * When the new flag CREATE_AREA_DONT_WAIT is specified, the functions don't wait for memory or pages to become available. They fail immediately instead. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27117 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
1cda5944ad23e0ee134b13b9e3c0c0fd2f68d6ca |
|
20-Aug-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added object_cache_set_minimum_reserve() which sets the minimal number of free objects an object cache should try to have ready. If the number of free objects drops below the threshold, a new urgent priority thread is asked to asynchronously resize the object cache (pretty similar to the heap grower thread). Such a mechanism is necessary for code paths that are supposed to free pages, but may need memory themselves (like the swap support). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27100 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
90cd1b25e1a589a1477bb76edd6f34b8d0d13ac5 |
|
08-Aug-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
vm_remove_all_page_mappings(): Decrement the mapped pages count only, if the page was really mapped before. Fixes bug #2585. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26876 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
a9d7be0708b660121608c1b916862ab6d664ba07 |
|
07-Aug-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Implemented mprotect(). A vm_area does now have an optional array specifying the protection of each page (4 bits per page). * Added no-op implementation of posix_madvise(). * Replaced a few "addr_t size" parameters by "size_t size". git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26871 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
3394ebd3c2d14214f0603fabecf2ac36c9fd4eae |
|
06-Aug-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Improved some output and coding style. * If a segment violation occurs, we do now check whether the thread in question has a handler for SIGSEGV. If so, we just send it the signal. Otherwise we notify the debugger as before. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26851 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
8d12bd1370b89bd29d6b306f5875ec08ce5f4a74 |
|
05-Aug-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Moved the incrementing/decrementing of vm_page::wired_count into dedicated functions. * Introduced gMappedPagesCount variable which counts the total number of physical pages that are mapped. * Added vm_page_get_stats() which fills in the memory related part of the system_info structure. Used and cached pages are computed differently, now. The "available" (== not committed) memory is no longer used for the computation as it doesn't say anything about the actually used/free pages (with swap support enabled it is even less meaningful, since we first commit swap space when possible). We do also consider the memory used by the block cache as cached pages, now. All in all these changes should fix the memory statistics reported by get_system_info(), IOW bug #2574. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26837 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
57f2b5a0137be29081ab719ae33ebabddc95b78b |
|
05-Aug-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Changed the meaning of the {KERNEL,USER}_STACK_SIZE macros to not include the guard pages. Adjusted the kernel and boot loader code accordingly -- the guard pages size is added/not removed respectively. The stack size passed to _kern_spawn_thread() is now the actually usable size, and it is no longer possible to specify a size smaller than or equal to the guard pages size. * vm_create_anonymous_area(): Precommit two pages maximum -- a stack with only one page usable size obviously doesn't need two pages. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26819 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
39ec9b48bd80677e43182f4b2a308550d47c8697 |
|
03-Aug-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
vm_page_fault(): Only put the address space, if we actually got one. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26774 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
c421c138b689eecb625667e2a55844c3fcea4c35 |
|
02-Aug-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
vm_create_anonymous_area(): * Moved reservation of memory for the "locked" cases upfront. Particularly if the would-be area is a kernel area, we don't want the address space to be write locked while doing that, since that would block the low memory handler. * For full lock areas the pages are reserved upfront, too. The reasoning is similar. Reserve the pages needed by the translation map backend for mapping the area pages there too. * Moved the cache locking/unlocking out of the individual cases. All want to have the cache locked the whole time, now. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26741 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
272457553e0ff0860cf931c1d193c2c6020a7da8 |
|
02-Aug-2008 |
Axel Dörfler <axeld@pinc-software.de> |
* Renamed kernel_startup to gKernelStartup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26731 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
e6f3de9a29518fc7b426b6a715628ccf92252267 |
|
31-Jul-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added TODO -- food for thoughts. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26711 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
4aeadff00f3e7b6ce852d75e8f69a5d361998158 |
|
26-Jul-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Removed pointless check. vm_page_allocate_page() only returns NULL, when an invalid page state was supplied. The comment was misleading too, as the pages weren't reserved upfront. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26650 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
7a9d5c2e39b4f5d26b6aa358b48ab64aa6a39fb3 |
|
25-Jul-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added TODOs in lock_memory_etc. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26629 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
2dad5fa7eb67fef7a172c5f5687b838c5b59efc8 |
|
24-Jul-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Added "boolean getNewReference" parameter to the vm_address_space* versions of the AddressSpaceReadLocker constructor and SetTo(). When true it will get a new reference to the address space. * Changed vm_soft_fault(): Now it gets the address space as a parameter (for page faults getting it happens in vm_page_fault()). This should fix lock_memory_etc() for other teams -- it used the correct address space before, but the invoked vm_soft_fault() always used the current team's address space. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26628 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
c586076dcafe59a79b7f3073f2471497d62b29af |
|
24-Jul-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Patch by Zhao Shuai with changes by myself: * Init swap support in main(). * Added "bool swappable" parameter to VMCacheFactory::CreateAnonymousCache(). A cache supporting swapping is created when true. Adjusted invocations accordingly. * The page writer does now write non-locked swappable pages (when memory is low). * Fixed header guard of VMAnonymousNoSwapCache.h. * Swap support is compiled conditionally, controlled by the ENABLE_SWAP_SUPPORT in src/system/kernel/vm/VMAnonymousCache.h. It is disabled ATM. Since no swap files are added, it wouldn't have much effect anyway. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26625 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
6e60a6ac033d07074184341d26598e559aec89b0 |
|
23-Jul-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added function get_memory_map_etc() which works similar to get_memory_map(), but has a saner semantics and allows specifying a team. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26600 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
b4395038ee924f613bba2ab42b687cd45fdae749 |
|
23-Jul-2008 |
Axel Dörfler <axeld@pinc-software.de> |
* Replaced the sAreaHashLock with an rw_lock. * As this was the last user of the READ_COUNT/WRITE_COUNT definitions in vm_priv.h, I removed those as well. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26582 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
e6bd90c58dbae64f3b464edcff90dcb06e63a716 |
|
23-Jul-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* bfs_fsync() was the only place which could cause the fs_vnode_ops::write_pages() to be called with fsReenter = true. Since this is no longer the case, the argument has become superfluous. For read_pages() it always was. Removed the argument from the functions and all functions that propagated it. * Some whitespace at the end of lines was removed. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26579 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
4ed05c68691768ea84dc5e041ffd6a1a423ffddf |
|
23-Jul-2008 |
Axel Dörfler <axeld@pinc-software.de> |
* Replaced the simplistic semaphore based R/W lock in the vm_address_space with the new rw_lock locking primitive. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26578 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
5c99d639708df9b4e2cc847b38d510149d19ec78 |
|
22-Jul-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Merged branch haiku/branches/developer/bonefish/vm into trunk. This introduces the following relevant changes: * VMCache: - Renamed vm_cache to VMCache, merged it with vm_store and made it a C++ class with virtual methods (replacing the store operations). Turned the different store implementations into subclasses. - Introduced MergeStore() callback, changed semantics of Commit(). - Changed locking and referencing semantics. A reference can only be acquired/released with the cache locked. An unreferenced cache is deleted and a mergeable cache merged when it is unlocked. This removes the "busy" state of a cache and simplifies the page fault code. * Added VMAnonymousCache, which will implement swap support (work by Zhao Shuai). It is not integrated and used yet, though. * Enabled the mutex/recursive lock holder asserts. * Fixed DoublyLinkedList::Swap(). * Generalized the low memory handler to a low resource handler. And made semaphores and reserved memory handled resources. Made vm_try_resource_memory() optionally wait (with timeout), and used that feature to reserve memory for areas. ... git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26572 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
df1b333aa538e9b0b088d40448452f24fec8b3be |
|
18-Jul-2008 |
Axel Dörfler <axeld@pinc-software.de> |
No wethers in here anymore. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26487 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
6db6b628d6fdad197f44cc51fea342e888064575 |
|
16-Jul-2008 |
Axel Dörfler <axeld@pinc-software.de> |
* Added B_PHYSICAL_BASE_ADDRESS address specification for anonymous areas. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26456 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
736352dcf58f1855db8dc09c456d420ca91596ef |
|
16-Jul-2008 |
Axel Dörfler <axeld@pinc-software.de> |
* Added [un]lock_memory_etc() versions that accept a team_id as first argument. This allows drivers to lock the memory outside of the original team context. * create_area_etc() got a struct team as first argument, but that should have been a team_id. * Removed delete_area_etc() - there is already vm_delete_area() doing the same thing. * Renamed vm_get_address_space_by_id() to vm_get_address_space(), as there is no other method of getting an address space. * Removed erroneous white space. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26455 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
b64e66fbd07e9ddcc3bf59f54755188c5bcc9e3e |
|
08-Jul-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Changes related to the "caches" command: * The table used for sorting the caches could be too small for the number of caches in the system. We never checked that, which could cause a crash or triple faults when invoking the command. * We now allocate the table as an area. Also increased the table size to 102400 entries. * Also print the committed memory for non-RAM caches, if they are the root cache of a cache tree that has committed memory. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26333 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
e5f7642ca8331f375e7169bb024d0096962abc8f |
|
04-Jul-2008 |
Michael Lotz <mmlr@mlotz.ch> |
Remove a few unused variables. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26249 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
b8a66215076d23291ca8bae9dca283d2128885e7 |
|
04-Jul-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
fault_find_page(): When the source of the top cache is busy, we may find our own dummy page. This is equivalent to not finding a page at all. Fixes #2471. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26248 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
af637076adfbf7023a9470cb93c02a92e3758049 |
|
04-Jul-2008 |
Michael Lotz <mmlr@mlotz.ch> |
* Avoid calling vm_unreserve_memory() if there is no change in the commited size. Removes a bit of overhead (call and mutex_lock / mutex_unlock). * Don't fail if there is exactly enough memory available to satisfy the reserve request. Not that it would really matter as it's rather an edge case... git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26246 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d9a109d8dc09a519108e5a7881b5186ab64b1c22 |
|
29-Jun-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
"caches" also prints the total number of pages assigned to caches and the total amount of committed memory. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26165 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
e1b630c55d9d0c25aef812efc9c2410f5ba53456 |
|
28-Jun-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Replaced the global cache pages hash table by an IteratableSplayTree per cache. * Changed the strategy vm_cache_acquire_page_cache_ref() uses to ensure that the cache isn't deleted while trying to get a reference. Instead of the global cache pages hash table lock, it holds the global cache list lock now. We acquire + release this lock in delete_cache() after removing all pages and just before deleting the object. * Some small optimizations using the property that the cache's pages are ordered, now (vm_cache_resize(), vm_page_write_modified_page_range(), vm_page_schedule_write_page_range()). * Replaced some code counting a cache's pages by simply using vm_cache::page_count. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26160 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
df7096a4aaa8076f7ebbc617f914700c9a5c0109 |
|
18-Jun-2008 |
Michael Lotz <mmlr@mlotz.ch> |
* Added malloc_nogrow() function that does allocation without triggering or waiting for a heap grow. * Use that nogrow version in the VM code to avoid a deadlock with the address space lock when a grow operation would try to create an area while a malloc happened from such a function in the VM. * When waiting for a grow to happen, notify the waiting thread from the grower also if it failed to allocate a new heap. Otherwise a thread would just sit there and wait until another thread requested growing too and that one succeeded (or just forever in the worst case). * Make the dedicated grow heap growable too. If the current grow heaps run low on memory it will instruct the grower to allocate a new grow heap. This reduces the likelyhood of running out of memory with no way to grow to a minimum. As the growing is done asynchronously it is still possible to happen, but it is highly unlikely as the grow heap is solely used to allocate memory in the process of creating new heap areas and it will even try using normal public memory if the dedicated memory has run out. * Reduced the dedicated grow heap from 2 to 1MB. As it can now grow itself, it doesn't need to last so long. * Extract heap creation into it's own function that does area creation and heap attach and use this function for growing normal and grow heaps. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26009 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
f5b3a6a7968b849c8cb3d06ffe6d19acccf910a8 |
|
05-Jun-2008 |
Michael Lotz <mmlr@mlotz.ch> |
* Initialize all static mutexes in the kernel through a MUTEX_INITIALIZER() and remove the then unneeded mutex_init() for them. * Remove the workaround for allowing uninitialized mutexes on kernel startup. As they are all initialized statically through the MUTEX_INITIALIZER() now this is not needed anymore. * An uninitialized mutex will now cause a panic when used to find possibly remaining cases. * Remove now unnecessary driver_settings_init_post_sem() function. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25812 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
0e82c8d5555f89a127d68637a0fb9d1df59eb99d |
|
27-May-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Improved the "caches" command: * List the sum of pages used by a cache tree in the line printed for the root cache. * Also print the amount of committed memory per cache (and the sum for the tree), and allow sorting the list by it ("-c" switch). * Added usage text. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25675 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
6607b17d6b867901cf55b63a1a76264947ac689c |
|
23-May-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Pimped up the "caches" command. Now it prints the caches in trees with additional info (offset, size, used pages, areas), sorting the trees by used pages. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25633 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
fe8878faa4fe363165ea31aa2c058118b478701e |
|
23-May-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Implemented unmapping of partial areas (mmap()/munmap()). Review welcome. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25629 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
0f448d21e52dfbde6ebd029af30d19542224c16d |
|
22-May-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Added vm_page_write_modified_page_range(), which is similar to vm_page_write_modified_pages(), save that it only writes pages in the given range. * Added vm_page_schedule_write_page_range() which schedules all modified pages in the given cache's range for writing by the page writer. * Added _kern_sync_memory() syscall and the msync() POSIX function. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25620 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
7da0a81c0e1ecc582c580ae0769e5cc8fce220bc |
|
21-May-2008 |
Axel Dörfler <axeld@pinc-software.de> |
Patch by Jan Klötzke (with additional TODO comments): * Add a "fault_callback" to the thread structure which is called when a unhandled page fault happens in user space. A SIGSEGV will only be sent if the callback returns "true". git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25609 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
541532342d65b916dcb1b610f449997e212ea943 |
|
13-May-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Fixed build with tracing turned on. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25483 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
58148e2e0264908503a3b71f6d7fcdae3c66704b |
|
11-May-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added new private area protection flag B_KERNEL_AREA, which prevents all changes to the area (delete, resize, clone) from userland. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25450 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d59239b300271a9b9edb7063069908317e5b31f7 |
|
09-May-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Also align the given size to pages when unmapping memory. Fixes munmap() for non-aligned sizes. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25399 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
06b580d76f0c626e62f4e776b57d520d84a6d9f0 |
|
08-May-2008 |
Axel Dörfler <axeld@pinc-software.de> |
Replaced the sAvailableMemoryLock benaphore with a mutex. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25379 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
7cbf8fdd5a22f56b50ce28270e0f867401dd6c0f |
|
07-May-2008 |
Axel Dörfler <axeld@pinc-software.de> |
First part of the vm86 work by Jan Klötzke: * Allow userland teams to create areas below 1 MB when requested specifically. * Note, this is a temporary solution - see the comments in the code. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25358 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
0c615a01ae49634aaf59fbe35b3d55b3bb8890df |
|
01-May-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Removed old mutex implementation and renamed cutex to mutex. * Trivial adjustments of code using mutexes. Mostly removing the mutex_init() return value check. * Added mutex_lock_threads_locked(), which is called with the threads spinlock being held. The spinlock is released while waiting, of course. This function is useful in cases where the existence of the mutex object is ensured by holding the threads spinlock. * Changed the two instances in the VFS code where an IO context of another team needs to be locked to use mutex_lock_threads_locked(). Before it required a semaphore-based mutex implementation. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25283 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
184de764fe4d2593164db6e8b3d3a42021f6bc2f |
|
30-Apr-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Replaced the vm_cache mutex by a cutex. This should save quite a few semaphores. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25277 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
6cef245eca821584f07f5a13558f51ec586852e8 |
|
22-Apr-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Detemplatized ConditionVariable{Entry}. Merged them with their respective Private* base class. * Changed sigwait() and sigsuspend() to use thread_block() instead of a condition variable. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25100 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
3cf7ecd1e49db0ad531a6d81ad1945c4a6235010 |
|
13-Apr-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Added <sys/mman.h> header. It declares only mmap() and munmap() yet and defines the macros needed by them. * Renamed syscall sys_vm_map_file() to _kern_map_file() and changed the path to an FD parameter. Changed vm_map_file() accordingly and adjusted the kernel ELF loader and the runtime loader. * Added syscall _kern_unmap_memory(). * Added bool unmapAddressRange parameter to vm_create_anonymous_area() and map_backing_store(). If true and the address specification is B_EXACT_ADDRESS, all areas in the specified address range will be deleted (unless an area is covered only partially). * Introduced B_SHARED_AREA flag, which is set on areas that have been created by {vm,_user}_map_file() with REGION_NO_PRIVATE_MAP. When fork()ing those areas won't be copied CoW, but rather be cloned. This is needed for mmap() MAP_SHARED. * {vm,_user}_map_file() also accept an FD argument < 0, in which case an anonymous area is created. * Implemented mmap() and munmap(). Currently there's the restriction that we can't partially unmap areas. Otherwise the functions should be rather compliant. We also support the non-POSIX extension MAP_ANONYMOUS. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24964 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
9583c41d8aec16ffb58f4634e30dca35d4eadb80 |
|
05-Apr-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added TODO regarding potential deadlock. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24820 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
6b53669383384c213fac62ca0ec4300b62e43c7b |
|
01-Apr-2008 |
Axel Dörfler <axeld@pinc-software.de> |
* Renamed vm_get_available_memory() to vm_available_memory() to fit better into our usual naming scheme. * Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24745 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
c32f787401c6eefff2880eae60d901de93433d30 |
|
26-Mar-2008 |
Axel Dörfler <axeld@pinc-software.de> |
* Added new KDL command "string" that dumps a string given a pointer. * Use parse_expression() where appropriate. * Removed extraneous white space. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24593 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
41f8d41647c52758df0d91031609d31ca01032ce |
|
25-Mar-2008 |
Axel Dörfler <axeld@pinc-software.de> |
Applied patch by Rene Gollent: * Add a cached_pages field to the system_info structure, and change the meaning of the used_pages field to not include cached pages. * Provide the needed info using the new calls vm_get_available_memory(), and vm_page_num_available_pages(). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24571 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
00265801043978a8bd21386cfde7d5b74f2699b9 |
|
20-Mar-2008 |
Rene Gollent <anevilyak@gmail.com> |
Leave tracing disabled by default though. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24497 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
7f9a9ff61239281e212e836984f4cc3d97ebcf5a |
|
20-Mar-2008 |
Rene Gollent <anevilyak@gmail.com> |
Fix broken TRACE statement. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24496 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
4495cd43c19a4925102a20b4d4f8bedd2cfa923d |
|
20-Mar-2008 |
Axel Dörfler <axeld@pinc-software.de> |
* Fixed warnings, mostly due to NULL changes. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24487 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d1189f0b057290eea0ca3127e07cb00ff40c1a46 |
|
08-Mar-2008 |
Michael Lotz <mmlr@mlotz.ch> |
Naive implementation of transfer_area(). It follows the suggested sematics of the resolved ToDo, but could probably be made more efficient. Instead of transfering the area, the area is cloned into the target teams' address space and the original is deleted. This generates a new area_id for the transfered area (as suggested by the ToDo). Updated syscall prototypes according to the status_t to area_id return type change. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24320 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
5c4d1c5e21dcf7e66414c44691ff0aa92be93842 |
|
10-Feb-2008 |
Michael Lotz <mmlr@mlotz.ch> |
Complete rework of the heap implementation. Freelists are now part of the pages and pages are now kept in lists as well. This allows to return free pages once a bin does not need them anymore. Partially filled pages are kept in a sorted linked list so that allocation will always happen on the fullest page - this favours having full pages and makes it more likely lightly used pages will get completely empty so they can be returned. Generally this now goes more in the direction of a slab allocator. The allocation logic has been extracted, so a heap is now simply attachable to a region of memory. This allows for multiple heaps and for dynamic growing. In case the allocator runs out of free pages, an asynchronous growing thread is notified to create a new area and attach a new heap to it. By default the kernel heap is now set to 16MB and grows by 8MB each time all heaps run full. This should solve quite a few issues, like certain bins just claiming all pages so that even if there is free space nothing can be allocated. Also it obviously does aways with filling the heap page by page until it overgrows. I think this is now a well performing and scalable allocator we can live with for quite some time. It is well tested under emulation and real hardware and performs as expected. If problems come up there is an extensive sanity checker that can be enabled by PARANOID_VALIDATION that covers most aspects of the allocator. For normal operation this is not necessary though and is therefore disabled by default. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23939 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
9835c090a69357df22aaaa5a3e12483a36f8deb0 |
|
07-Feb-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added a boolean "force" parameter to thread_yield(). When true, the function has the old behavior. When false, it just calls the scheduler without any priority adjustment or other stuff. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23906 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
72f7b290185c2f86085d6dbec56b6f3ab9f5dbfc |
|
23-Jan-2008 |
Stephan Aßmus <superstippi@gmx.de> |
Limit the number of stack frames we print. Infinite recursions or, even worse, cyclic stack frames would be seriously annoying. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23712 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
c6ee79ce388772e847063f6d52111db54b0bbc71 |
|
16-Jan-2008 |
Axel Dörfler <axeld@pinc-software.de> |
* vm_create_anonymous_area() now accepts B_ANY_KERNEL_BLOCK_ADDRESS. * As a temporary work-around for the current slab allocator's area usage, I added the CACHE_LARGE_SLAB flag, which will force the allocator to use larger areas. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23564 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
abf34addc5e5ff24b50a94b3731eb82970c74d35 |
|
16-Jan-2008 |
Axel Dörfler <axeld@pinc-software.de> |
* B_ANY_KERNEL_BLOCK_ADDRESS now aligns the memory on the next power of two value greater or equal its size (actually untested, but at least Haiku still boots with these changes :-)). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23563 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
c87ef6db88e8dbc06accf256f7bac1c68a8b431f |
|
15-Jan-2008 |
Axel Dörfler <axeld@pinc-software.de> |
Made Haiku behave better when you have more memory: * with 1 GB or more, the semaphore limit is now 131072 instead of 65536. * double the heap when there is 1 GB or more (64 MB). * the low memory handler now also watches semaphore usage; in the end, we need a low resource handler, not a low memory handler. * create_sem_etc() no longer calls vfs_free_unused_vnodes() directly as this could actually deadlock (at least because the address space is a R/W lock, not a recursive lock). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23538 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
7ce6a420b7b38f855b020970f63c9fb344972a3e |
|
11-Dec-2007 |
Michael Lotz <mmlr@mlotz.ch> |
Make the initial size of the slab depend on the CPU count. This avoids running out of initial space with more than two CPUs. I haven't fully tracked down the usage of this space, probably it is used to allocate some per CPU construct. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23115 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
3d268eda3d0ca504c865533347decf27b54025b6 |
|
10-Nov-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* Extracted file_map API out of the file cache - it's now an optional service that can be used by file systems. * Changed the way the file cache works: instead of reading/writing to the underlying device directly, it can now be used for any data source, ie. also network file systems. * As a result, the former pages_io() moved to the VFS layer, and can now be called by a file system via {read|write}_file_io_vec_pages() (naming suggestions are always welcomed :-)). It now gets an FD, and uses that to communicate with the device (via its fs_{read|write}_pages() hooks). * The file_cache_{read|write}() functions must now be called without holding an I/O relevant file system lock. That allows the file cache to prepare the pages without colliding with the page writer, IOW the "mayBlock" flag can go into the attic again (yay!). * This also results in a much better performance when the system does I/O and is low on memory, as the page writer can now finally write back some pages, and that even without maxing out the CPU :) * The API changes put slightly more burden on the fs_{read|write}_pages() hooks, but in combination with the file_map it's still pretty straight forward. It just will have to dispatch the call to the underlying device directly, usually it will just call its fs_{read|write}_pages() hooks via the above mentioned calls. * Ported BFS and FAT to the new API, the latter has not been tested, though. * Also ported the API changes to the fs_shell. I also completely removed its file cache level page handling - the downside is that device access is no longer cached (ie. depends on the host OS now), the upside is that the code is greatly simplified. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22886 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
90f87904fc955fd62be23702969140476302cc93 |
|
23-Oct-2007 |
François Revol <revol@free.fr> |
Some m68k fixes. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22692 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
215a91d16188e9b9c588dd48e6ee9da1664f202a |
|
11-Oct-2007 |
Axel Dörfler <axeld@pinc-software.de> |
No need to print and try NULL at all. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22505 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
013f781f47210f8e83040c1efabf99524855a197 |
|
10-Oct-2007 |
Axel Dörfler <axeld@pinc-software.de> |
vm_test_map_{modification|activation}(), vm_clear_map_flags(), and 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
|
#
477c9d1dc0c9e0ba73bad72ffbfab374d770dd52 |
|
09-Oct-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* vm_set_area_protection() would remap the whole area instead of just the page 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
|
#
80f54692912d728f5780e9d78d7643828edaaa2a |
|
06-Oct-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* struct vnode is an opaque type now, removed void* where it was used incorrectly. * Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22461 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
0e183340579eeeb7703088d847cfd1284a511129 |
|
06-Oct-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* Mapping a page might actually need memory - since we usually have locks that 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
|
#
9d8c209014a71a82de460aafd94bed1f6aa90f55 |
|
04-Oct-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* vm_remove_all_page_mappings() now returns an accumulation of the flags of 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
|
#
3e9513aa4a8bf5f2fb2b86a767ffe46f6e626acc |
|
03-Oct-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* fs_{write|read}_pages() now has an additional argument "mayBlock". * 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
|
#
b062823d817b8d2bdffe10cb3d390230dffdff18 |
|
29-Sep-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* register_low_memory_handler() was called too early by several kernel 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
|
#
a6778735f9b06e497f3ad8e23b7c6da9356bbef5 |
|
28-Sep-2007 |
Axel Dörfler <axeld@pinc-software.de> |
bonefish+axeld: * We now have a page writer that takes some pages from the modified queue and writes it back every few seconds. It can be triggered by the page scanner to do that more often, though. That mechanism can be greatly improved once we have our I/O scheduler working. * Removed vm_page_write_modified_page() again - it was all "eaten up" by the page writer. * Reworked vm_page_write_modified_pages() a bit: it now uses vm_test_map_modification() and vm_clear_map_flags() instead of the iterating over all areas which wouldn't even work correctly. The code is much simpler now, too. * You usually put something to the tail of a queue, and remove the contents from the head, not vice versa - changed queue implementation to reflect this. * Additionally, there is now a enqueue_page_to_head() if you actually want the opposite. * vm_page_requeue() allows you to move a page in a queue to the head or tail. * Replaced vm_clear_map_activation() with vm_clear_map_flags() which allows you to clear other flags than PAGE_ACCESSED. * The page scanner dumps now some arguments with each run. * Removed the old disabled pageout_daemon() from NewOS. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22348 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
e6dc7903e4277bf6e22527ed611df619c7e645f1 |
|
26-Sep-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* vm.h no longer includes vm_types.h - only those that actually need access to the private VM types are including vm_types.h now. * Removed vm_page, vm_area, vm_cache, and vm_address_space typedefs; it's cleaner this way, and the actual types are only used in C++ files now, anyway. * And that caused changes in many files... * Made commpage.h self-containing. * Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22329 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
8692ec023c373576f9bd46adeb9954ce708b8026 |
|
26-Sep-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* Renamed vm_page_write_modified() to vm_page_write_modifed_pages() and introduced a new vm_page_write_modified_page(). * Resolved a TODO: vm_page_write_modified_pages() did not mark a to be written page busy but unlocked its cache which could let someone else steal that page in the mean time. * Moved the logic when to move a page to the active or inactive queue to a new function move_page_to_active_or_inactive_queue(). * Moved page_state_to_string() to vm_page(); it's now also used by the "page" and "page_queue" KDL commands. * Made the output of the "page_queue list" command more useful. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22323 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
8e0f884c71025810db35b54234f1a2919131b108 |
|
26-Sep-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* Since the page scanner and thief can work more effectively when no vm_caches are locked, there is now a vm_page_reserve_pages() call to ensure upfront that there is a page for me when I need it, and may have locked some caches. * The vm_soft_fault() routine now makes use of that feature. * vm_page_allocate_page() now resets the vm_page::usage_count, so that the file cache does not need to do this in read_chunk_into_cache() and write_chunk_to_cache(). * In cache_io() however, it need to update the usage_count - and it does that now. Since non-mapped caches don't have mappings, the page scanner will punish the cache pages stronger than other pages which is accidently just what we want. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22319 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
6d4aea47962e0ea08b81327fbbf93b32ae821177 |
|
25-Sep-2007 |
Axel Dörfler <axeld@pinc-software.de> |
bonefish+axeld: * Removed the vm_cache/vm_store ref_count duality that besides being a bit ugly also created the page dameon cache retrieval problem: now, only areas (and cache consumers) retrieve a reference to the store (and therefore, the vnode). The page daemon doesn't need to care about this at all anymore, and the pseudo references of the vm_cache could be removed again. * Rearranged deletion of vnodes such that its ID can be reused directly after fs_remove_vnode() has been called. * vm_page_allocate_page() no longer panics when it runs out of pages, but just waits for new pages to become available using the new sFreeCondition condition variable - to make sure this happens in an acceptable time frame, it'll trigger a run of the low memory handlers. * Implemented a page_thief() that steals inactive pages from caches and puts them into the free queue. It runs as a low memory handler. * The file cache now sets the usage count on the pages it inserts into the cache (needs some rework though, cache_io() doesn't do it yet). * Instead of panicking, the kernel will currently dead lock in low memory situations, since BFS does a bit too much in bfs_release_vnode(). * Some minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22315 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
8c657126cdd318c4af32423d10f44a48a861868d |
|
25-Sep-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* Removed unused vm_page::busy_{reading|writing} fields. * Fixed vm_page_allocate_page_run(): it did not take the pageState into account, and would therefore return uninitialized memory (ie. B_CONTIGUOUS areas would contain garbage). Now, it stores if a page is cleared in a new vm_page::is_cleared field. * Some cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22306 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
87689e25ea5f8e921f28500b4f0bcf4498c9b340 |
|
03-Sep-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* sMappingLock is now a mutex instead of a spinlock. * The vm_translation_map is now correctly held in all of the vm_ mapping functions. * Removed the old vm_daemons.c file - there is now a new vm_daemons.cpp which contains the beginnings of our new page daemon. So far, it's pretty static and not much tested. What it currently does is to rescan all pages in the system with a two-handed clock algorithm and push pages into the modified and inactive lists. * These inactive pages aren't really stolen yet, even though their mappings are removed (ie. their next access will cause a page fault). This should slow down Haiku a bit more, great, huh? :-) * The page daemon currently only runs on low memory situations, though. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22156 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d2056c99338c177f72cf8bdf187b692ae473d835 |
|
02-Sep-2007 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Added "caches" debugger command (to be enable by defining DEBUG_CACHE_LIST) that prints an unspectacular list of pointers to all existing caches. Feel free to extend. * Enhanced MultiAddressSpaceLocker: - It supports choosing between read and write lock per address space, now. - Added AddAreaCacheAndLock(), which adds the address spaces of all areas that are attached to a given area's cache, locks them, and locks the cache. It makes sure that the area list didn't change in the meantime and optionally also that all areas have their no_cache_change flags cleared. * Changed vm_copy_on_write_area() to take a cache instead of an area, requiring it to be locked and all address spaces of affected areas to be read-locked, plus all areas' no_cache_change flags to be cleared. Callers simply use MultiAddressSpaceLocker:: AddAreaCacheAndLock() to do that. This resolves an open TODO, that the areas' base, size, and protection fields were accessed without their address spaces being locked. * vm_copy_area() does now always insert a cache for the target area. Not doing that would cause source and target area being attached to the same cache in case the target protection was read-only. This would make them behave like cloned areas, which would lead to trouble when one of the areas would be changed to writable later. * Fixed the !writable -> writable case in vm_set_area_protection(). It would simply change the protection of all mapped pages for this area, including ones from lower caches, thus causing later writes to the area to be seen by areas that shouldn't see them. This fixes a problem with software breakpoints in gdb. They could cause other programs to be dropped into the debugger. * resize_area() uses MultiAddressSpaceLocker::AddAreaCacheAndLock() now, too, and could be compacted quite a bit. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22152 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
22e95c5911749774324862ec6ba06fbc3f4bb777 |
|
31-Aug-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* creating (or dividing) reserved areas did not acquire a ref to an address space - but they were released upon deletion. It's probably not really needed, but now all reserved areas also grab a reference to their address space. * Rearranged team tear down to be a bit more sane: the I/O context is removed first (where semaphores/areas/ports/whatever might still be used), and the address space is deleted last. * delete_area() can now remove its address space reference again (due to the two changes above), and therefore fixes bug #1374. * cleaned up vm_address_space.c a bit (no functional change there, though). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22130 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
9d22ffbe844d371fd6665a5d60efa9309c994488 |
|
20-Aug-2007 |
Axel Dörfler <axeld@pinc-software.de> |
Fixed bug #1413: * vm_soft_fault() no longer touches the page source cache in case fault_get_page() failed. * fault_find_page() now unlocks and releases the cache if reading in a page failed. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22016 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
066a55744440bddbf1fa0e314131754681fa5b82 |
|
15-Aug-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* vm_soft_fault() no longer sets all pages it touches to "active"; instead, it now honours if the page was already in the "modified" list before. Also, the source page (which is either mapped directly or copied to the target page) is no longer marked busy before its final destiny is decided (it didn't have any effect, anyway, since we had its cache locked for the whole time, but it now preserves the modified state). This fixes bug #1369. * vm_cache_write_modified() now filters out temporary caches (it's currently called on area deletion). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21971 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
5c806b5dbc6cedbe961690a7d9f5d7cf14f240b7 |
|
12-Aug-2007 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
map_backing_store() would deadlock in error case for REGION_PRIVATE_MAP. Closes #1379. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21914 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
279c6b76dc2a862f712eb2222381988f74b7b199 |
|
09-Aug-2007 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Use condition variables when waiting for busy pages or busy caches. * Removed a few instances where the page state was set busy directly after allocating it. This is a no-op, since a page is always busy after allocation. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21875 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
a2057fac93fd335635afb22afa2a3edaab56704d |
|
08-Aug-2007 |
Axel Dörfler <axeld@pinc-software.de> |
Since get_memory_map() can run with interrupts turned off, it can't put up it's reference to the vm_address_space - luckily, it doesn't even need a reference, since it always runs in the current address space, which cannot go away for obvious reasons. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21865 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
69bee56c3bf369ce40236abc9e18fc2149b2e5ed |
|
08-Aug-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* get_memory_map() leaked vm_address_space references * fixes a dead lock in vm_soft_fault() - the locking scheme enforces you to lock the address space before a vm_cache, not the other way, around. Since we need to lock the cache that has our page in fault_get_page(), we violated that scheme by relocking the address space in order to get access to the vm_area. Now, we read lock the address space during the whole page fault; added a TODO that explains why this might not really be desirable, if we can avoid it (the only way would be to reverse that locking scheme which would potentially cause the more busy vm_cache locks to be held longer). * vm_copy_area() uses the MultiAddressSpaceLocker, but actually forget to call Lock() on it... * delete_area() leaks vm_address_space references - but fixing this currently causes other problems to be investigated; I'll open a bug for that. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21862 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
5af1dda7937d021c160a481f38267f9a1f7a93cc |
|
07-Aug-2007 |
Axel Dörfler <axeld@pinc-software.de> |
bonefish+axeld: * Removed the ref_count from vm_areas. You now always need to have the address space locked (read or write, depending on what you do) when dealing with areas. * Added helper classes for locking the address space: AddressSpace{Read|Write}Locker, and MultiAddressSpaceLocker which can lock several spaces at once and makes sure no dead locks can happen. * resize_area() is now using the MultiAddressSpaceLocker instead of no locking at all; ie. it should now be safely to use. * Disabled transfer_area() for now; it will be changed to work like an atomic clone_area()/delete_area(), that is, it will hand out a new ID for the transfered area. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21848 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
2ac748daf1a3eb53a010696d4e223a1020e10136 |
|
06-Aug-2007 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Changed the signatures of fault_get_page() and fault_find_page(), so that an error can be propagated back to vm_soft_fault(). * Added boolean restart reference parameter to fault_find_page() which is set to true whenever a condition is it encountered that requires to start fault_find_page() from the very beginning. fault_get_page() checks the flag and executes fault_find_page() in a loop, now. * Removed the panic()s+TODOs in fault_find_page() when a cache became busy. The restart feature is used in this case. * fault_find_page(): If after the loop we haven't found a page yet, and after locking the right cache one turned up, we restart the function, too, thus avoiding double insertion of a page into a cache. * Fixed potential dead-lock in fault_get_page(): After inserting a clean page into a cache other than the top cache (read fault on copy-on-write area not backed by a file (e.g. the heap)) the dummy page was removed from the to be locked top cache while we still held a lock for the lower cache, thus inverting the locking direction required by the cache locking policy (top -> bottom). * fault_get_page(): In case of a write access and a readable page found in a lower cache, vm_cache_remove_consumer() could have replaced our dummy page with a real page from a collapsed lower cache while we had unlocked both caches. We didn't check for this condition and always inserted our freshly allocated page, thus potentially inserting a duplicate page into the top cache. We do the check now and discard our page, when another page turned up. Fixes bug #1359. * fault_get_page(), same if block: Removed unused case for removal of the dummy page from a non-top cache. We only ever insert it into the top cache and it should not be moved to another cache. Added an assert. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21841 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
0a75dab5fe1efd6512b9d03964ba3ffc135d18a8 |
|
03-Aug-2007 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
fault_find_page(): Fixed a race condition in case of reading the page from the store into the top cache, which could lead to pages inserted multiple times into the cache. We don't insert a dummy page in this case anymore. Instead we mark a freshly allocated page busy and insert that one. That's exactly the approach the file cache uses too. This does probably make the whole dummy page special handling in the file cache obsolete. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21816 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
e9012605b81d82945a912c6889e8d7003d03c455 |
|
02-Aug-2007 |
Axel Dörfler <axeld@pinc-software.de> |
vfs_get_vnode_cache() was changed (read: fixed) since r18716; it was wrong to acquire the extra vnode reference, and actually prevented unmounting from working - which it now does again. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21806 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
6e09c5679e1874094812c4b8a185a462edd479a4 |
|
30-Jul-2007 |
Axel Dörfler <axeld@pinc-software.de> |
area_for() in the kernel can now also find user areas in case you are coming from a user team. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21746 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d6dfbc4de58fd494a4853a65411207fd5af3e899 |
|
26-Jul-2007 |
Axel Dörfler <axeld@pinc-software.de> |
Minor cleanup in comments. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21714 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
6d1c68155a33b0cbe1df50986fa8345dcaaa6a32 |
|
19-Jul-2007 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
axeld + bonefish: * More conditional debug code (wrt page transitions between caches). * Replaced debugger command cache_chain by a nicer cache_tree. * While handling a soft fault: When we temporarily unlock a cache, it can theoretically become busy. One such occurrence is now handled properly, two more panic() ATM, though should be fixed. * When merging caches, we do now always replace a dummy page in the upper cache, not only when the concurrent page fault is a read fault. This prevents a page from the lower (to be discarded) cache from still remaining mapped (causing a panic). * When merging caches and replacing a dummy page, we were trying to remove the dummy page from the wrong cache (causing a panic). The Haiku kernel seems now to run shockingly stable. ATM, we have more than two hours uptime of a system booted and running over network. We didn't manage to get it down by fully building Pe, downloading, unzipping, and playing with various stuff. Someone should finally fix all those app server drawing bugs, though (hint, hint! ;-)). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21672 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
58f6e8e5e4aeee797ecd3bb7bed17d5a3a2029c0 |
|
17-Jul-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* Merged vm_cache_ref and vm_cache to a single structure (Axel & Ingo). * Renamed vm_cache.c to vm_cache.cpp git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21642 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
25f46ea449ca29e08bef64ef93eb5d5b117d7e2f |
|
30-Jun-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* Reserving areas never put down their reference of their address space when removed in several cases. * vfs_get_vnode_cache() now always gives out a reference to the cache it returns; if it needs to allocate a new one, the vnode owns one reference, and the caller another. * therefore, file_cache_create() now owns a reference to its vm_cache_ref, and frees it in file_cache_delete(). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21533 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
0cb94db5390bfd8614afd53920bb4866b98c8754 |
|
21-Jun-2007 |
Axel Dörfler <axeld@pinc-software.de> |
Ingo and I fixed a couple of VM bugs in a late night debugging session: * vm_copy_on_write_area() now does no longer overwrite the ref_count, but keeps it's reference to the cache until it has unlocked it. * It now also locks its reference from the start, preventing any other thread to interfere. * vm_cache_remove_consumer() now detects if it has to remove a foreign busy page itself in order to preserve a mapped page. * vm_soft_fault() now keeps a reference to the cache that owns the page to be mapped until it has actually mapped it. * vm_unmap_pages() removed the mappings of all pages of the area instead of only those that are within the requested range. * Kept (disabled) debug output for convenience. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21482 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d9be8bc0fe58da98d1aae39011170561c786452d |
|
08-Jun-2007 |
Stefano Ceccherini <stefano.ceccherini@gmail.com> |
Got rid of a global, hope no one minds git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21349 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
1c86f4892b1df15e1c86475a5d52535e77a24110 |
|
03-Jun-2007 |
Stefano Ceccherini <stefano.ceccherini@gmail.com> |
Renamed a couple of variables, for easier reading... git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21319 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
698b6d7195c415b907449e44cd2fd295bbdb8523 |
|
29-Apr-2007 |
Hugo Santos <hugosantos@nowhere.fake> |
cache/slab: when CACHE_DURING_BOOT is specified, use vm_allocate_early to obtain pages for slabs, and create the associated areas on post bootup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20913 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
6bad4934393e784ea38685a76d28643deec67184 |
|
28-Apr-2007 |
Hugo Santos <hugosantos@nowhere.fake> |
pushed the slab init a bit deeper. added a object cache based allocator, including a bootstrap mechanism to have it init during bootup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20896 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
be1f43264872470640f1668be0612e8b58195bac |
|
23-Apr-2007 |
Axel Dörfler <axeld@pinc-software.de> |
Don't allow creating areas with a size of 0 bytes, courtesy of Vasilis Kaoutsis. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20789 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
3095921098845afe35c6791a1a7778bc5985cc95 |
|
16-Apr-2007 |
Travis Geiselbrecht <geist@foobox.com> |
asm optimized user_memcpy(), which should help somewhat, since the old version was a byte-by-byte copy. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20723 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
1407f23d9b97600890c2fa7903a6077f6023d4cf |
|
03-Apr-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* The test for existing mappings in vm_remove_consumer() was a bit too aggressive; if the page is currently copied, the source page still has mappings. * vm_copy_on_write_area() did not set the cache type for the upper cache. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20530 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
3a1532ef98dc26c4211d55dd298000ff7c3a938c |
|
29-Mar-2007 |
Axel Dörfler <axeld@pinc-software.de> |
In case the source cache of the current vm_cache_ref was in the process of being merged in vm_cache_remove_consumer(), fault_find_page() tried again with the current vm_cache_ref, but didn't realize it might have had inserted a busy page in this cache already. This fixes a deadlock, as this page would never get unbusy again. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20470 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
94d37a4b51b01df0d868e776590c2a6c1a6f33b4 |
|
30-Mar-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* map_backing_store() did not set the private mapping's cache to CACHE_TYPE_RAM. * Some more debug helpers. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20469 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
673a63dc41cfdbc514cc5d58ea719407f9163fef |
|
30-Mar-2007 |
Axel Dörfler <axeld@pinc-software.de> |
Added more checks regarding page movement for debugging purposes. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20468 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
c0c59f5b2d3dd83c870899145d8e4e63fdf25c10 |
|
22-Mar-2007 |
Axel Dörfler <axeld@pinc-software.de> |
Accidently unmapped the wrong pages in case of COW after the last commit... git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20408 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
c6a7ff7a9fd2ed08390fe64b8e37a7e67a0fb24f |
|
23-Mar-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* The new vm_page_mappings weren't updated correctly in many cases. * Added a comment to vm_remove_all_page_mappings() that shows that we need to change the mapping spinlock into a mutex. * Pointed out some potential problems in the code. * Added vm_page_at_index(), vm_clear_map_activation(), and vm_test_map_activation() in preparation of the page scanner rewrite. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20407 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
529bf4045b5fa5f40514f5c41edde75f1f71b311 |
|
21-Mar-2007 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
In a copy-on-write situation a page from a lower cache must always be mapped fully read-only (for both kernel and userland). Previously a kernel read access to a yet unmapped r/w accessible userland address would cause the page from the lower cache to be mapped with write permission for userland (on x86 also for the kernel) thus e.g. allowing a fork()ed child process to write to the parent process' memory. Fixes bugs #113 and #928. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20402 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
f19d32ef8f93bdf3183fbd1f86120e492d3b18a3 |
|
11-Mar-2007 |
Axel Dörfler <axeld@pinc-software.de> |
Fixed warning. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20369 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
6e601ee88fa21e28c910ff4b5a382a362fa5963b |
|
11-Mar-2007 |
Axel Dörfler <axeld@pinc-software.de> |
get_memory_map() now panics (and fails) in case it was called on unmapped memory as suggested by Ingo; before it would just fill the physical pages with NULL pointers. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20364 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
bf4604c3639d7b89b158af2e03c91404dc4a28e5 |
|
09-Mar-2007 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Fixed incorrect loop conditions in [un]lock_memory(). If the given start address wasn't aligned and numBytes was a multiple of the page size, the last page was ignored. A subsequent get_memory_map() would return NULL as physical address for that page, if it hadn't been mapped before (that function looks generally suspicious, IMHO). E.g. reads from a device into an unaligned buffer that hadn't been touched before would hit that problem. Fixes bug #1075. Might also fix other reported problems (like #1056), since this bug could have cause all kinds of weird behavior and crashes. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20362 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
1594e83f84aba00ad5928fbb3eca9f6b63d7e8fa |
|
08-Mar-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* All mapped pages that are not wired (ie. locked) now have a vm_page_mapping object that points to both, the page and the area the page is in. This will allow a page scanner to steal unused pages when necessary. * The locking is currently done with a spinlock which we might want to have another look at one day. * dump_page() and dump_area_struct() now dump the page mappings as well. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20356 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ab0ad5e92b8ef2853f19ef8fa9bac888295f645f |
|
01-Mar-2007 |
Axel Dörfler <axeld@pinc-software.de> |
Implemented printing the stack trace in vm_page_fault() for PPC as well. Not tested, though. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20284 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
00be6a4ccb8ab90c69cfdd8239b02c40da1da6cf |
|
01-Mar-2007 |
Axel Dörfler <axeld@pinc-software.de> |
And of course, we shouldn't test newArea->cache_type before it was set... git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20283 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
528e40c07dc772b0c867f6b154170419f831421b |
|
01-Mar-2007 |
Axel Dörfler <axeld@pinc-software.de> |
Of course, we need to query the address space of the source area, not the one of the target. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20282 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
0c12332715ae3cd6dedad4270d52ccf29d2cdcbf |
|
01-Mar-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* vm_map_physical_memory() now sets the wiring/locking type of the area created to B_FULL_LOCK. * vm_clone_area() now respects the source area's wiring and inherits it. This should fix bug #1055. * vm_cache::type is now duplicated in vm_area::cache_type - this allows looking it up without having to lock a vm_cache_ref; this also solves a locking bug in vm_unmap_pages() in this regard. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20281 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
5eb9da355ae6b7a44bbc1c6085c870b2620e50e5 |
|
01-Mar-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* The KDL commands cache/cache_ref will now also print the type of the cache. * Made the output look a bit more like that of the other commands. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20279 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ca954b78161f1c84cc2fd42d5a7ebbcbd56c30ac |
|
28-Feb-2007 |
Axel Dörfler <axeld@pinc-software.de> |
Another work-in-progress towards having extra structures per mapping per page: * vm_area and vm_page now have a new field "mappings" where they will store lists of vm_page_mapping structures. vm_page::ref_count is gone, as it's no longer needed (it was never updated correctly, anyway). * vm_caches now have a type field, ie. CACHE_TYPE_RAM for anonymous areas - this makes the stores a bit less independent, but is quite handy in several places. * Added new vm_map_page() and vm_unmap_pages() functions to be used whenever you map in or unmap pages into/from an area. They don't do much more than handling vm_page::wired_count correctly right now, though (ie. B_LAZY_LOCK is now working as expected as well). * Moved the device fault handler to vm_map_physical_memory(); it was not really used as a fault handler, anyway. * Didn't notice Ingo's changes to the I/O space region broke lock_memory(). It now checks the type of the area that contains the memory, and doesn't lock anymore if not needed which solves the problem in a platform independent way. * Implemented lock_memory() and unlock_memory() for real: they now change the vm_page::wired_count member to identify pages that shouldn't be paged out. * vm_area_for() now uses vm_area_lookup() internally. * Fixed various potential overflow conditions with areas that reach 0xffffffff. * Creating anonymous areas with B_FULL_LOCK no longer causes vm_soft_fault() to be called, instead, the pages are allocated and mapped (via vm_map_page()) directly. * Removed the _vm_ prefix for create_area_struct() and create_reserved_area_struct(). * Fixed a bug in vm_page_write_modified() that would not have enqueued pages that failed to be written to the modified queue again when needed. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20251 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
3eca85851531dfe2cd8a3135eeac91b540c2c55f |
|
27-Feb-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* Moved the early startup VM allocation functions from vm_page.c to vm.cpp. * Renamed them, made everything static besides vm_allocate_early() (previous vm_alloc_from_kernel_args()) which now allows you to specify a different virtual than physical size, and therefore makes vm_alloc_virtual_from_kernel_args() superfluous (which isn't exported anymore, and is now called allocate_early_virtual()). * Enabled printing a stack trace on serial output on team crash - it doesn't hurt for now, anyway. * Cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20244 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
b200275472a971ea4ccc46c94566cade754b1555 |
|
07-Feb-2007 |
Axel Dörfler <axeld@pinc-software.de> |
Flushing the translation map is done automatically on unlock. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20097 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
fe70b87d91cc71989ad3c476db81e74acd8cec99 |
|
31-Jan-2007 |
Axel Dörfler <axeld@pinc-software.de> |
Fixed a couple of issues in our VM: * we now always flush the TLBs after having unmapped some pages. * vm_soft_fault() could traverse to a source cache while it was being collapsed by vm_cache_remove_consumer() - this is now no longer possible as the latter marks the cache as busy when doing so, and the former now tests this flag and locks the cache (via the new fault_acquire_locked_source() function). * if fault_acquire_locked_source() fails with B_BUSY, the current cache is locked again, and tested again for the page - as it might have been moved upwards to it with the destruction of its former source. * The cache delivering the page for vm_soft_fault() is now locked until the end; it can no longer go away before having actually mapped the page into the area. * This also fixes the issue where pages would get lost as vm_soft_fault() put the page in the active list, no matter if its cache still existed. * Also, we now keep a reference of to a cache in case a dummy page is inserted; this makes again sure that it doesn't go away during the execution of vm_soft_fault() (which could even add this page to the free list...). * divided vm_soft_fault() into several smaller functions which should make it much more readable. * Added a "cache_chain" KDL command that dumps the whole chain until the bottom when giving a pointer to a vm_cache as parameter. * now usually call vm_cache_acquire_ref() before map_backing_store(), even though it shouldn't be really needed (I added it for debugging purposes). * Some minor cleanup. * NOTE: a major problem still persists: when removing a vm_cache, it's possible that some of its pages are still mapped, and there is currently no mechanism to get rid of these mappings! I've added TODO comments into vm_cache.c where appropriate. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20028 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
3901c6aacf9bf7bf72f9f28393f843a0bf0ef781 |
|
22-Jan-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* "db/ds/dw/dl" now print all isprint() characters, not only isalnum(). * Also, the output no longer has the leading "0x" to ease reading. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19906 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
7954a14f87c8f7cd91c289b20ce46319ed945701 |
|
22-Jan-2007 |
Axel Dörfler <axeld@pinc-software.de> |
Add a little hack to the "dw/db/ds/dl" commands that allows you to dump the contents of a physical memory location. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19898 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
f212f3bad27032ac64484f0c16bf4eccd0a82830 |
|
17-Jan-2007 |
Bruno G. Albuquerque <bga@bug-br.org.br> |
Fix build with TRACE enabled. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19848 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
e9ffbbf36ca6a12f63e9758492199b82f338bcb5 |
|
15-Jan-2007 |
Axel Dörfler <axeld@pinc-software.de> |
Moved locking into map_backing_store() - it now gets a vm_cache_ref instead of a vm_store, so that this can be done safely. It was also needed, as it would call vm_cache_release_ref() on failure which requires you to have no vm_cache_ref locks around (as it might deadlock in this case). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19806 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
63ac6cdcf4cefff930acc904f48e702bb0dfc708 |
|
14-Jan-2007 |
Jérôme Duval <korli@users.berlios.de> |
fix gcc4 build git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19802 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
f39acd678c80de07c376b008cc5b274717959595 |
|
14-Jan-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* Made vm_area_lookup() part of the kernel private API. * "sc"/"where"/"bt" now prints the area where the function of the stack frame is located in case there is no other information (using the above function). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19800 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
647b1f70a57cbe10eddde2666a644cd4a815d96f |
|
14-Jan-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* vm_copy_on_write_area() did not always correctly divide the ref_count of the two cache_refs - it needs to count the consumers of the lower cache to find its actual number of references; the upper cache could still be in use by someone else. * There were several locking bugs in the VM code; since cache_ref::cache can change, we must not access it without having the cache_ref locked. * As a result, map_backing_store() now requires you to have the lock of the store's cache_ref held. * And therefore, some functions in vm_cache.c must no longer lock the cache_ref on their own, but require the caller to have it locked already. * Added the -s option to the cache/cache_ref KDL commands: it will only print the requested structure, and not its counterpart (useful if accessing one structure results in a page fault, as was possible previously). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19796 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ff718cafed79ed02a50bdee33249860a8cc73491 |
|
13-Jan-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* Maintain the vm_cache::virtual_size field in all cases. * Fixed dumping the area list of a cache I broke with the previous commit. * Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19789 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
81d5ce45a8d992527d89bbf97ded346eba0f6f8b |
|
13-Jan-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* Merged "cache"/"cache_ref" commands, as you usually want to have all the info, anyway (you can still use both commands, but you'll see always the same output). * The cache_ref's area list now also prints the owner of the area. * Added "-p" option to "cache"/"cache_ref" that will show the pages of the cache; if you omit it, it will now only present you a page counter. * Nicer output for the commands above. * Added "dl" to display memory in 64 bit values. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19787 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
dc688434eda19492ba3808020056a70046575a55 |
|
12-Jan-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* Added the possibility to pre-commit pages for areas that can overcommit. * This is now used for userland stack - they now always pre-commit two pages, enough to initialize TLS and copy the user-thread-exit stub to that area. * Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19776 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d1b0be94b0d167db79e913908b71731ce3e4155b |
|
12-Jan-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* Private and temporary vm_caches now maintain their new virtual_base field, which allows them to commit substantially less memory (we we're committing about 40 MB (!) too much after a complete system boot). This means you'll run out of memory less likely now. * fill_area_info() no longer filters out kernel protection flags - we may want to keep filtering them when called from userland, though, dunno. * Added new debugger command "avail" which shows how much memory has been committed, and how much is regarded as free space. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19771 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
b5428267c79050d007d692932e6ade3c411cfff5 |
|
19-Dec-2006 |
Axel Dörfler <axeld@pinc-software.de> |
This should fix the most often found kernel crash (on bootup): * vm_soft_fault() did not take into account that a cache's source can change while traversing a cache chain. * Now, we grab a reference to every cache we get before locking it, and * no longer get the cache's source without having the cache locked. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19571 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
c4546ea038a0282baace0e50fe8815edcc0e1a81 |
|
18-Dec-2006 |
Travis Geiselbrecht <geist@foobox.com> |
A fix for the double-fault on bootup: -Turns out the area removal routine had a massive race condition inside vm_put_area(). Basically the area was removed from the address space's area list before the pages were unmapped, so the vm could (and would) recycle the space before the pages were finally unmapped. It was completely reproducable on my machine during initialization of a bunch of storage drivers that were bringing the locked_pool module into and out of existence, which caused a thread to be spawned and stopped in rapid sucession. On a dual processor machine, it was possible for the new thread to be started up while the old one was still shutting down, and the kernel stack of the new one would get wiped out. Note, there still is a page ref counting problem with this area removal code. It doesn't decrement the ref count of the page as it unmaps it. Will have to figure that out. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19549 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
c3a89b90d3f38f660bfbebbee2174a24816954b7 |
|
17-Dec-2006 |
Travis Geiselbrecht <geist@foobox.com> |
fix the 'cache_ref' and 'cache' kdl commands git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19546 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
0ad660a168b87946b2bfed03603790119f53dc39 |
|
02-Nov-2006 |
Axel Dörfler <axeld@pinc-software.de> |
Remap all preloaded executables read-only and executable. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19180 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
bcf2f8133b385415700f1c47d0ffd8aec030f775 |
|
10-Oct-2006 |
Axel Dörfler <axeld@pinc-software.de> |
* Fixed a big memory leak: vm_delete_areas() did not put the reference of the address space of reserved areas - IOW address spaces were never freed upon team exit. * dump_cache() now prints a list of the cache's consumers. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19040 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
a7181e951da4d8b81f1a8740a8a5494fbcdc214f |
|
10-Oct-2006 |
Axel Dörfler <axeld@pinc-software.de> |
Accidently turned on printing stack traces with the last commit. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19037 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
0b8e0bfc083ab5bd341977209d2066010053b868 |
|
10-Oct-2006 |
Axel Dörfler <axeld@pinc-software.de> |
Some cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19036 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d593e74a2794114ae783adbb889f82f32710dae7 |
|
10-Oct-2006 |
Axel Dörfler <axeld@pinc-software.de> |
First steps towards being able of collapse vm_cache objects after forking: * a vm_cache now maintains a list of its "consumer" caches. * introduced to new functions that add/remove consumer to a cache (instead of only maintaining the vm_cache::source field). * fixed the incorrect reference counting when doing copy-on-write; we kept one ref too many of the lower cache. * minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19035 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
c40fe37f0b9ed23d499abfbb4dbc51ae282bba1b |
|
30-Aug-2006 |
Axel Dörfler <axeld@pinc-software.de> |
* Reverted the changes r17693 made to vfs_get_vnode_cache(); instead, vm_create_vnode_cache() will now grab a reference to the vnode as well if successful. This way, vfs_get_vnode_cache() now actually works how it should: it will now always grab a reference to the cache and its underlying vnode. This removes an extra reference to the vnode (and vm_cache) that got ignored before and prevented volumes to be unmounted (or file caches to be removed). Thanks to Korli for pointing this out. * file_cache_create() is now aware of that extra vnode reference and releases it; unmounting volumes is now working again as it should. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18716 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
acac7c6834809fa3626c3c27dda7ef398419acd9 |
|
01-Jun-2006 |
Axel Dörfler <axeld@pinc-software.de> |
_vm_map_file() did in fact not work correctly, but the main problem was vfs_get_vnode_cache() which did not acquire an extra reference to the cache_ref when the cache had to be created. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17693 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
a9fa017d82b1434a0597682b1232e61d92c80645 |
|
01-Jun-2006 |
Axel Dörfler <axeld@pinc-software.de> |
map_backing_store() did not acquire a cache ref in case it created a private mapping, but it connected the vm_cache objects, so if it failed later, and thus called vm_cache_release_ref() the object could have been freed accidently. Most uses of map_backing_store() explicetly acquired a cache_ref *after* the call was successful, but _vm_map_file() did not do this. _vm_map_file() might still not work correctly, though, need to have a closer look at it. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17692 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
01fdd314e56ac2700d33a528b8d50c1c30748f66 |
|
17-May-2006 |
Axel Dörfler <axeld@pinc-software.de> |
Some GCC 4.1.0 related build fixes (under Linux/PPC). Doesn't build yet, though. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17500 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
573c4336a35b51c7bf651042915e4597f21f470a |
|
30-Apr-2006 |
Axel Dörfler <axeld@pinc-software.de> |
Implemented quite a hack to solve the lockless get_memory_map() problem (bug #349): when called with interrupts turned off, get_memory_map() will now call the new vm_translation_map_ops::query_interrupt() call. Under PPC, this is trivial (at least right now), but on x86 we need to make sure we have access to the page table entry, ie. we need to create an area that points to its own page table entry, so that we can map in the page table entry containing the address we're looking for. It's not really nice, feel free to come up with a cleaner solution :-) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17280 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
97e069713b80839b9dd5441b9f4d37d891b452d8 |
|
12-Apr-2006 |
Axel Dörfler <axeld@pinc-software.de> |
Added a "reenter" parameter to the {read|write}_pages() functions to give file systems a chance to know if they have locked already. This fixes a locking problem in BFS where one thread tried to acquire two read locks (where someone else trying to acquire a write lock would have caused a dead lock). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17108 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
8645479b368deebb3c4d2ce2d90dbe1d901e72ed |
|
11-Apr-2006 |
Axel Dörfler <axeld@pinc-software.de> |
* cache_io() could insert a second page at the same position in the vm_cache since it unlocked the cache while waiting on a busy page. Now, we're filling the pending request before unlocking the cache. * Fixed the deadlock I mentioned in the last commit: if a page fault happens at the same time we're trying to read/write from/to a page, we no longer fight for the BFS inode lock, but eventually doing the job twice if needed. Will need to go over the "write modified" functions to make sure they are behaving as well. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17091 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
5ba2a3839d3e8f3e86929bade8f190ceefca856e |
|
23-Mar-2006 |
Axel Dörfler <axeld@pinc-software.de> |
Improved the filter capabilities of the "ports", "port", "sems", and "areas" debugger commands. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16870 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
db823da57eb219269a2d359a4cd5b6c9a229c30b |
|
19-Mar-2006 |
Axel Dörfler <axeld@pinc-software.de> |
* Even though our current heap is a temporary solution, the heap size depends now on the amount of memory installed in the system. Ie. if you have only 128 MB the kernel heap will be only half in size. * Minor cleanup in vm_page.c, renamed some variables to match our style guide. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16838 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
5f0bf2a3e15c9dcb6922b2a03faf0b3fa3e4305d |
|
18-Mar-2006 |
Axel Dörfler <axeld@pinc-software.de> |
We now track how many pages are in a vm_cache. Therefore, the area_info.ram_size now reflects the number of pages in the areas cache, instead of just the size of the area. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16834 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
66b7a0f4770a9b02e1f80d72fc93ce16b82b01d4 |
|
17-Mar-2006 |
Axel Dörfler <axeld@pinc-software.de> |
Renamed the _kern_init_heap_address_range() syscall to _kern_reserve_heap_address_range() and made it more powerful. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16825 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
b420ef64611ae5a42e4867b046919abb86a76cdf |
|
06-Mar-2006 |
Axel Dörfler <axeld@pinc-software.de> |
* Many VM area creation functions just panicked when a vm_store, vm_cache, or vm_cache_ref couldn't be created, instead of cleaning up and returning an appropriate error. * vm_cache_ref_create() no returns a status_t instead of the vm_cache_ref (as that's part of the vm_cache anyway). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16602 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d97476d155eb38f349b58ccbb1bd873f3844007c |
|
24-Jan-2006 |
Axel Dörfler <axeld@pinc-software.de> |
The userland stack trace no longer accesses the stack of the crashed application unsafe. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16071 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
1777154c1437c0670e368776e5171b73a05089fa |
|
09-Jan-2006 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Fixed tracing build. * In reserve_boot_loader_ranges() we skip ranges that lie without the kernel address space (we failed and panic()ed before). The architecture specific code has to deal with those, if they are of any importance. * sAvailableMemoryLock.sem was not set to -1 in vm_init() so code executed after semaphores were available but before the semaphore was created caused semaphore 0 to be acquired. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15889 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
70226007345b6be52c3be651584a66cfb7acaedb |
|
30-Dec-2005 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Don't know what kernel_args::bootdir_addr was originally intended for, but it's not initialized anymore. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15745 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
6aeb59944d7d7bdb9817af4fe8922e233f26b8e2 |
|
27-Dec-2005 |
Axel Dörfler <axeld@pinc-software.de> |
Fixed printing stack trace of crashed apps. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15680 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
0c19920751e97dd46487bb86ba41190928122a8b |
|
21-Dec-2005 |
Axel Dörfler <axeld@pinc-software.de> |
Improved debug output, added missing owner info to _dump_area(). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15653 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
7a3e1b697906291459cedc00e3f688ab98def450 |
|
21-Dec-2005 |
Axel Dörfler <axeld@pinc-software.de> |
Slightly improved debug output. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15652 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ebe5949e61c6e5a016dde07b8a6c25ab714d15ef |
|
21-Dec-2005 |
Axel Dörfler <axeld@pinc-software.de> |
The debugger command "areas" can now restrict the list by team ID. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15650 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
c1b5724035c6cec60b54779059f9a98a48ad413b |
|
21-Dec-2005 |
Axel Dörfler <axeld@pinc-software.de> |
My last commit broken vm_clone_area(): it didn't grab a reference to its cache, and therefore, let the kernel crash easily. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15649 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
db39fa281e6d89d253cd7e9525793157aa67550c |
|
21-Dec-2005 |
Axel Dörfler <axeld@pinc-software.de> |
Moved the headers of the different store implementations into the VM source directory; they are not used outside the VM. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15648 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ea2cd27e57272fe016f285c1762252da775ddfc2 |
|
21-Dec-2005 |
Axel Dörfler <axeld@pinc-software.de> |
* Fixed the strange vm_cache_ref reference count mechanism: now, a fresh vm_cache_ref starts with a reference count of 1. When acquiring a vm_cache, you no longer need to worry if that should go through the vm_store, or not; as it now always does. * map_backing_store() no longer needs to play with the vm_cache_ref references. * that simplified some code. * vfs_get_vnode_cache() now grabs a reference to the cache, if successful. * better balanced vnode ownership on vnode_store creation (vnode_store released the vnode before if its creation failed). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15641 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
79f73dbc56ac58d027f33ad260c1eefbc1730935 |
|
20-Dec-2005 |
Axel Dörfler <axeld@pinc-software.de> |
* vm_page::offset is now called cache_offset and is now an uint32 instead of off_t; this saves 4 bytes per page. To compensate the loss of bytes, the offset is now stored in page size units, that's enough to address 2^44 or 16 TB (which is now the maximal supported file size!). * Renamed vm_page::ppn to physical_page_number. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15637 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d608540b67e096e46c34092480b92a684e5b8b6b |
|
20-Dec-2005 |
Axel Dörfler <axeld@pinc-software.de> |
Separated vm_address_space.h from vm.h. Some more cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15614 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
96e01a27bffd323883c58cf6c2f0f93275a0234e |
|
20-Dec-2005 |
Axel Dörfler <axeld@pinc-software.de> |
* Merged vm_virtual_map with vm_address_space - there was no reason to have them apart (this even saves a pointer from vm_virtual_map to its address space) * aspace -> address_space * vm_create_address_space() did not check if creating the semaphore succeeded * Removed team::kaspace - was not really needed (introduced a new vm_kernel_address_space() function that doesn't grab a reference to the address space) * Removed vm_address_space::name - it was just a copy of the team name, anyway, and there is always only one address space per team * Removed aspace_id - the address space is now using the team_id * Some cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15609 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
9d845483cf2ced7587f734aa082b3c001795dca2 |
|
19-Dec-2005 |
Axel Dörfler <axeld@pinc-software.de> |
Got rid of two ToDo-items: instead of clearing the PAGE_MODIFIED flag after having written the page, we now do it before, so that it cannot lose any changed data anymore; it doesn't matter if the page is written to while writing it back, the worst thing that can happen is that we write the same page twice. Also, we don't rely on the PAGE_MODIFIED bit anymore, we now check all mappings of that page to find all modified pages, no matter how far the (currently disabled) page daemon had come. Also, destroying an area will now result in writing back changed pages - this is only really important for memory mapped files, though, and should probably be avoided for other vm_store types. Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15597 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
41e866f3ae9f335c32dc7eb3843bcc8572e42f6d |
|
16-Dec-2005 |
Axel Dörfler <axeld@pinc-software.de> |
The block cache now registers and uses a low memory handler that will flush unused blocks when needed. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15561 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
51a3c450bebefa32a5636bc6078bdd648818da41 |
|
13-Dec-2005 |
Axel Dörfler <axeld@pinc-software.de> |
The short story: we now have MTRR support on Intel and AMD CPUs (the latter has not yet been tested, though - I'll do this after this commit): * Removed the arch_memory_type stuff from vm_area; since there are only 8 memory ranges on x86, it's simply overkill. The MTRR code now remembers the area ID and finds the MTRR that way (it could also iterate over the existing MTRRs). * Introduced some post_modules() init functions. * If the other x86 CPUs out there don't differ a lot, MTRR functionality might be put back into the kernel. * x86_write_msr() was broken, it wrote the 64 bit number with the 32 bit words switched - it took me some time (and lots of #GPs) to figure that one out. * Removed the macro read_ebp() and introduced a function x86_read_ebp() (it's not really a time critical call). * Followed the Intel docs on how to change MTRRs (symmetrically on all CPUs with caches turned off). * Asking for memory types will automatically change the requested length to a power of two - note that BeOS seems to behave in the same, although that's not really very clean. * fixed MTRRs are ignored for now - we should make sure at least, though, that they are identical on all CPUs (or turn them off, even though I'd prefer the BIOS stuff to be uncacheable, which we don't enforce yet, though). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15528 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
2ed21b85257d9d36d4d8a25c2a798a42add6e618 |
|
12-Dec-2005 |
Axel Dörfler <axeld@pinc-software.de> |
Some work in progress of the MTRR support. Shouldn't do any harm yet :-) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15525 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
7c0a93573b061c8ff2b1e9e8644eb3943c1f5855 |
|
12-Dec-2005 |
Axel Dörfler <axeld@pinc-software.de> |
Preparation for MTRR support, code is completely untested, though. The CPU specific MTRR code will be in modules. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15520 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
2bea891d752d845e0dd036a1d908c90f3aacb2c8 |
|
24-Nov-2005 |
Axel Dörfler <axeld@pinc-software.de> |
Debug output change: vm_page_fault() doesn't kill the team anymore, it just sends a SIGSEGV signal (and lets the debugger handle the rest). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15145 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
e432cef2962c92aafd74bf07778786d661969dfc |
|
25-Aug-2005 |
Axel Dörfler <axeld@pinc-software.de> |
Updated a few more hash functions to be able to deal with negative numbers. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14067 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
099ceb8f9dcb58e0af4d04849480152545439e89 |
|
21-Aug-2005 |
Axel Dörfler <axeld@pinc-software.de> |
map_physical_memory() and its backend vm_map_physical_memory() did not map in the pages, ie. they considered the areas to be B_LAZY_LOCK. But that doesn't really make sense and potentially cause page faults where you wouldn't expect them (and where it's not a good idea to trigger them). Reworked display_mem() (used by the dw/db/ds commands in the kernel debugger) to be a bit more sane, improved formatting, and allows it to work on non-existing memory without a panic. The "area" debugger command now also accepts an address (contained by the area) as argument - and it will now always print out an error message if no matching area could be found. Replaced all dprintf() calls to kprintf() calls for the kernel debugger functions. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14042 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
eab435cd59a30d144ecc077fbdbc1bb37b3eb5a6 |
|
05-Aug-2005 |
Axel Dörfler <axeld@pinc-software.de> |
vfs_get_vnode_cache() now only allocates a new cache if requested: this prevents the system to allocate caches for files that don't use or have a file cache (ie. only those can be mmap()ed!). Therefore, cache_prefetch() no longer crashes when trying to prefetch files without a file cache. read_into_cache() no longer does anything if the requested size is 0. Fixed a bug in cache_prefetch_vnode(): if the cache couldn't be retrieved, it put the vnode, but didn't own it (the caller does). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13904 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
b72cf2601fbc931d2b3224e285eb26d09b20ea5e |
|
01-Aug-2005 |
Axel Dörfler <axeld@pinc-software.de> |
Renamed vfs_vnode_acquire_ref() to vnode_acquire_vnode(). Removed vfs_vnode_release_ref(), as vfs_put_vnode() already does the same thing. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13867 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
230a037ed4e6180f6ca73dc17b69dee8ce1fb811 |
|
19-Jul-2005 |
Axel Dörfler <axeld@pinc-software.de> |
Fixed a bad bug in vm_copy_on_write_area(): the area's cache offset was not taken into account when remapping the pages read-only; it could have overwritten valid page mappings this way. This was also the reason for the Terminal to crash - it does now work as it should, although some keys don't work (like tab completion)). vm_copy_area() no longer always sets B_KERNEL_WRITE_AREA if no kernel protection was specified, but mirrors the userland protection (for example, the x86 MMU is not able to have a page writable in kernel but not in userland). This caused some areas to be read/write when read-only would have been enough. vm_copy_area() now panics when vm_copy_on_write_area() fails - that's of course no real solution, but it's bettern than letting it silently fail. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13768 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
b7a96f02fd5d6ac737c389c9168cda91d7e1376a |
|
30-Jun-2005 |
Axel Dörfler <axeld@pinc-software.de> |
Now fills in system_info::cpu_infos[] (ie. CPU activity) by looking at the active time of the idle thread. IOW Pulse now works :-) Renamed the idle thread/stack to start with 1 instead of 0 (first idle thread will be called "idle thread 1"). Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13373 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
e970b839a0ba2c78aa2ece93ca01ba5f27701bf0 |
|
30-Jun-2005 |
Axel Dörfler <axeld@pinc-software.de> |
Disabled B_USER_CLONEABLE_AREA for now - maybe this should be handled via kernel settings later. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13372 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
b84688be5fa069d69df1c4bed506cf6347d5edf3 |
|
13-Jun-2005 |
Axel Dörfler <axeld@pinc-software.de> |
Added a basic low memory handler service. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13090 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
62d6961672d6a404abf15eac1cfb92284485f359 |
|
16-May-2005 |
Axel Dörfler <axeld@pinc-software.de> |
Renamed vm.c to vm.cpp and made all the changes to let it compile without errors. Also made the VM headers C++ safe. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12694 a95241bf-73f2-0310-859d-f6bbb57e9c96
|