From 274a7d4800a1b95cb76e6b7dd3d70c40ca93e1ee Mon Sep 17 00:00:00 2001 From: dtc <dtc> Date: Wed, 19 Jan 2000 18:15:15 +0000 Subject: [PATCH] Have os_validate pass the MAP_NORESERVE flag to mmap. This allows users with low swap plus memory to run without enabling the non-standard and perhaps undesirable overcommit_memory option. With this change the current scheme of splitting mmap operations into smaller pieces to bypass the kernel checks is no longer necessary, and this code has been cleaned up. --- lisp/Linux-os.c | 55 ++++++++++--------------------------------------- 1 file changed, 11 insertions(+), 44 deletions(-) diff --git a/lisp/Linux-os.c b/lisp/Linux-os.c index f56f47a76..8c4ec3865 100644 --- a/lisp/Linux-os.c +++ b/lisp/Linux-os.c @@ -15,7 +15,7 @@ * GENCGC support by Douglas Crosher, 1996, 1997. * Alpha support by Julian Dolby, 1999. * - * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/Linux-os.c,v 1.9 1999/11/29 17:04:07 dtc Exp $ + * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/Linux-os.c,v 1.10 2000/01/19 18:15:15 dtc Exp $ * */ @@ -118,27 +118,9 @@ void os_set_context(void) { } -int do_mmap(os_vm_address_t *addr, os_vm_size_t len, int flags) -{ - /* We _must_ have the memory where we want it... */ - os_vm_address_t old_addr = *addr; - - *addr = mmap(*addr, len, OS_VM_PROT_ALL, flags, -1, 0); - if ((old_addr != NULL && *addr != old_addr) || - *addr == (os_vm_address_t) -1) - { - fprintf(stderr, "Error in allocating memory, do you have more then 16MB of memory+swap?\n"); - perror("mmap"); - return 1; - } - return 0; -} - os_vm_address_t os_validate(os_vm_address_t addr, os_vm_size_t len) { - int flags = MAP_PRIVATE | MAP_ANONYMOUS; - os_vm_address_t oa = addr; - os_vm_size_t olen = len; + int flags = MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE; if (addr) flags |= MAP_FIXED; @@ -146,33 +128,18 @@ os_vm_address_t os_validate(os_vm_address_t addr, os_vm_size_t len) flags |= MAP_VARIABLE; DPRINTF(0, (stderr, "os_validate %x %d => ", addr, len)); - if (addr) - { - do { - if (len <= 0x1000000 ) - { - if (do_mmap(&addr, len, flags)) - return NULL; - len = 0; - } - else - { - len = len - 0x1000000; - if (do_mmap(&addr, 0x1000000, flags)) - return NULL; - addr += 0x1000000; - } - } - while (len > 0); - } - else + + addr = mmap(addr, len, OS_VM_PROT_ALL, flags, -1, 0); + + if(addr == (os_vm_address_t) -1) { - if (do_mmap(&addr, len, flags)) - return NULL; - return addr; + perror("mmap"); + return NULL; } + DPRINTF(0, (stderr, "%x\n", addr)); - return oa; + + return addr; } void os_invalidate(os_vm_address_t addr, os_vm_size_t len) -- GitLab