diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c index bcabfb68f826..20715e4abc01 100644 --- a/sys/vm/vm_page.c +++ b/sys/vm/vm_page.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_page.c,v 1.42 1998/03/01 02:24:01 fvdl Exp $ */ +/* $NetBSD: vm_page.c,v 1.43 1998/03/12 06:25:52 thorpej Exp $ */ #define VM_PAGE_ALLOC_MEMORY_STATS @@ -1401,6 +1401,70 @@ vm_page_free(mem) { vm_page_remove(mem); + vm_page_free1(mem); +} + +/* + * vm_page_alloc1: + * + * Allocate and return a memory cell with no associated object. + */ +vm_page_t +vm_page_alloc1() +{ + vm_page_t mem; + int spl; + + spl = splimp(); + simple_lock(&vm_page_queue_free_lock); + if (vm_page_queue_free.tqh_first == NULL) { + simple_unlock(&vm_page_queue_free_lock); + splx(spl); + return (NULL); + } + + mem = vm_page_queue_free.tqh_first; + TAILQ_REMOVE(&vm_page_queue_free, mem, pageq); + + cnt.v_free_count--; + simple_unlock(&vm_page_queue_free_lock); + splx(spl); + + mem->flags = PG_BUSY | PG_CLEAN | PG_FAKE; + mem->wire_count = 0; + + /* + * Decide if we should poke the pageout daemon. + * We do this if the free count is less than the low + * water mark, or if the free count is less than the high + * water mark (but above the low water mark) and the inactive + * count is less than its target. + * + * We don't have the counts locked ... if they change a little, + * it doesn't really matter. + */ + + if (cnt.v_free_count < cnt.v_free_min || + (cnt.v_free_count < cnt.v_free_target && + cnt.v_inactive_count < cnt.v_inactive_target)) + thread_wakeup((void *)&vm_pages_needed); + + return (mem); +} + +/* + * vm_page_free1: + * + * Returns the given page to the free list. + * + * The page must already be disassociated with + * any objects. + */ +void +vm_page_free1(mem) + vm_page_t mem; +{ + if (mem->flags & PG_ACTIVE) { TAILQ_REMOVE(&vm_page_queue_active, mem, pageq); mem->flags &= ~PG_ACTIVE; diff --git a/sys/vm/vm_page.h b/sys/vm/vm_page.h index 96cc84e463e9..57ad6512492a 100644 --- a/sys/vm/vm_page.h +++ b/sys/vm/vm_page.h @@ -1,4 +1,4 @@ -/* $NetBSD: vm_page.h,v 1.25 1998/03/01 02:24:02 fvdl Exp $ */ +/* $NetBSD: vm_page.h,v 1.26 1998/03/12 06:25:53 thorpej Exp $ */ /* * Copyright (c) 1991, 1993 @@ -330,6 +330,7 @@ static int vm_physseg_find __P((vm_offset_t, int *)); void vm_page_activate __P((vm_page_t)); vm_page_t vm_page_alloc __P((vm_object_t, vm_offset_t)); +vm_page_t vm_page_alloc1 __P((void)); int vm_page_alloc_memory __P((vm_size_t size, vm_offset_t low, vm_offset_t high, vm_offset_t alignment, vm_offset_t boundary, struct pglist *rlist, int nsegs, int waitok)); @@ -340,6 +341,7 @@ void vm_page_bootstrap __P((vm_offset_t *, vm_offset_t *)); void vm_page_copy __P((vm_page_t, vm_page_t)); void vm_page_deactivate __P((vm_page_t)); void vm_page_free __P((vm_page_t)); +void vm_page_free1 __P((vm_page_t)); void vm_page_insert __P((vm_page_t, vm_object_t, vm_offset_t)); vm_page_t vm_page_lookup __P((vm_object_t, vm_offset_t)); #if defined(MACHINE_NEW_NONCONTIG)