diff --git a/sys/alpha/alpha/pmap.c b/sys/alpha/alpha/pmap.c index 1a9082fb3cfc..73406fc3f2c9 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 1ffef00e9b26..13a42b66aa54 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 56f692a204ad..b018b93c0532 100644 --- a/sys/sparc64/sparc64/vm_machdep.c +++ b/sys/sparc64/sparc64/vm_machdep.c @@ -64,6 +64,7 @@ #include #include #include +#include #include #include #include @@ -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