2002-07-09 16:24:59 +04:00
|
|
|
/*
|
2009-06-19 12:23:11 +04:00
|
|
|
* Copyright 2002-2009, Axel Dörfler, axeld@pinc-software.de.
|
2004-12-14 01:04:26 +03:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
|
|
|
|
* Distributed under the terms of the NewOS License.
|
|
|
|
*/
|
2009-12-02 21:05:10 +03:00
|
|
|
#ifndef _KERNEL_VM_VM_H
|
|
|
|
#define _KERNEL_VM_VM_H
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2008-05-14 07:55:16 +04:00
|
|
|
#include <OS.h>
|
2003-05-03 20:03:26 +04:00
|
|
|
|
2005-12-21 15:38:31 +03:00
|
|
|
#include <arch/vm.h>
|
2008-05-14 07:55:16 +04:00
|
|
|
#include <vm_defs.h>
|
2010-06-10 01:21:18 +04:00
|
|
|
#include <vm/vm_types.h>
|
2007-09-27 16:21:33 +04:00
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2010-06-02 22:42:20 +04:00
|
|
|
struct generic_io_vec;
|
2003-05-03 20:03:26 +04:00
|
|
|
struct kernel_args;
|
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
2010-01-22 02:10:52 +03:00
|
|
|
struct ObjectCache;
|
2008-09-17 20:27:17 +04:00
|
|
|
struct system_memory_info;
|
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
2010-01-22 02:10:52 +03:00
|
|
|
struct team;
|
2009-12-01 20:27:09 +03:00
|
|
|
struct VMAddressSpace;
|
2009-12-01 20:40:04 +03:00
|
|
|
struct VMArea;
|
2008-07-23 00:36:32 +04:00
|
|
|
struct VMCache;
|
2009-12-01 20:27:09 +03:00
|
|
|
struct vm_page;
|
2007-09-26 04:20:23 +04:00
|
|
|
struct vnode;
|
2010-04-11 19:07:06 +04:00
|
|
|
struct VMPageWiringInfo;
|
2003-05-03 20:03:26 +04:00
|
|
|
|
|
|
|
|
2008-08-22 02:50:11 +04:00
|
|
|
// area creation flags
|
|
|
|
#define CREATE_AREA_DONT_WAIT 0x01
|
|
|
|
#define CREATE_AREA_UNMAP_ADDRESS_RANGE 0x02
|
2009-07-29 22:57:21 +04:00
|
|
|
#define CREATE_AREA_DONT_CLEAR 0x04
|
2010-01-26 17:44:58 +03:00
|
|
|
#define CREATE_AREA_PRIORITY_VIP 0x08
|
2010-05-06 18:59:14 +04:00
|
|
|
#define CREATE_AREA_DONT_COMMIT_MEMORY 0x10
|
2010-01-26 17:44:58 +03:00
|
|
|
|
|
|
|
// memory/page allocation priorities
|
|
|
|
#define VM_PRIORITY_USER 0
|
|
|
|
#define VM_PRIORITY_SYSTEM 1
|
|
|
|
#define VM_PRIORITY_VIP 2
|
|
|
|
|
|
|
|
// page reserves
|
|
|
|
#define VM_PAGE_RESERVE_USER 512
|
|
|
|
#define VM_PAGE_RESERVE_SYSTEM 128
|
|
|
|
|
|
|
|
// memory reserves
|
|
|
|
#define VM_MEMORY_RESERVE_USER (VM_PAGE_RESERVE_USER * B_PAGE_SIZE)
|
|
|
|
#define VM_MEMORY_RESERVE_SYSTEM (VM_PAGE_RESERVE_SYSTEM * B_PAGE_SIZE)
|
2008-08-22 02:50:11 +04:00
|
|
|
|
|
|
|
|
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
2010-01-22 02:10:52 +03:00
|
|
|
extern struct ObjectCache* gPageMappingsObjectCache;
|
|
|
|
|
|
|
|
|
2003-06-27 06:27:43 +04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2007-02-27 22:26:40 +03:00
|
|
|
// startup only
|
2007-09-27 16:21:33 +04:00
|
|
|
status_t vm_init(struct kernel_args *args);
|
2004-10-20 03:19:10 +04:00
|
|
|
status_t vm_init_post_sem(struct kernel_args *args);
|
|
|
|
status_t vm_init_post_thread(struct kernel_args *args);
|
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
2005-12-13 19:34:29 +03:00
|
|
|
status_t vm_init_post_modules(struct kernel_args *args);
|
2007-09-27 16:21:33 +04:00
|
|
|
void vm_free_kernel_args(struct kernel_args *args);
|
2004-10-20 03:19:10 +04:00
|
|
|
void vm_free_unused_boot_loader_range(addr_t start, addr_t end);
|
2010-06-10 01:21:18 +04:00
|
|
|
page_num_t vm_allocate_early_physical_page(kernel_args *args);
|
2007-09-27 16:21:33 +04:00
|
|
|
addr_t vm_allocate_early(struct kernel_args *args, size_t virtualSize,
|
2010-06-09 15:15:43 +04:00
|
|
|
size_t physicalSize, uint32 attributes, addr_t alignment);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
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
2010-01-25 16:46:58 +03:00
|
|
|
void slab_init(struct kernel_args *args);
|
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
2010-01-22 02:10:52 +03:00
|
|
|
void slab_init_post_area();
|
2007-04-29 06:23:37 +04:00
|
|
|
void slab_init_post_sem();
|
2008-08-21 07:21:37 +04:00
|
|
|
void slab_init_post_thread();
|
2007-04-29 06:23:37 +04:00
|
|
|
|
2005-12-20 18:54:45 +03:00
|
|
|
// to protect code regions with interrupts turned on
|
|
|
|
void permit_page_faults(void);
|
|
|
|
void forbid_page_faults(void);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2003-08-19 18:11:58 +04:00
|
|
|
// private kernel only extension (should be moved somewhere else):
|
* 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
2010-06-14 20:25:14 +04:00
|
|
|
area_id create_area_etc(team_id team, const char *name, uint32 size,
|
|
|
|
uint32 lock, uint32 protection, uint32 flags,
|
|
|
|
const virtual_address_restrictions* virtualAddressRestrictions,
|
|
|
|
const physical_address_restrictions* physicalAddressRestrictions,
|
|
|
|
void **_address);
|
2009-07-17 20:21:06 +04:00
|
|
|
area_id transfer_area(area_id id, void** _address, uint32 addressSpec,
|
|
|
|
team_id target, bool kernel);
|
2003-08-19 18:11:58 +04:00
|
|
|
|
2009-09-10 05:40:46 +04:00
|
|
|
status_t vm_block_address_range(const char* name, void* address, addr_t size);
|
2005-12-20 18:54:45 +03:00
|
|
|
status_t vm_unreserve_address_range(team_id team, void *address, addr_t size);
|
2008-04-02 16:30:06 +04:00
|
|
|
status_t vm_reserve_address_range(team_id team, void **_address,
|
2005-05-15 19:56:55 +04:00
|
|
|
uint32 addressSpec, addr_t size, uint32 flags);
|
* 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
2010-06-14 20:25:14 +04:00
|
|
|
area_id vm_create_anonymous_area(team_id team, const char* name, addr_t size,
|
|
|
|
uint32 wiring, uint32 protection, uint32 flags,
|
|
|
|
const virtual_address_restrictions* virtualAddressRestrictions,
|
|
|
|
const physical_address_restrictions* physicalAddressRestrictions,
|
|
|
|
bool kernel, void** _address);
|
2008-04-02 16:30:06 +04:00
|
|
|
area_id vm_map_physical_memory(team_id team, const char *name, void **address,
|
2010-01-14 01:02:21 +03:00
|
|
|
uint32 addressSpec, addr_t size, uint32 protection,
|
2010-05-26 01:34:08 +04:00
|
|
|
phys_addr_t physicalAddress, bool alreadyWired);
|
2009-10-11 20:48:03 +04:00
|
|
|
area_id vm_map_physical_memory_vecs(team_id team, const char* name,
|
|
|
|
void** _address, uint32 addressSpec, addr_t* _size, uint32 protection,
|
2010-06-02 22:42:20 +04:00
|
|
|
struct generic_io_vec* vecs, uint32 vecCount);
|
2008-04-02 16:30:06 +04:00
|
|
|
area_id vm_map_file(team_id aid, const char *name, void **address,
|
|
|
|
uint32 addressSpec, addr_t size, uint32 protection, uint32 mapping,
|
2009-06-19 12:23:11 +04:00
|
|
|
bool unmapAddressRange, int fd, off_t offset);
|
2009-12-01 20:40:04 +03:00
|
|
|
struct VMCache *vm_area_get_locked_cache(struct VMArea *area);
|
2008-07-23 00:36:32 +04:00
|
|
|
void vm_area_put_locked_cache(struct VMCache *cache);
|
2008-04-02 16:30:06 +04:00
|
|
|
area_id vm_create_null_area(team_id team, const char *name, void **address,
|
2010-01-26 17:44:58 +03:00
|
|
|
uint32 addressSpec, addr_t size, uint32 flags);
|
2008-04-02 16:30:06 +04:00
|
|
|
area_id vm_copy_area(team_id team, const char *name, void **_address,
|
2005-05-15 19:56:55 +04:00
|
|
|
uint32 addressSpec, uint32 protection, area_id sourceID);
|
2008-04-02 16:30:06 +04:00
|
|
|
area_id vm_clone_area(team_id team, const char *name, void **address,
|
|
|
|
uint32 addressSpec, uint32 protection, uint32 mapping,
|
2008-05-11 20:02:13 +04:00
|
|
|
area_id sourceArea, bool kernel);
|
|
|
|
status_t vm_delete_area(team_id teamID, area_id areaID, bool kernel);
|
2008-07-23 00:36:32 +04:00
|
|
|
status_t vm_create_vnode_cache(struct vnode *vnode, struct VMCache **_cache);
|
2010-05-26 01:34:08 +04:00
|
|
|
status_t vm_set_area_memory_type(area_id id, phys_addr_t physicalBase,
|
|
|
|
uint32 type);
|
|
|
|
status_t vm_get_page_mapping(team_id team, addr_t vaddr, phys_addr_t *paddr);
|
2007-09-28 19:50:26 +04:00
|
|
|
bool vm_test_map_modification(struct vm_page *page);
|
|
|
|
void vm_clear_map_flags(struct vm_page *page, uint32 flags);
|
* 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
2010-02-03 21:53:52 +03:00
|
|
|
void vm_remove_all_page_mappings(struct vm_page *page);
|
|
|
|
int32 vm_clear_page_mapping_accessed_flags(struct vm_page *page);
|
|
|
|
int32 vm_remove_all_page_mappings_if_unaccessed(struct vm_page *page);
|
2010-04-11 19:07:06 +04:00
|
|
|
status_t vm_wire_page(team_id team, addr_t address, bool writable,
|
|
|
|
struct VMPageWiringInfo* info);
|
|
|
|
void vm_unwire_page(struct VMPageWiringInfo* info);
|
* 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
2008-10-20 04:06:09 +04:00
|
|
|
|
2010-05-26 01:34:08 +04:00
|
|
|
status_t vm_get_physical_page(phys_addr_t paddr, addr_t* vaddr, void** _handle);
|
* 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
2008-10-20 04:06:09 +04:00
|
|
|
status_t vm_put_physical_page(addr_t vaddr, void* handle);
|
2010-05-26 01:34:08 +04:00
|
|
|
status_t vm_get_physical_page_current_cpu(phys_addr_t paddr, addr_t* vaddr,
|
* 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
2008-10-20 04:06:09 +04:00
|
|
|
void** _handle);
|
|
|
|
status_t vm_put_physical_page_current_cpu(addr_t vaddr, void* handle);
|
2010-05-26 01:34:08 +04:00
|
|
|
status_t vm_get_physical_page_debug(phys_addr_t paddr, addr_t* vaddr,
|
* 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
2008-10-20 04:06:09 +04:00
|
|
|
void** _handle);
|
|
|
|
status_t vm_put_physical_page_debug(addr_t vaddr, void* handle);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2008-09-17 20:27:17 +04:00
|
|
|
void vm_get_info(struct system_memory_info *info);
|
|
|
|
uint32 vm_num_page_faults(void);
|
2008-04-02 16:30:06 +04:00
|
|
|
off_t vm_available_memory(void);
|
2008-07-23 00:36:32 +04:00
|
|
|
off_t vm_available_not_needed_memory(void);
|
2009-11-27 16:03:28 +03:00
|
|
|
size_t vm_kernel_address_space_left(void);
|
2008-03-25 14:51:45 +03:00
|
|
|
|
2010-05-26 01:34:08 +04:00
|
|
|
status_t vm_memset_physical(phys_addr_t address, int value, size_t length);
|
|
|
|
status_t vm_memcpy_from_physical(void* to, phys_addr_t from, size_t length,
|
* 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
2008-10-20 04:06:09 +04:00
|
|
|
bool user);
|
2010-05-26 01:34:08 +04:00
|
|
|
status_t vm_memcpy_to_physical(phys_addr_t to, const void* from, size_t length,
|
* 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
2008-10-20 04:06:09 +04:00
|
|
|
bool user);
|
2010-05-26 01:34:08 +04:00
|
|
|
void vm_memcpy_physical_page(phys_addr_t to, phys_addr_t from);
|
2008-10-17 20:32:12 +04:00
|
|
|
|
2010-04-13 21:40:15 +04:00
|
|
|
status_t vm_debug_copy_page_memory(team_id teamID, void* unsafeMemory,
|
|
|
|
void* buffer, size_t size, bool copyToUnsafe);
|
|
|
|
|
2005-12-20 18:54:45 +03:00
|
|
|
// user syscalls
|
2003-08-19 18:11:58 +04:00
|
|
|
area_id _user_create_area(const char *name, void **address, uint32 addressSpec,
|
2003-08-20 19:47:52 +04:00
|
|
|
size_t size, uint32 lock, uint32 protection);
|
2003-08-19 18:11:58 +04:00
|
|
|
status_t _user_delete_area(area_id area);
|
2008-08-08 05:00:06 +04:00
|
|
|
|
2010-05-01 23:47:39 +04:00
|
|
|
area_id _user_map_file(const char *uname, void **uaddress, uint32 addressSpec,
|
|
|
|
size_t size, uint32 protection, uint32 mapping,
|
|
|
|
bool unmapAddressRange, int fd, off_t offset);
|
2008-08-08 05:00:06 +04:00
|
|
|
status_t _user_unmap_memory(void *address, size_t size);
|
|
|
|
status_t _user_set_memory_protection(void* address, size_t size,
|
2010-05-01 23:47:39 +04:00
|
|
|
uint32 protection);
|
|
|
|
status_t _user_sync_memory(void *address, size_t size, uint32 flags);
|
|
|
|
status_t _user_memory_advice(void* address, size_t size, uint32 advice);
|
2008-08-08 05:00:06 +04:00
|
|
|
|
2003-08-20 19:47:52 +04:00
|
|
|
area_id _user_area_for(void *address);
|
|
|
|
area_id _user_find_area(const char *name);
|
|
|
|
status_t _user_get_area_info(area_id area, area_info *info);
|
|
|
|
status_t _user_get_next_area_info(team_id team, int32 *cookie, area_info *info);
|
|
|
|
status_t _user_resize_area(area_id area, size_t newSize);
|
2008-04-02 16:30:06 +04:00
|
|
|
area_id _user_transfer_area(area_id area, void **_address, uint32 addressSpec,
|
2005-05-15 19:56:55 +04:00
|
|
|
team_id target);
|
2003-08-20 19:47:52 +04:00
|
|
|
status_t _user_set_area_protection(area_id area, uint32 newProtection);
|
2008-04-02 16:30:06 +04:00
|
|
|
area_id _user_clone_area(const char *name, void **_address, uint32 addressSpec,
|
2003-08-20 19:47:52 +04:00
|
|
|
uint32 protection, area_id sourceArea);
|
2009-06-19 15:09:21 +04:00
|
|
|
status_t _user_reserve_address_range(addr_t* userAddress, uint32 addressSpec,
|
2006-03-18 15:52:01 +03:00
|
|
|
addr_t size);
|
2009-06-19 15:09:21 +04:00
|
|
|
status_t _user_unreserve_address_range(addr_t address, addr_t size);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2003-06-27 06:27:43 +04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
2002-07-09 16:24:59 +04:00
|
|
|
#endif
|
|
|
|
|
2009-12-02 21:05:10 +03:00
|
|
|
#endif /* _KERNEL_VM_VM_H */
|