From a8a79584f77a1ca0b1f651c27d219678e44c3f4d Mon Sep 17 00:00:00 2001 From: Thiemo Seufer Date: Wed, 5 Sep 2007 01:20:45 +0000 Subject: [PATCH] 1.0.9.30: Make SBCL work on MIPS/Linux with larger page sizes. - Supports now up to 64k pages, aas defined by the o32 ABI. - Tested on a bcm1480 with a kernel for 16k pages. - The pagesize handling in SBCL is very broken for most other architectures / OSes. --- contrib/sb-sprof/sb-sprof.lisp | 2 +- src/compiler/mips/backend-parms.lisp | 9 +++++---- src/compiler/ppc/backend-parms.lisp | 2 +- src/runtime/gc.h | 2 +- src/runtime/runtime.c | 2 +- src/runtime/thread.c | 13 ++++++++++--- version.lisp-expr | 2 +- 7 files changed, 20 insertions(+), 12 deletions(-) diff --git a/contrib/sb-sprof/sb-sprof.lisp b/contrib/sb-sprof/sb-sprof.lisp index b68c78b..a6e461c 100644 --- a/contrib/sb-sprof/sb-sprof.lisp +++ b/contrib/sb-sprof/sb-sprof.lisp @@ -345,7 +345,7 @@ profiling") (defvar *alloc-region-size* #-gencgc - 4096 + (get-page-size) ;; This hardcoded 2 matches the one in gc_find_freeish_pages. It's not ;; really worth genesifying. #+gencgc diff --git a/src/compiler/mips/backend-parms.lisp b/src/compiler/mips/backend-parms.lisp index 1df277b..e1c1a1d 100644 --- a/src/compiler/mips/backend-parms.lisp +++ b/src/compiler/mips/backend-parms.lisp @@ -1,11 +1,12 @@ (in-package "SB!VM") -;;; FIXME: Do I need a different one for little-endian? :spim, -;;; perhaps? (def!constant +backend-fasl-file-implementation+ :mips) (setf *backend-register-save-penalty* 3) (setf *backend-byte-order* #!+little-endian :little-endian #!-little-endian :big-endian) -;;; FIXME: Check this. Where is it used? -(setf *backend-page-size* 4096) + +(progn ;eval-when (:compile-toplevel :load-toplevel :execute) + ;; The o32 ABI specifies 4k-64k as page size. We have to pick the + ;; maximum since mprotect() works only with page granularity. + (setf *backend-page-size* 65536)) diff --git a/src/compiler/ppc/backend-parms.lisp b/src/compiler/ppc/backend-parms.lisp index ebaf637..d15cc53 100644 --- a/src/compiler/ppc/backend-parms.lisp +++ b/src/compiler/ppc/backend-parms.lisp @@ -5,7 +5,7 @@ (setf *backend-byte-order* :big-endian) (eval-when (:compile-toplevel :load-toplevel :execute) - ;; On Linux, the ABI specifies the page size to be 4k-65k, use the + ;; On Linux, the ABI specifies the page size to be 4k-64k, use the ;; maximum of that range. FIXME: it'd be great if somebody would ;; find out whether using exact multiples of the page size actually ;; matters in the few places where that's done, or whether we could diff --git a/src/runtime/gc.h b/src/runtime/gc.h index 224ae6c..a619175 100644 --- a/src/runtime/gc.h +++ b/src/runtime/gc.h @@ -21,7 +21,7 @@ #ifdef LISP_FEATURE_GENCGC #define PAGE_BYTES GENCGC_PAGE_SIZE #else -#define PAGE_BYTES 0x1000 +#define PAGE_BYTES BACKEND_PAGE_SIZE #endif typedef signed long page_index_t; diff --git a/src/runtime/runtime.c b/src/runtime/runtime.c index ab61951..5db1453 100644 --- a/src/runtime/runtime.c +++ b/src/runtime/runtime.c @@ -332,7 +332,7 @@ main(int argc, char *argv[], char *envp[]) } /* Align down to multiple of page_table page size */ - dynamic_space_size = (dynamic_space_size/PAGE_BYTES) * PAGE_BYTES; + dynamic_space_size &= ~(PAGE_BYTES - 1); /* KLUDGE: os_vm_page_size is set by os_init(), and on some * systems (e.g. Alpha) arch_init() needs need os_vm_page_size, so diff --git a/src/runtime/thread.c b/src/runtime/thread.c index 0bc37a2..e61ecbe 100644 --- a/src/runtime/thread.c +++ b/src/runtime/thread.c @@ -373,12 +373,19 @@ create_thread_struct(lispobj initial_function) { /* Give a chance for cleanup threads to run. */ sched_yield(); #endif - /* may as well allocate all the spaces at once: it saves us from + /* May as well allocate all the spaces at once: it saves us from * having to decide what to do if only some of the allocations - * succeed */ - spaces=os_validate(0, THREAD_STRUCT_SIZE); + * succeed. SPACES must be page-aligned, since the GC expects the + * control stack to start at a page boundary. We can't rely on the + * alignment passed from os_validate, since that might assume the + * current (e.g. 4k) pagesize, while we calculate with the biggest + * (e.g. 64k) pagesize allowed by the ABI. */ + spaces=os_validate(0, THREAD_STRUCT_SIZE + BACKEND_PAGE_SIZE); if(!spaces) return NULL; + spaces = (void *)((((unsigned long)(char *)spaces) + + BACKEND_PAGE_SIZE - 1) + & ~(BACKEND_PAGE_SIZE - 1)); per_thread=(union per_thread_data *) (spaces+ THREAD_CONTROL_STACK_SIZE+ diff --git a/version.lisp-expr b/version.lisp-expr index 7c53621..510933c 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -17,4 +17,4 @@ ;;; checkins which aren't released. (And occasionally for internal ;;; versions, especially for internal versions off the main CVS ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".) -"1.0.9.29" +"1.0.9.30" -- 1.7.10.4