Split GENCGC_PAGE_BYTES in 3 constants
authorPaul Khuong <pvk@pvk.ca>
Sun, 3 Jul 2011 16:45:42 +0000 (12:45 -0400)
committerPaul Khuong <pvk@pvk.ca>
Sun, 3 Jul 2011 16:45:42 +0000 (12:45 -0400)
 * We still have BACKEND_PAGE_BYTES, which should be a conservative
   over-approximation of the OS's page size.

 * GENCGC_PAGE_BYTES is mostly replaced by GENCGC_CARD_BYTES, the
   byte granularity at which we track writes to old generations.
   While we're using mprotect-based write barriers, this should be
   a multiple of BACKEND_PAGE_BYTES.

 * GENCGC_ALLOC_GRANULARITY is the minimum size we attempt to make
   each allocation region.  Should be a multiple of GENCGC_CARD_BYTES.
   While we have largeish cards, this shouldn't ever be an issue, but
   it might if we ever go down to < 1k cards.

 * GENCGC_RELEASE_GRANULARITY is the minimum size at which we release
   address space to the OS.  This should always be a multiple of
   BACKEND_PAGE_BYTES.

 * For now, all three new constants are equal to BACKEND_PAGE_BYTES.

12 files changed:
contrib/sb-sprof/sb-sprof.lisp
package-data-list.lisp-expr
src/code/room.lisp
src/compiler/generic/genesis.lisp
src/compiler/ppc/backend-parms.lisp
src/compiler/x86-64/backend-parms.lisp
src/compiler/x86/backend-parms.lisp
src/runtime/gc.h
src/runtime/gencgc-internal.h
src/runtime/gencgc.c
src/runtime/linux-os.c
src/runtime/runtime.c

index 7d2374e..5a5b3e7 100644 (file)
@@ -360,10 +360,8 @@ profiling")
 (defvar *alloc-region-size*
   #-gencgc
   (get-page-size)
-  ;; This hardcoded 2 matches the one in gc_find_freeish_pages. It's not
-  ;; really worth genesifying.
   #+gencgc
-  (* 2 sb-vm:gencgc-page-bytes))
+  sb-vm:gencgc-alloc-granularity)
 (declaim (type number *alloc-region-size*))
 
 (defvar *samples* nil)
index 87b6362..a48e6d9 100644 (file)
@@ -2620,7 +2620,9 @@ structure representations"
                "FUN-POINTER-LOWTAG"
                "SIMPLE-FUN-SELF-SLOT"
                "SIMPLE-FUN-TYPE-SLOT"
-               "GENCGC-PAGE-BYTES"
+               "GENCGC-CARD-BYTES"
+               "GENCGC-ALLOC-GRANULARITY"
+               "GENCGC-RELEASE-GRANULARITY"
                #!+ppc "PSEUDO-ATOMIC-INTERRUPTED-FLAG"
                #!+ppc "PSEUDO-ATOMIC-FLAG"
                "GENESIS" "HALT-TRAP" "IGNORE-ME-SC-NUMBER"
index 2f3c02a..3877c29 100644 (file)
               ;; will be a short. On platforms with larger ones, it'll
               ;; be an int.
               (bytes-used (unsigned
-                           #.(if (typep sb!vm:gencgc-page-bytes
+                           #.(if (typep sb!vm:gencgc-card-bytes
                                         '(unsigned-byte 16))
                                  16
                                  32)))
                    (maybe-skip-page ()
                      #!+gencgc
                      (when (eq space :dynamic)
-                       (loop with page-mask = #.(1- sb!vm:gencgc-page-bytes)
+                       (loop with page-mask = #.(1- sb!vm:gencgc-card-bytes)
                              for addr of-type sb!vm:word = (sap-int current)
                              while (>= addr skip-tests-until-addr)
                              do
                                    (return-from maybe-skip-page))
                                  ;; Move CURRENT to start of next page.
                                  (setf current (int-sap (+ (logandc2 addr page-mask)
-                                                           sb!vm:gencgc-page-bytes)))
+                                                           sb!vm:gencgc-card-bytes)))
                                  (maybe-finish-mapping))))))
                    (maybe-map (obj obj-tag n-obj-bytes &optional (ok t))
                      (let ((next (typecase n-obj-bytes
index fac1eb4..10d6df0 100644 (file)
@@ -2798,7 +2798,9 @@ core and return a descriptor to it."
               (maybe-record-with-munged-name "-SUBTYPE" "subtype_" 4)
               (maybe-record-with-munged-name "-SC-NUMBER" "sc_" 5)
               (maybe-record-with-translated-name '("-SIZE") 6)
-              (maybe-record-with-translated-name '("-START" "-END" "-PAGE-BYTES") 7 :large t)
+              (maybe-record-with-translated-name '("-START" "-END" "-PAGE-BYTES"
+                                                   "-CARD-BYTES" "-GRANULARITY")
+                                                 7 :large t)
               (maybe-record-with-translated-name '("-CORE-ENTRY-TYPE-CODE") 8)
               (maybe-record-with-translated-name '("-CORE-SPACE-ID") 9)
               (maybe-record-with-translated-name '("-GENERATION+") 10))))))
index cfb3bb4..c57da60 100644 (file)
   ;; just use 4k everywhere.
   (setf *backend-page-bytes* #!+linux 65536 #!-linux 4096))
 
-;;; The size in bytes of the GENCGC pages. Should be a multiple of the
-;;; architecture page size.
-(def!constant gencgc-page-bytes *backend-page-bytes*)
+;;; The size in bytes of GENCGC cards, i.e. the granularity at which
+;;; writes to old generations are logged.  With mprotect-based write
+;;; barriers, this must be a multiple of the OS page size.
+(def!constant gencgc-card-bytes *backend-page-bytes*)
+;;; The minimum size of new allocation regions.  While it doesn't
+;;; currently make a lot of sense to have a card size lower than
+;;; the alloc granularity, it will, once we are smarter about finding
+;;; the start of objects.
+(def!constant gencgc-alloc-granularity *backend-page-bytes*)
+;;; The minimum size at which we release address ranges to the OS.
+;;; This must be a multiple of the OS page size.
+(def!constant gencgc-release-granularity *backend-page-bytes*)
index 1d5f418..f90310d 100644 (file)
 (eval-when (:compile-toplevel :load-toplevel :execute)
   (setf *backend-page-bytes* 32768))
 
-;;; The size in bytes of the GENCGC pages. Should be a multiple of the
-;;; architecture code size.
-(def!constant gencgc-page-bytes *backend-page-bytes*)
+;;; The size in bytes of GENCGC cards, i.e. the granularity at which
+;;; writes to old generations are logged.  With mprotect-based write
+;;; barriers, this must be a multiple of the OS page size.
+(def!constant gencgc-card-bytes *backend-page-bytes*)
+;;; The minimum size of new allocation regions.  While it doesn't
+;;; currently make a lot of sense to have a card size lower than
+;;; the alloc granularity, it will, once we are smarter about finding
+;;; the start of objects.
+(def!constant gencgc-alloc-granularity *backend-page-bytes*)
+;;; The minimum size at which we release address ranges to the OS.
+;;; This must be a multiple of the OS page size.
+(def!constant gencgc-release-granularity *backend-page-bytes*)
index 3f8cf62..5f1e90b 100644 (file)
 ;;;
 ;;;   would be: (setf *backend-page-bytes* 65536)
 
-;;; The size in bytes of the GENCGC pages. Should be a multiple of the
-;;; architecture code size.
-(def!constant gencgc-page-bytes *backend-page-bytes*)
+;;; The size in bytes of GENCGC cards, i.e. the granularity at which
+;;; writes to old generations are logged.  With mprotect-based write
+;;; barriers, this must be a multiple of the OS page size.
+(def!constant gencgc-card-bytes *backend-page-bytes*)
+;;; The minimum size of new allocation regions.  While it doesn't
+;;; currently make a lot of sense to have a card size lower than
+;;; the alloc granularity, it will, once we are smarter about finding
+;;; the start of objects.
+(def!constant gencgc-alloc-granularity *backend-page-bytes*)
+;;; The minimum size at which we release address ranges to the OS.
+;;; This must be a multiple of the OS page size.
+(def!constant gencgc-release-granularity *backend-page-bytes*)
index ce1b925..10c97a4 100644 (file)
 
 #include "sbcl.h"
 
-#ifdef LISP_FEATURE_GENCGC
-#define PAGE_BYTES GENCGC_PAGE_BYTES
-#else
 #define PAGE_BYTES BACKEND_PAGE_BYTES
-#endif
 
 typedef signed long page_index_t;
 typedef signed char generation_index_t;
index 84178ad..e4a34fb 100644 (file)
@@ -49,7 +49,7 @@ struct page {
      * allocation regions. It should be 0 for all unallocated pages (not
      * hard to achieve).
      */
-#if PAGE_BYTES > USHRT_MAX
+#if GENCGC_CARD_BYTES > USHRT_MAX
     unsigned int bytes_used;
 #else
     unsigned short bytes_used;
@@ -119,7 +119,7 @@ space_matches_p(lispobj obj, generation_index_t space)
 {
     if (obj >= DYNAMIC_SPACE_START) {
         page_index_t page_index=((pointer_sized_uint_t)obj
-                                 - DYNAMIC_SPACE_START) / PAGE_BYTES;
+                                 - DYNAMIC_SPACE_START) / GENCGC_CARD_BYTES;
         return ((page_index < page_table_pages) &&
                 (page_table[page_index].gen == space));
     } else {
index be5cc4b..86fcc4c 100644 (file)
@@ -81,7 +81,7 @@ enum {
 boolean enable_page_protection = 1;
 
 /* the minimum size (in bytes) for a large object*/
-long large_object_size = 4 * PAGE_BYTES;
+long large_object_size = 4 * GENCGC_ALLOC_GRANULARITY;
 
 \f
 /*
@@ -217,7 +217,7 @@ static void *heap_base = NULL;
 inline void *
 page_address(page_index_t page_num)
 {
-    return (heap_base + (page_num * PAGE_BYTES));
+    return (heap_base + (page_num * GENCGC_CARD_BYTES));
 }
 
 /* Calculate the address where the allocation region associated with
@@ -235,7 +235,7 @@ find_page_index(void *addr)
 {
     if (addr >= heap_base) {
         page_index_t index = ((pointer_sized_uint_t)addr -
-                              (pointer_sized_uint_t)heap_base) / PAGE_BYTES;
+                              (pointer_sized_uint_t)heap_base) / GENCGC_CARD_BYTES;
         if (index < page_table_pages)
             return (index);
     }
@@ -246,7 +246,7 @@ static size_t
 npage_bytes(long npages)
 {
     gc_assert(npages>=0);
-    return ((unsigned long)npages)*PAGE_BYTES;
+    return ((unsigned long)npages)*GENCGC_CARD_BYTES;
 }
 
 /* Check that X is a higher address than Y and return offset from Y to
@@ -791,7 +791,7 @@ gc_alloc_new_region(long nbytes, int page_type_flag, struct alloc_region *alloc_
     gc_assert(ret == 0);
     first_page = generation_alloc_start_page(gc_alloc_generation, page_type_flag, 0);
     last_page=gc_find_freeish_pages(&first_page, nbytes, page_type_flag);
-    bytes_found=(PAGE_BYTES - page_table[first_page].bytes_used)
+    bytes_found=(GENCGC_CARD_BYTES - page_table[first_page].bytes_used)
             + npage_bytes(last_page-first_page);
 
     /* Set up the alloc_region. */
@@ -1021,8 +1021,8 @@ gc_alloc_update_page_tables(int page_type_flag, struct alloc_region *alloc_regio
         more = 0;
         if ((bytes_used = void_diff(alloc_region->free_pointer,
                                     page_address(first_page)))
-            >PAGE_BYTES) {
-            bytes_used = PAGE_BYTES;
+            >GENCGC_CARD_BYTES) {
+            bytes_used = GENCGC_CARD_BYTES;
             more = 1;
         }
         page_table[first_page].bytes_used = bytes_used;
@@ -1046,8 +1046,8 @@ gc_alloc_update_page_tables(int page_type_flag, struct alloc_region *alloc_regio
             /* Calculate the number of bytes used in this page. */
             more = 0;
             if ((bytes_used = void_diff(alloc_region->free_pointer,
-                                        page_address(next_page)))>PAGE_BYTES) {
-                bytes_used = PAGE_BYTES;
+                                        page_address(next_page)))>GENCGC_CARD_BYTES) {
+                bytes_used = GENCGC_CARD_BYTES;
                 more = 1;
             }
             page_table[next_page].bytes_used = bytes_used;
@@ -1148,8 +1148,8 @@ gc_alloc_large(long nbytes, int page_type_flag, struct alloc_region *alloc_regio
     /* Calc. the number of bytes used in this page. This is not
      * always the number of new bytes, unless it was free. */
     more = 0;
-    if ((bytes_used = nbytes+orig_first_page_bytes_used) > PAGE_BYTES) {
-        bytes_used = PAGE_BYTES;
+    if ((bytes_used = nbytes+orig_first_page_bytes_used) > GENCGC_CARD_BYTES) {
+        bytes_used = GENCGC_CARD_BYTES;
         more = 1;
     }
     page_table[first_page].bytes_used = bytes_used;
@@ -1173,8 +1173,8 @@ gc_alloc_large(long nbytes, int page_type_flag, struct alloc_region *alloc_regio
         /* Calculate the number of bytes used in this page. */
         more = 0;
         bytes_used=(nbytes+orig_first_page_bytes_used)-byte_cnt;
-        if (bytes_used > PAGE_BYTES) {
-            bytes_used = PAGE_BYTES;
+        if (bytes_used > GENCGC_CARD_BYTES) {
+            bytes_used = GENCGC_CARD_BYTES;
             more = 1;
         }
         page_table[next_page].bytes_used = bytes_used;
@@ -1267,7 +1267,7 @@ gc_find_freeish_pages(page_index_t *restart_page_ptr, long nbytes,
     }
 
     gc_assert(nbytes>=0);
-    if (((unsigned long)nbytes)>=PAGE_BYTES) {
+    if (((unsigned long)nbytes)>=GENCGC_CARD_BYTES) {
         /* Search for a contiguous free space of at least nbytes,
          * aligned on a page boundary. The page-alignment is strictly
          * speaking needed only for objects at least large_object_size
@@ -1279,12 +1279,12 @@ gc_find_freeish_pages(page_index_t *restart_page_ptr, long nbytes,
                 first_page++;
 
             last_page = first_page;
-            bytes_found = PAGE_BYTES;
+            bytes_found = GENCGC_CARD_BYTES;
             while ((bytes_found < nbytes) &&
                    (last_page < (page_table_pages-1)) &&
                    page_free_p(last_page+1)) {
                 last_page++;
-                bytes_found += PAGE_BYTES;
+                bytes_found += GENCGC_CARD_BYTES;
                 gc_assert(0 == page_table[last_page].bytes_used);
                 gc_assert(0 == page_table[last_page].write_protected);
             }
@@ -1303,7 +1303,7 @@ gc_find_freeish_pages(page_index_t *restart_page_ptr, long nbytes,
             if (page_free_p(first_page))
                 {
                     gc_assert(0 == page_table[first_page].bytes_used);
-                    bytes_found = PAGE_BYTES;
+                    bytes_found = GENCGC_CARD_BYTES;
                     break;
                 }
             else if ((page_table[first_page].allocated == page_type_flag) &&
@@ -1312,7 +1312,7 @@ gc_find_freeish_pages(page_index_t *restart_page_ptr, long nbytes,
                      (page_table[first_page].write_protected == 0) &&
                      (page_table[first_page].dont_move == 0))
                 {
-                    bytes_found = PAGE_BYTES
+                    bytes_found = GENCGC_CARD_BYTES
                         - page_table[first_page].bytes_used;
                     if (bytes_found > most_bytes_found)
                         most_bytes_found = bytes_found;
@@ -1457,19 +1457,19 @@ copy_large_object(lispobj object, long nwords)
 
         next_page = first_page;
         remaining_bytes = nwords*N_WORD_BYTES;
-        while (remaining_bytes > PAGE_BYTES) {
+        while (remaining_bytes > GENCGC_CARD_BYTES) {
             gc_assert(page_table[next_page].gen == from_space);
             gc_assert(page_boxed_p(next_page));
             gc_assert(page_table[next_page].large_object);
             gc_assert(page_table[next_page].region_start_offset ==
                       npage_bytes(next_page-first_page));
-            gc_assert(page_table[next_page].bytes_used == PAGE_BYTES);
+            gc_assert(page_table[next_page].bytes_used == GENCGC_CARD_BYTES);
             /* Should have been unprotected by unprotect_oldspace(). */
             gc_assert(page_table[next_page].write_protected == 0);
 
             page_table[next_page].gen = new_space;
 
-            remaining_bytes -= PAGE_BYTES;
+            remaining_bytes -= GENCGC_CARD_BYTES;
             next_page++;
         }
 
@@ -1490,7 +1490,7 @@ copy_large_object(lispobj object, long nwords)
 
         /* Free any remaining pages; needs care. */
         next_page++;
-        while ((old_bytes_used == PAGE_BYTES) &&
+        while ((old_bytes_used == GENCGC_CARD_BYTES) &&
                (page_table[next_page].gen == from_space) &&
                page_boxed_p(next_page) &&
                page_table[next_page].large_object &&
@@ -1599,17 +1599,17 @@ copy_large_unboxed_object(lispobj object, long nwords)
 
         next_page = first_page;
         remaining_bytes = nwords*N_WORD_BYTES;
-        while (remaining_bytes > PAGE_BYTES) {
+        while (remaining_bytes > GENCGC_CARD_BYTES) {
             gc_assert(page_table[next_page].gen == from_space);
             gc_assert(page_allocated_no_region_p(next_page));
             gc_assert(page_table[next_page].large_object);
             gc_assert(page_table[next_page].region_start_offset ==
                       npage_bytes(next_page-first_page));
-            gc_assert(page_table[next_page].bytes_used == PAGE_BYTES);
+            gc_assert(page_table[next_page].bytes_used == GENCGC_CARD_BYTES);
 
             page_table[next_page].gen = new_space;
             page_table[next_page].allocated = UNBOXED_PAGE_FLAG;
-            remaining_bytes -= PAGE_BYTES;
+            remaining_bytes -= GENCGC_CARD_BYTES;
             next_page++;
         }
 
@@ -1630,7 +1630,7 @@ copy_large_unboxed_object(lispobj object, long nwords)
 
         /* Free any remaining pages; needs care. */
         next_page++;
-        while ((old_bytes_used == PAGE_BYTES) &&
+        while ((old_bytes_used == GENCGC_CARD_BYTES) &&
                (page_table[next_page].gen == from_space) &&
                page_allocated_no_region_p(next_page) &&
                page_table[next_page].large_object &&
@@ -2697,20 +2697,20 @@ maybe_adjust_large_object(lispobj *where)
 
     next_page = first_page;
     remaining_bytes = nwords*N_WORD_BYTES;
-    while (remaining_bytes > PAGE_BYTES) {
+    while (remaining_bytes > GENCGC_CARD_BYTES) {
         gc_assert(page_table[next_page].gen == from_space);
         gc_assert(page_allocated_no_region_p(next_page));
         gc_assert(page_table[next_page].large_object);
         gc_assert(page_table[next_page].region_start_offset ==
                   npage_bytes(next_page-first_page));
-        gc_assert(page_table[next_page].bytes_used == PAGE_BYTES);
+        gc_assert(page_table[next_page].bytes_used == GENCGC_CARD_BYTES);
 
         page_table[next_page].allocated = boxed;
 
         /* Shouldn't be write-protected at this stage. Essential that the
          * pages aren't. */
         gc_assert(!page_table[next_page].write_protected);
-        remaining_bytes -= PAGE_BYTES;
+        remaining_bytes -= GENCGC_CARD_BYTES;
         next_page++;
     }
 
@@ -2732,7 +2732,7 @@ maybe_adjust_large_object(lispobj *where)
 
     /* Free any remaining pages; needs care. */
     next_page++;
-    while ((old_bytes_used == PAGE_BYTES) &&
+    while ((old_bytes_used == GENCGC_CARD_BYTES) &&
            (page_table[next_page].gen == from_space) &&
            page_allocated_no_region_p(next_page) &&
            page_table[next_page].large_object &&
@@ -2800,7 +2800,7 @@ preserve_pointer(void *addr)
     /* quick check 2: Check the offset within the page.
      *
      */
-    if (((unsigned long)addr & (PAGE_BYTES - 1)) >
+    if (((unsigned long)addr & (GENCGC_CARD_BYTES - 1)) >
         page_table[addr_page_index].bytes_used)
         return;
 
@@ -2835,7 +2835,7 @@ preserve_pointer(void *addr)
     while (page_table[first_page].region_start_offset != 0) {
         --first_page;
         /* Do some checks. */
-        gc_assert(page_table[first_page].bytes_used == PAGE_BYTES);
+        gc_assert(page_table[first_page].bytes_used == GENCGC_CARD_BYTES);
         gc_assert(page_table[first_page].gen == from_space);
         gc_assert(page_table[first_page].allocated == region_allocation);
     }
@@ -2852,7 +2852,7 @@ preserve_pointer(void *addr)
         if (page_free_p(addr_page_index)
             || (page_table[addr_page_index].bytes_used == 0)
             /* Check the offset within the page. */
-            || (((unsigned long)addr & (PAGE_BYTES - 1))
+            || (((unsigned long)addr & (GENCGC_CARD_BYTES - 1))
                 > page_table[addr_page_index].bytes_used)) {
             FSHOW((stderr,
                    "weird? ignore ptr 0x%x to freed area of large object\n",
@@ -2886,8 +2886,8 @@ preserve_pointer(void *addr)
         gc_assert(!page_table[i].write_protected);
 
         /* Check whether this is the last page in this contiguous block.. */
-        if ((page_table[i].bytes_used < PAGE_BYTES)
-            /* ..or it is PAGE_BYTES and is the last in the block */
+        if ((page_table[i].bytes_used < GENCGC_CARD_BYTES)
+            /* ..or it is CARD_BYTES and is the last in the block */
             || page_free_p(i+1)
             || (page_table[i+1].bytes_used == 0) /* next page free */
             || (page_table[i+1].gen != from_space) /* diff. gen */
@@ -2962,7 +2962,7 @@ update_page_write_prot(page_index_t page)
         /*FSHOW((stderr, "/write-protecting page %d gen %d\n", page, gen));*/
 
         os_protect((void *)page_addr,
-                   PAGE_BYTES,
+                   GENCGC_CARD_BYTES,
                    OS_VM_PROT_READ|OS_VM_PROT_EXECUTE);
 
         /* Note the page as protected in the page tables. */
@@ -3031,8 +3031,8 @@ scavenge_generations(generation_index_t from, generation_index_t to)
             for (last_page = i; ; last_page++) {
                 write_protected =
                     write_protected && page_table[last_page].write_protected;
-                if ((page_table[last_page].bytes_used < PAGE_BYTES)
-                    /* Or it is PAGE_BYTES and is the last in the block */
+                if ((page_table[last_page].bytes_used < GENCGC_CARD_BYTES)
+                    /* Or it is CARD_BYTES and is the last in the block */
                     || (!page_boxed_p(last_page+1))
                     || (page_table[last_page+1].bytes_used == 0)
                     || (page_table[last_page+1].gen != generation)
@@ -3147,8 +3147,8 @@ scavenge_newspace_generation_one_scan(generation_index_t generation)
 
                 /* Check whether this is the last page in this
                  * contiguous block */
-                if ((page_table[last_page].bytes_used < PAGE_BYTES)
-                    /* Or it is PAGE_BYTES and is the last in the block */
+                if ((page_table[last_page].bytes_used < GENCGC_CARD_BYTES)
+                    /* Or it is CARD_BYTES and is the last in the block */
                     || (!page_boxed_p(last_page+1))
                     || (page_table[last_page+1].bytes_used == 0)
                     || (page_table[last_page+1].gen != generation)
@@ -3336,16 +3336,16 @@ unprotect_oldspace(void)
                 if (!region_addr) {
                     /* First region. */
                     region_addr = page_addr;
-                    region_bytes = PAGE_BYTES;
+                    region_bytes = GENCGC_CARD_BYTES;
                 } else if (region_addr + region_bytes == page_addr) {
                     /* Region continue. */
-                    region_bytes += PAGE_BYTES;
+                    region_bytes += GENCGC_CARD_BYTES;
                 } else {
                     /* Unprotect previous region. */
                     os_protect(region_addr, region_bytes, OS_VM_PROT_ALL);
                     /* First page in new region. */
                     region_addr = page_addr;
-                    region_bytes = PAGE_BYTES;
+                    region_bytes = GENCGC_CARD_BYTES;
                 }
             }
         }
@@ -3767,8 +3767,8 @@ verify_generation(generation_index_t generation)
             for (last_page = i; ;last_page++)
                 /* Check whether this is the last page in this contiguous
                  * block. */
-                if ((page_table[last_page].bytes_used < PAGE_BYTES)
-                    /* Or it is PAGE_BYTES and is the last in the block */
+                if ((page_table[last_page].bytes_used < GENCGC_CARD_BYTES)
+                    /* Or it is CARD_BYTES and is the last in the block */
                     || (page_table[last_page+1].allocated != region_allocation)
                     || (page_table[last_page+1].bytes_used == 0)
                     || (page_table[last_page+1].gen != generation)
@@ -3803,7 +3803,7 @@ verify_zero_fill(void)
                 }
             }
         } else {
-            long free_bytes = PAGE_BYTES - page_table[page].bytes_used;
+            long free_bytes = GENCGC_CARD_BYTES - page_table[page].bytes_used;
             if (free_bytes > 0) {
                 long *start_addr = (long *)((unsigned long)page_address(page)
                                           + page_table[page].bytes_used);
@@ -4470,11 +4470,11 @@ gc_free_heap(void)
             page_start = (void *)page_address(page);
 
             /* First, remove any write-protection. */
-            os_protect(page_start, PAGE_BYTES, OS_VM_PROT_ALL);
+            os_protect(page_start, GENCGC_CARD_BYTES, OS_VM_PROT_ALL);
             page_table[page].write_protected = 0;
 
-            os_invalidate(page_start,PAGE_BYTES);
-            addr = os_validate(page_start,PAGE_BYTES);
+            os_invalidate(page_start,GENCGC_CARD_BYTES);
+            addr = os_validate(page_start,GENCGC_CARD_BYTES);
             if (addr == NULL || addr != page_start) {
                 lose("gc_free_heap: page moved, 0x%08x ==> 0x%08x\n",
                      page_start,
@@ -4539,7 +4539,7 @@ gc_init(void)
 
     /* Compute the number of pages needed for the dynamic space.
      * Dynamic space size should be aligned on page size. */
-    page_table_pages = dynamic_space_size/PAGE_BYTES;
+    page_table_pages = dynamic_space_size/GENCGC_CARD_BYTES;
     gc_assert(dynamic_space_size == npage_bytes(page_table_pages));
 
     /* The page_table must be allocated using "calloc" to initialize
@@ -4643,7 +4643,7 @@ gencgc_pickup_dynamic(void)
           /* It is possible, though rare, for the saved page table
            * to contain free pages below alloc_ptr. */
           page_table[page].gen = gen;
-          page_table[page].bytes_used = PAGE_BYTES;
+          page_table[page].bytes_used = GENCGC_CARD_BYTES;
           page_table[page].large_object = 0;
           page_table[page].write_protected = 0;
           page_table[page].write_protected_cleared = 0;
@@ -4845,7 +4845,7 @@ gencgc_handle_wp_violation(void* fault_addr)
         gc_assert(ret == 0);
         if (page_table[page_index].write_protected) {
             /* Unprotect the page. */
-            os_protect(page_address(page_index), PAGE_BYTES, OS_VM_PROT_ALL);
+            os_protect(page_address(page_index), GENCGC_CARD_BYTES, OS_VM_PROT_ALL);
             page_table[page_index].write_protected_cleared = 1;
             page_table[page_index].write_protected = 0;
         } else {
@@ -4903,7 +4903,7 @@ zero_all_free_pages()
         if (page_free_p(i)) {
 #ifdef READ_PROTECT_FREE_PAGES
             os_protect(page_address(i),
-                       PAGE_BYTES,
+                       GENCGC_CARD_BYTES,
                        OS_VM_PROT_ALL);
 #endif
             zero_pages(i, i);
index e25527a..db72fa6 100644 (file)
@@ -365,7 +365,7 @@ os_protect(os_vm_address_t address, os_vm_size_t length, os_vm_prot_t prot)
             lose("An mprotect call failed with ENOMEM. This probably means that the maximum amount\n"
                  "of separate memory mappings was exceeded. To fix the problem, either increase\n"
                  "the maximum with e.g. 'echo 262144 > /proc/sys/vm/max_map_count' or recompile\n"
-                 "SBCL with a larger value for GENCGC-PAGE-BYTES in\n"
+                 "SBCL with a larger value for GENCGC-CARD-BYTES in\n"
                  "'src/compiler/target/backend-parms.lisp'.");
         } else {
             perror("mprotect");
index 4c1ea71..f127933 100644 (file)
@@ -482,6 +482,9 @@ main(int argc, char *argv[], char *envp[])
     /* Align down to multiple of page_table page size, and to the appropriate
      * stack alignment. */
     dynamic_space_size &= ~(PAGE_BYTES-1);
+#ifdef LISP_FEATURE_GENCGC
+    dynamic_space_size &= ~(GENCGC_CARD_BYTES-1);
+#endif
     thread_control_stack_size &= ~(CONTROL_STACK_ALIGNMENT_BYTES-1);
 
     /* Preserve the runtime options for possible future core saving */