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
This commit is contained in:
Axel Dörfler
2008-03-25 11:51:45 +00:00
parent b11e554156
commit 41f8d41647
7 changed files with 34 additions and 7 deletions
+2 -1
View File
@@ -657,7 +657,8 @@ typedef struct {
int64 kernel_version; /* version of this kernel */
bigtime_t _busy_wait_time; /* reserved for whatever */
int32 pad[4]; /* just in case... */
int32 cached_pages;
int32 pad[3]; /* just in case... */
} system_info;
/* system private, use macro instead */
+3 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007, Axel Dörfler, [email protected]. All rights reserved.
* Copyright 2002-2008, Axel Dörfler, [email protected]. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
@@ -138,6 +138,8 @@ status_t vm_map_page(struct vm_area *area, struct vm_page *page, addr_t address,
status_t vm_get_physical_page(addr_t paddr, addr_t *vaddr, uint32 flags);
status_t vm_put_physical_page(addr_t vaddr);
off_t vm_get_available_memory(void);
// user syscalls
area_id _user_create_area(const char *name, void **address, uint32 addressSpec,
size_t size, uint32 lock, uint32 protection);
+2 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007, Axel Dörfler, [email protected].
* Copyright 2002-2008, Axel Dörfler, [email protected].
* Distributed under the terms of the MIT License.
*
* Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
@@ -33,6 +33,7 @@ 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);
status_t vm_page_write_modified_pages(struct vm_cache *cache, bool fsReenter);
void vm_page_schedule_write_page(struct vm_page *page);
+2 -1
View File
@@ -517,9 +517,10 @@ dump_cpus(system_info *info)
static void
dump_mem(system_info *info)
{
printf("%10lu bytes free (used/max %10lu / %10lu)\n",
printf("%10lu bytes free (used/cached/max %10lu / %10lu / %10lu)\n",
B_PAGE_SIZE * (uint32)(info->max_pages - info->used_pages),
B_PAGE_SIZE * (uint32)info->used_pages,
B_PAGE_SIZE * (uint32)info->cached_pages,
B_PAGE_SIZE * (uint32)info->max_pages);
}
+3 -2
View File
@@ -79,8 +79,9 @@ _get_system_info(system_info *info, size_t size)
// ToDo: Add page_faults
info->max_pages = vm_page_num_pages();
info->used_pages = vm_page_num_pages() - vm_page_num_free_pages();
info->used_pages = vm_page_num_pages() - vm_page_num_available_pages();
info->cached_pages = vm_page_num_pages() - vm_page_num_free_pages()
- info->used_pages;
info->used_threads = thread_used_threads();
info->max_threads = thread_max_threads();
info->used_teams = team_used_teams();
+7
View File
@@ -4363,6 +4363,13 @@ vm_get_physical_page(addr_t paddr, addr_t *_vaddr, uint32 flags)
}
off_t
vm_get_available_memory(void)
{
return sAvailableMemory;
}
status_t
vm_put_physical_page(addr_t vaddr)
{
+15 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007, Axel Dörfler, axeld@pinc-software.de.
* Copyright 2002-2008, Axel Dörfler, axeld@pinc-software.de.
* Distributed under the terms of the MIT License.
*
* Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
@@ -1830,6 +1830,20 @@ vm_page_num_pages(void)
}
/*! There is a subtle distinction between the page counts returned by
this function and vm_page_num_free_pages():
The latter returns the number of pages that are completely uncommitted,
whereas this one returns the number of pages that are available for
use by being reclaimed as well (IOW it factors in things like cache pages
as available).
*/
size_t
vm_page_num_available_pages(void)
{
return vm_get_available_memory() / B_PAGE_SIZE;
}
size_t
vm_page_num_free_pages(void)
{