Add a waitok boolean argument to the VM system's pool page allocator backend.

This commit is contained in:
thorpej 1998-08-28 20:05:48 +00:00
parent 808c0cca58
commit 77d0a69569
6 changed files with 39 additions and 23 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: subr_pool.c,v 1.10 1998/08/13 02:10:58 eeh Exp $ */
/* $NetBSD: subr_pool.c,v 1.11 1998/08/28 20:05:48 thorpej Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@ -830,11 +830,12 @@ pool_page_alloc(sz, flags, mtype)
int flags;
int mtype;
{
boolean_t waitok = (flags & PR_WAITOK) ? TRUE : FALSE;
#if defined(UVM)
return ((void *)uvm_km_alloc_poolpage());
return ((void *)uvm_km_alloc_poolpage(waitok));
#else
return ((void *)kmem_alloc_poolpage());
return ((void *)kmem_alloc_poolpage(waitok));
#endif
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: uipc_mbuf.c,v 1.31 1998/08/13 19:15:33 thorpej Exp $ */
/* $NetBSD: uipc_mbuf.c,v 1.32 1998/08/28 20:05:48 thorpej Exp $ */
/*
* Copyright (c) 1982, 1986, 1988, 1991, 1993
@ -94,11 +94,13 @@ mclpool_alloc(sz, flags, mtype)
int flags;
int mtype;
{
boolean_t waitok = (flags & PR_WAITOK) ? TRUE : FALSE;
#if defined(UVM)
return ((void *)uvm_km_alloc_poolpage1(mb_map, uvmexp.mb_object));
return ((void *)uvm_km_alloc_poolpage1(mb_map, uvmexp.mb_object,
waitok));
#else
return ((void *)kmem_alloc_poolpage1(mb_map));
return ((void *)kmem_alloc_poolpage1(mb_map, waitok));
#endif
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: uvm_extern.h,v 1.19 1998/08/13 02:11:00 eeh Exp $ */
/* $NetBSD: uvm_extern.h,v 1.20 1998/08/28 20:05:49 thorpej Exp $ */
/*
* XXXCDC: "ROUGH DRAFT" QUALITY UVM PRE-RELEASE FILE!
@ -303,11 +303,11 @@ struct vm_map *uvm_km_suballoc __P((vm_map_t, vaddr_t *,
vaddr_t uvm_km_valloc __P((vm_map_t, vsize_t));
vaddr_t uvm_km_valloc_wait __P((vm_map_t, vsize_t));
vaddr_t uvm_km_alloc_poolpage1 __P((vm_map_t,
struct uvm_object *));
struct uvm_object *, boolean_t));
void uvm_km_free_poolpage1 __P((vm_map_t, vaddr_t));
#define uvm_km_alloc_poolpage() uvm_km_alloc_poolpage1(kmem_map, \
uvmexp.kmem_object)
#define uvm_km_alloc_poolpage(waitok) uvm_km_alloc_poolpage1(kmem_map, \
uvmexp.kmem_object, (waitok))
#define uvm_km_free_poolpage(addr) uvm_km_free_poolpage1(kmem_map, (addr))
/* uvm_map.c */

View File

@ -1,4 +1,4 @@
/* $NetBSD: uvm_km.c,v 1.14 1998/08/13 02:11:01 eeh Exp $ */
/* $NetBSD: uvm_km.c,v 1.15 1998/08/28 20:05:49 thorpej Exp $ */
/*
* XXXCDC: "ROUGH DRAFT" QUALITY UVM PRE-RELEASE FILE!
@ -1003,17 +1003,24 @@ uvm_km_valloc_wait(map, size)
/* ARGSUSED */
vaddr_t
uvm_km_alloc_poolpage1(map, obj)
uvm_km_alloc_poolpage1(map, obj, waitok)
vm_map_t map;
struct uvm_object *obj;
boolean_t waitok;
{
#if defined(PMAP_MAP_POOLPAGE)
struct vm_page *pg;
vaddr_t va;
again:
pg = uvm_pagealloc(NULL, 0, NULL);
if (pg == NULL)
return (0);
if (pg == NULL) {
if (waitok) {
uvm_wait("plpg");
goto again;
} else
return (0);
}
va = PMAP_MAP_POOLPAGE(VM_PAGE_TO_PHYS(pg));
if (va == 0)
uvm_pagefree(pg);
@ -1023,7 +1030,7 @@ uvm_km_alloc_poolpage1(map, obj)
int s;
s = splimp();
va = uvm_km_kmemalloc(map, obj, PAGE_SIZE, UVM_KMF_NOWAIT);
va = uvm_km_kmemalloc(map, obj, PAGE_SIZE, waitok ? 0 : UVM_KMF_NOWAIT);
splx(s);
return (va);
#endif /* PMAP_MAP_POOLPAGE */

View File

@ -1,4 +1,4 @@
/* $NetBSD: vm_extern.h,v 1.40 1998/08/13 02:11:05 eeh Exp $ */
/* $NetBSD: vm_extern.h,v 1.41 1998/08/28 20:05:48 thorpej Exp $ */
/*-
* Copyright (c) 1992, 1993
@ -86,10 +86,10 @@ void kmem_init __P((vaddr_t, vaddr_t));
vaddr_t kmem_malloc __P((vm_map_t, vsize_t, boolean_t));
vm_map_t kmem_suballoc __P((vm_map_t, vaddr_t *, vaddr_t *,
vsize_t, boolean_t));
vaddr_t kmem_alloc_poolpage1 __P((vm_map_t));
vaddr_t kmem_alloc_poolpage1 __P((vm_map_t, boolean_t));
void kmem_free_poolpage1 __P((vm_map_t, vaddr_t));
#define kmem_alloc_poolpage() kmem_alloc_poolpage1(kmem_map)
#define kmem_alloc_poolpage(waitok) kmem_alloc_poolpage1(kmem_map, (waitok))
#define kmem_free_poolpage(addr) kmem_free_poolpage1(kmem_map, (addr))
void loadav __P((struct loadavg *));

View File

@ -1,4 +1,4 @@
/* $NetBSD: vm_kern.c,v 1.29 1998/08/18 17:31:25 thorpej Exp $ */
/* $NetBSD: vm_kern.c,v 1.30 1998/08/28 20:05:48 thorpej Exp $ */
/*
* Copyright (c) 1991, 1993
@ -455,16 +455,22 @@ kmem_free_wakeup(map, addr, size)
*/
/* ARGSUSED */
vaddr_t
kmem_alloc_poolpage1(map)
kmem_alloc_poolpage1(map, waitok)
vm_map_t map;
boolean_t waitok;
{
#if defined(PMAP_MAP_POOLPAGE)
vm_page_t pg;
vaddr_t va;
pg = vm_page_alloc1();
if (pg == NULL)
return (0);
if (pg == NULL) {
if (waitok) {
vm_wait("plpg");
goto again;
} else
return (0);
}
va = PMAP_MAP_POOLPAGE(VM_PAGE_TO_PHYS(pg));
if (va == 0)
vm_page_free1(pg);
@ -474,7 +480,7 @@ kmem_alloc_poolpage1(map)
int s;
s = splimp();
va = kmem_malloc(map, PAGE_SIZE, 0);
va = kmem_malloc(map, PAGE_SIZE, waitok);
splx(s);
return (va);
#endif /* PMAP_MAP_POOLPAGE */