40bb94819e
* 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
75 lines
2.2 KiB
C
75 lines
2.2 KiB
C
/*
|
|
* Copyright 2002-2009, Axel Dörfler, axeld@pinc-software.de.
|
|
* Distributed under the terms of the MIT License.
|
|
*
|
|
* Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
|
|
* Distributed under the terms of the NewOS License.
|
|
*/
|
|
#ifndef _KERNEL_VM_VM_PAGE_H
|
|
#define _KERNEL_VM_VM_PAGE_H
|
|
|
|
|
|
#include <vm/vm.h>
|
|
|
|
|
|
struct kernel_args;
|
|
|
|
extern int32 gMappedPagesCount;
|
|
|
|
|
|
struct vm_page_reservation {
|
|
uint32 count;
|
|
};
|
|
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
void vm_page_init_num_pages(struct kernel_args *args);
|
|
status_t vm_page_init(struct kernel_args *args);
|
|
status_t vm_page_init_post_area(struct kernel_args *args);
|
|
status_t vm_page_init_post_thread(struct kernel_args *args);
|
|
|
|
status_t vm_mark_page_inuse(addr_t page);
|
|
status_t vm_mark_page_range_inuse(addr_t startPage, addr_t length);
|
|
void vm_page_free(struct VMCache *cache, struct vm_page *page);
|
|
void vm_page_set_state(struct vm_page *page, int state);
|
|
void vm_page_requeue(struct vm_page *page, bool tail);
|
|
|
|
// get some data about the number of pages in the system
|
|
size_t vm_page_num_pages(void);
|
|
size_t vm_page_num_free_pages(void);
|
|
size_t vm_page_num_available_pages(void);
|
|
size_t vm_page_num_unused_pages(void);
|
|
void vm_page_get_stats(system_info *info);
|
|
|
|
status_t vm_page_write_modified_page_range(struct VMCache *cache,
|
|
uint32 firstPage, uint32 endPage);
|
|
status_t vm_page_write_modified_pages(struct VMCache *cache);
|
|
void vm_page_schedule_write_page(struct vm_page *page);
|
|
void vm_page_schedule_write_page_range(struct VMCache *cache,
|
|
uint32 firstPage, uint32 endPage);
|
|
|
|
void vm_page_unreserve_pages(vm_page_reservation* reservation);
|
|
void vm_page_reserve_pages(vm_page_reservation* reservation, uint32 count,
|
|
int priority);
|
|
bool vm_page_try_reserve_pages(vm_page_reservation* reservation, uint32 count,
|
|
int priority);
|
|
|
|
struct vm_page *vm_page_allocate_page(vm_page_reservation* reservation,
|
|
uint32 flags);
|
|
struct vm_page *vm_page_allocate_page_run(uint32 flags, addr_t base,
|
|
addr_t length, int priority);
|
|
struct vm_page *vm_page_allocate_page_run_no_base(uint32 flags, addr_t count,
|
|
int priority);
|
|
struct vm_page *vm_page_at_index(int32 index);
|
|
struct vm_page *vm_lookup_page(addr_t pageNumber);
|
|
bool vm_page_is_dummy(struct vm_page *page);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* _KERNEL_VM_VM_PAGE_H */
|