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
This commit is contained in:
Ingo Weinhold
2010-06-10 17:30:49 +00:00
parent 0c4c918a3d
commit 1d26c7248f
4 changed files with 28 additions and 9 deletions
+1 -1
View File
@@ -61,7 +61,7 @@ bool vm_page_try_reserve_pages(vm_page_reservation* reservation, uint32 count,
struct vm_page *vm_page_allocate_page(vm_page_reservation* reservation,
uint32 flags);
struct vm_page *vm_page_allocate_page_run(uint32 flags, phys_addr_t base,
page_num_t length, int priority);
phys_addr_t limit, page_num_t length, int priority);
struct vm_page *vm_page_at_index(int32 index);
struct vm_page *vm_lookup_page(page_num_t pageNumber);
bool vm_page_is_dummy(struct vm_page *page);
@@ -540,7 +540,7 @@ Aperture::AllocateMemory(aperture_memory *memory, uint32 flags)
if ((flags & B_APERTURE_NEED_PHYSICAL) != 0) {
memory->page = vm_page_allocate_page_run(
PAGE_STATE_WIRED | VM_PAGE_ALLOC_CLEAR, 0, count,
PAGE_STATE_WIRED | VM_PAGE_ALLOC_CLEAR, 0, 0, count,
VM_PRIORITY_SYSTEM);
if (memory->page == NULL)
return B_NO_MEMORY;
+1 -1
View File
@@ -1181,7 +1181,7 @@ vm_create_anonymous_area(team_id team, const char* name, void** address,
// we try to allocate the page run here upfront as this may easily
// fail for obvious reasons
page = vm_page_allocate_page_run(PAGE_STATE_WIRED | pageAllocFlags,
physicalAddress, size / B_PAGE_SIZE, priority);
physicalAddress, 0, size / B_PAGE_SIZE, priority);
if (page == NULL) {
status = B_NO_MEMORY;
goto err0;
+25 -6
View File
@@ -3319,11 +3319,30 @@ allocate_page_run(page_num_t start, page_num_t length, uint32 flags,
}
vm_page *
vm_page_allocate_page_run(uint32 flags, phys_addr_t base, page_num_t length,
int priority)
/*! Allocate a physically contiguous range of pages.
\param flags Page allocation flags. Encodes the state the function shall
set the allocated pages to, whether the pages shall be marked busy
(VM_PAGE_ALLOC_BUSY), and whether the pages shall be cleared
(VM_PAGE_ALLOC_CLEAR).
\param base The first acceptable physical address where the page run may
start.
\param limit The last acceptable physical address where the page run may
end (i.e. it must hold runStartAddress + runSize <= limit). If \c 0,
the limit is ignored.
\param length The number of contiguous pages to allocate.
\param priority The page reservation priority (as passed to
vm_page_reserve_pages()).
\return The first page of the allocated page run on success; \c NULL
when the allocation failed.
*/
vm_page*
vm_page_allocate_page_run(uint32 flags, phys_addr_t base, phys_addr_t limit,
page_num_t length, int priority)
{
page_num_t start = base >> PAGE_SHIFT;
page_num_t start = base / B_PAGE_SIZE;
page_num_t end = std::min(limit > 0 ? limit / B_PAGE_SIZE : sNumPages,
sNumPages);
vm_page_reservation reservation;
vm_page_reserve_pages(&reservation, length, priority);
@@ -3338,8 +3357,7 @@ vm_page_allocate_page_run(uint32 flags, phys_addr_t base, page_num_t length,
int useCached = freePages > 0 && (page_num_t)freePages > 2 * length ? 0 : 1;
for (;;) {
bool foundRun = true;
if (start + length > sNumPages) {
if (start + length > end) {
if (useCached == 0) {
// The first iteration with free pages only was unsuccessful.
// Try again also considering cached pages.
@@ -3356,6 +3374,7 @@ vm_page_allocate_page_run(uint32 flags, phys_addr_t base, page_num_t length,
return NULL;
}
bool foundRun = true;
page_num_t i;
for (i = 0; i < length; i++) {
uint32 pageState = sPages[start + i].State();