From abd498aa7127b03d6c0593cdb8f8308dd65758c6 Mon Sep 17 00:00:00 2001 From: Bruce M Simpson Date: Mon, 11 Aug 2003 07:14:08 +0000 Subject: Add the mlockall() and munlockall() system calls. - All those diffs to syscalls.master for each architecture *are* necessary. This needed clarification; the stub code generation for mlockall() was disabled, which would prevent applications from linking to this API (suggested by mux) - Giant has been quoshed. It is no longer held by the code, as the required locking has been pushed down within vm_map.c. - Callers must specify VM_MAP_WIRE_HOLESOK or VM_MAP_WIRE_NOHOLES to express their intention explicitly. - Inspected at the vmstat, top and vm pager sysctl stats level. Paging-in activity is occurring correctly, using a test harness. - The RES size for a process may appear to be greater than its SIZE. This is believed to be due to mappings of the same shared library page being wired twice. Further exploration is needed. - Believed to back out of allocations and locks correctly (tested with WITNESS, MUTEX_PROFILING, INVARIANTS and DIAGNOSTIC). PR: kern/43426, standards/54223 Reviewed by: jake, alc Approved by: jake (mentor) MFC after: 2 weeks --- sys/vm/vm_unix.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'sys/vm/vm_unix.c') diff --git a/sys/vm/vm_unix.c b/sys/vm/vm_unix.c index b57958e05dd8..877609f1eb77 100644 --- a/sys/vm/vm_unix.c +++ b/sys/vm/vm_unix.c @@ -79,7 +79,9 @@ obreak(td, uap) vm_offset_t new, old, base; int rv; int error = 0; + boolean_t do_map_wirefuture; + do_map_wirefuture = FALSE; new = round_page((vm_offset_t)uap->nsize); vm_map_lock(&vm->vm_map); @@ -121,6 +123,20 @@ obreak(td, uap) goto done; } vm->vm_dsize += btoc(new - old); + /* + * Handle the MAP_WIREFUTURE case for legacy applications, + * by marking the newly mapped range of pages as wired. + * We are not required to perform a corresponding + * vm_map_unwire() before vm_map_delete() below, as + * it will forcibly unwire the pages in the range. + * + * XXX If the pages cannot be wired, no error is returned. + */ + if ((vm->vm_map.flags & MAP_WIREFUTURE) == MAP_WIREFUTURE) { + if (bootverbose) + printf("obreak: MAP_WIREFUTURE set\n"); + do_map_wirefuture = TRUE; + } } else if (new < old) { rv = vm_map_delete(&vm->vm_map, new, old); if (rv != KERN_SUCCESS) { @@ -131,6 +147,11 @@ obreak(td, uap) } done: vm_map_unlock(&vm->vm_map); + + if (do_map_wirefuture) + (void) vm_map_wire(&vm->vm_map, old, new, + VM_MAP_WIRE_USER|VM_MAP_WIRE_NOHOLES); + return (error); } -- cgit v1.2.3