summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjeff <jeff@FreeBSD.org>2003-01-21 05:44:52 +0000
committerjeff <jeff@FreeBSD.org>2003-01-21 05:44:52 +0000
commit18309dfabebe791e296990abe7d558eba82724a8 (patch)
tree0787f6c8182982ce13ac9a14af60a5cbecd9e481
parenta56a74e4b68be38fa9402c627c60820dce36a399 (diff)
downloadFreeBSD-src-18309dfabebe791e296990abe7d558eba82724a8.zip
FreeBSD-src-18309dfabebe791e296990abe7d558eba82724a8.tar.gz
- Add a VM_WAIT in the appropriate cases where vm_page_alloc() fails and flags
indicate that uma_small_alloc should not. This code should be refactored so that there is not so much cross arch duplication. Reviewed by: jake Spotted by: tmm Tested on: alpha, sparc64 Pointy hat to: jeff and everyone who cut and pasted the bad code. :-)
-rw-r--r--sys/alpha/alpha/pmap.c21
-rw-r--r--sys/ia64/ia64/pmap.c22
-rw-r--r--sys/sparc64/sparc64/vm_machdep.c38
3 files changed, 50 insertions, 31 deletions
diff --git a/sys/alpha/alpha/pmap.c b/sys/alpha/alpha/pmap.c
index 1a9082f..73406fc 100644
--- a/sys/alpha/alpha/pmap.c
+++ b/sys/alpha/alpha/pmap.c
@@ -582,16 +582,21 @@ uma_small_alloc(uma_zone_t zone, int bytes, u_int8_t *flags, int wait)
if (wait & M_ZERO)
pflags |= VM_ALLOC_ZERO;
- m = vm_page_alloc(NULL, color++, pflags | VM_ALLOC_NOOBJ);
-
- if (m) {
- va = (void *)ALPHA_PHYS_TO_K0SEG(m->phys_addr);
- if ((m->flags & PG_ZERO) == 0)
- bzero(va, PAGE_SIZE);
- return (va);
+ for (;;) {
+ m = vm_page_alloc(NULL, color++, pflags | VM_ALLOC_NOOBJ);
+ if (m == NULL) {
+ if (wait & M_NOWAIT)
+ return (NULL);
+ else
+ VM_WAIT;
+ } else
+ break;
}
- return (NULL);
+ va = (void *)ALPHA_PHYS_TO_K0SEG(m->phys_addr);
+ if ((m->flags & PG_ZERO) == 0)
+ bzero(va, PAGE_SIZE);
+ return (va);
}
void
diff --git a/sys/ia64/ia64/pmap.c b/sys/ia64/ia64/pmap.c
index 1ffef00..13a42b6 100644
--- a/sys/ia64/ia64/pmap.c
+++ b/sys/ia64/ia64/pmap.c
@@ -488,14 +488,22 @@ uma_small_alloc(uma_zone_t zone, int bytes, u_int8_t *flags, int wait)
pflags = VM_ALLOC_SYSTEM;
if (wait & M_ZERO)
pflags |= VM_ALLOC_ZERO;
- m = vm_page_alloc(NULL, color++, pflags | VM_ALLOC_NOOBJ);
- if (m) {
- va = (void *)IA64_PHYS_TO_RR7(VM_PAGE_TO_PHYS(m));
- if ((m->flags & PG_ZERO) == 0)
- bzero(va, PAGE_SIZE);
- return (va);
+
+ for (;;) {
+ m = vm_page_alloc(NULL, color++, pflags | VM_ALLOC_NOOBJ);
+ if (m == NULL) {
+ if (wait & M_NOWAIT)
+ return (NULL);
+ else
+ VM_WAIT;
+ } else
+ break;
}
- return (NULL);
+
+ va = (void *)IA64_PHYS_TO_RR7(VM_PAGE_TO_PHYS(m));
+ if ((m->flags & PG_ZERO) == 0)
+ bzero(va, PAGE_SIZE);
+ return (va);
}
void
diff --git a/sys/sparc64/sparc64/vm_machdep.c b/sys/sparc64/sparc64/vm_machdep.c
index 56f692a..b018b93 100644
--- a/sys/sparc64/sparc64/vm_machdep.c
+++ b/sys/sparc64/sparc64/vm_machdep.c
@@ -64,6 +64,7 @@
#include <vm/pmap.h>
#include <vm/vm_map.h>
#include <vm/vm_page.h>
+#include <vm/vm_pageout.h>
#include <vm/vm_param.h>
#include <vm/uma.h>
#include <vm/uma_int.h>
@@ -330,24 +331,29 @@ uma_small_alloc(uma_zone_t zone, int bytes, u_int8_t *flags, int wait)
if (wait & M_ZERO)
pflags |= VM_ALLOC_ZERO;
- m = vm_page_alloc(NULL, color++, pflags | VM_ALLOC_NOOBJ);
-
- if (m) {
- pa = VM_PAGE_TO_PHYS(m);
- if (m->md.color != DCACHE_COLOR(pa)) {
- KASSERT(m->md.colors[0] == 0 && m->md.colors[1] == 0,
- ("uma_small_alloc: free page still has mappings!"));
- PMAP_STATS_INC(uma_nsmall_alloc_oc);
- m->md.color = DCACHE_COLOR(pa);
- dcache_page_inval(pa);
- }
- va = (void *)TLB_PHYS_TO_DIRECT(pa);
- if ((m->flags & PG_ZERO) == 0)
- bzero(va, PAGE_SIZE);
- return (va);
+ for (;;) {
+ m = vm_page_alloc(NULL, color++, pflags | VM_ALLOC_NOOBJ);
+ if (m == NULL) {
+ if (wait & M_NOWAIT)
+ return (NULL);
+ else
+ VM_WAIT;
+ } else
+ break;
}
- return (NULL);
+ pa = VM_PAGE_TO_PHYS(m);
+ if (m->md.color != DCACHE_COLOR(pa)) {
+ KASSERT(m->md.colors[0] == 0 && m->md.colors[1] == 0,
+ ("uma_small_alloc: free page still has mappings!"));
+ PMAP_STATS_INC(uma_nsmall_alloc_oc);
+ m->md.color = DCACHE_COLOR(pa);
+ dcache_page_inval(pa);
+ }
+ va = (void *)TLB_PHYS_TO_DIRECT(pa);
+ if ((m->flags & PG_ZERO) == 0)
+ bzero(va, PAGE_SIZE);
+ return (va);
}
void
OpenPOWER on IntegriCloud