* Added a TODO about a problematic use of vm_page_allocate_page() in combination
with vm_cache_acquire_locked_page_cache(). * Added new function vm_page_num_unused_pages() which returns the pages that are actually completely free and unused. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30514 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
1ce7a6b540
commit
2d8073a9dc
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2008, Axel Dörfler, axeld@pinc-software.de.
|
||||
* 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.
|
||||
|
@ -35,6 +35,7 @@ void vm_page_requeue(struct vm_page *page, bool tail);
|
|||
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,
|
||||
|
|
|
@ -345,6 +345,9 @@ vm_cache_acquire_locked_page_cache(vm_page* page, bool dontWait)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
// TODO: this is problematic, as it requires the caller not to have
|
||||
// a lock on this cache (it might be called via
|
||||
// vm_page_allocate_page(..., false)).
|
||||
if (!cache->SwitchLock(&sCacheListLock)) {
|
||||
// cache has been deleted
|
||||
mutex_lock(&sCacheListLock);
|
||||
|
|
|
@ -1893,6 +1893,8 @@ vm_page_try_reserve_pages(uint32 count)
|
|||
}
|
||||
|
||||
|
||||
// TODO: you must not have locked a cache when calling this function with
|
||||
// reserved == false. See vm_cache_acquire_locked_page_cache().
|
||||
vm_page *
|
||||
vm_page_allocate_page(int pageState, bool reserved)
|
||||
{
|
||||
|
@ -2167,13 +2169,20 @@ vm_page_num_free_pages(void)
|
|||
{
|
||||
size_t reservedPages = sReservedPages;
|
||||
size_t count = free_page_queue_count() + sInactivePageQueue.count;
|
||||
if (reservedPages > count)
|
||||
if (reservedPages >= count)
|
||||
return 0;
|
||||
|
||||
return count - reservedPages;
|
||||
}
|
||||
|
||||
|
||||
size_t
|
||||
vm_page_num_unused_pages(void)
|
||||
{
|
||||
return free_page_queue_count() - sReservedPages;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
vm_page_get_stats(system_info *info)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue