[haiku-commits] r33597 - in haiku/trunk/src: system/kernel/vm tests/system/kernel

  • From: axeld@xxxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 15 Oct 2009 13:23:38 +0200 (CEST)

Author: axeld
Date: 2009-10-15 13:23:38 +0200 (Thu, 15 Oct 2009)
New Revision: 33597
Changeset: http://dev.haiku-os.org/changeset/33597/haiku

Modified:
   haiku/trunk/src/system/kernel/vm/vm.cpp
   haiku/trunk/src/tests/system/kernel/reserved_areas_test.cpp
Log:
* Reserved areas would also be created in existing reserved areas in case the
  space was becoming tight. This actually fixes #4778.
* Fixed overflow problem in find_reserved_area().
* Cleaned up the test app, added license.


Modified: haiku/trunk/src/system/kernel/vm/vm.cpp
===================================================================
--- haiku/trunk/src/system/kernel/vm/vm.cpp     2009-10-15 10:13:02 UTC (rev 
33596)
+++ haiku/trunk/src/system/kernel/vm/vm.cpp     2009-10-15 11:23:38 UTC (rev 
33597)
@@ -1022,8 +1022,8 @@
        next = addressSpace->areas;
        while (next != NULL) {
                if (next->base <= start
-                       && next->base + next->size > start + (size - 1)) {
-                       // this area covers the requested range
+                       && next->base + (next->size - 1) >= start + (size - 1)) 
{
+                       // This area covers the requested range
                        if (next->id != RESERVED_AREA_ID) {
                                // but it's not reserved space, it's a real area
                                return B_BAD_VALUE;
@@ -1039,7 +1039,7 @@
        if (next == NULL)
                return B_ENTRY_NOT_FOUND;
 
-       // now we have to transfer the requested part of the reserved
+       // Now we have to transfer the requested part of the reserved
        // range to the new area - and remove, resize or split the old
        // reserved area.
 
@@ -1126,7 +1126,7 @@
                || start + (size - 1) > end)
                return B_BAD_ADDRESS;
 
-       if (addressSpec == B_EXACT_ADDRESS) {
+       if (addressSpec == B_EXACT_ADDRESS && area->id != RESERVED_AREA_ID) {
                // search for a reserved area
                status_t status = find_reserved_area(addressSpace, start, size, 
area);
                if (status == B_OK || status == B_BAD_VALUE)
@@ -1206,7 +1206,7 @@
                                foundSpot = true;
                                area->base = alignedBase;
                                break;
-                       } else {
+                       } else if (area->id != RESERVED_AREA_ID) {
                                // We didn't find a free spot - if there are 
any reserved areas,
                                // we can now test those for free space
                                // TODO: it would make sense to start with the 
biggest of them

Modified: haiku/trunk/src/tests/system/kernel/reserved_areas_test.cpp
===================================================================
--- haiku/trunk/src/tests/system/kernel/reserved_areas_test.cpp 2009-10-15 
10:13:02 UTC (rev 33596)
+++ haiku/trunk/src/tests/system/kernel/reserved_areas_test.cpp 2009-10-15 
11:23:38 UTC (rev 33597)
@@ -1,3 +1,9 @@
+/*
+ * Copyright 2009, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx
+ * Distributed under the terms of the MIT License.
+ */
+
+
 //!    Test application that reproduces bug #4778.
 
 
@@ -43,18 +49,17 @@
                        base = (void*)0x60000000;
                        status = _kern_reserve_address_range((addr_t*)&base, 
B_BASE_ADDRESS,
                                128 * 1024 * 1024);
-                       if (status != B_OK)
-                               snooze(10000000LL);
                        addressSpec = status == B_OK ? B_EXACT_ADDRESS : 
B_BASE_ADDRESS;
-printf("\naddress spec = %lx, base %p (status %s)\n", addressSpec, base, 
strerror(status));
+                       printf("\naddress spec = %lx, base %p (status %s)\n", 
addressSpec,
+                               base, strerror(status));
                }
 
                area_id area = create_area(readOnly ? "read-only memory" : "r/w 
memory",
                        &base, addressSpec, B_PAGE_SIZE * 4, B_NO_LOCK,
                        B_READ_AREA | (readOnly ? 0 : B_WRITE_AREA));
                if (area >= 0) {
-printf("new %s area %ld at %p\n", readOnly ? "read-only" : "r/w", area, base);
-//                     putchar('#');
+                       printf("new %s area %ld at %p\n", readOnly ? 
"read-only" : "r/w",
+                               area, base);
                } else
                        break;
 


Other related posts:

  • » [haiku-commits] r33597 - in haiku/trunk/src: system/kernel/vm tests/system/kernel - axeld