mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-14 10:09:48 +00:00
- 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. :-)
This commit is contained in:
parent
4fd3f3c599
commit
04de47b0d3
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=109615
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user