summaryrefslogtreecommitdiffstats
path: root/sys/powerpc/aim/slb.c
diff options
context:
space:
mode:
authoralc <alc@FreeBSD.org>2011-11-16 16:46:09 +0000
committeralc <alc@FreeBSD.org>2011-11-16 16:46:09 +0000
commit3692d0165926e89d0ad0d746888b510d4e49348c (patch)
tree272387d8a035403f23822efe5dfd1df09f424088 /sys/powerpc/aim/slb.c
parent1c37e71ee838a9da8d383e6e57d29d25820b52d5 (diff)
downloadFreeBSD-src-3692d0165926e89d0ad0d746888b510d4e49348c.zip
FreeBSD-src-3692d0165926e89d0ad0d746888b510d4e49348c.tar.gz
Refactor the code that performs physically contiguous memory allocation,
yielding a new public interface, vm_page_alloc_contig(). This new function addresses some of the limitations of the current interfaces, contigmalloc() and kmem_alloc_contig(). For example, the physically contiguous memory that is allocated with those interfaces can only be allocated to the kernel vm object and must be mapped into the kernel virtual address space. It also provides functionality that vm_phys_alloc_contig() doesn't, such as wiring the returned pages. Moreover, unlike that function, it respects the low water marks on the paging queues and wakes up the page daemon when necessary. That said, at present, this new function can't be applied to all types of vm objects. However, that restriction will be eliminated in the coming weeks. From a design standpoint, this change also addresses an inconsistency between vm_phys_alloc_contig() and the other vm_phys_alloc*() functions. Specifically, vm_phys_alloc_contig() manipulated vm_page fields that other functions in vm/vm_phys.c didn't. Moreover, vm_phys_alloc_contig() knew about vnodes and reservations. Now, vm_page_alloc_contig() is responsible for these things. Reviewed by: kib Discussed with: jhb
Diffstat (limited to 'sys/powerpc/aim/slb.c')
-rw-r--r--sys/powerpc/aim/slb.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/sys/powerpc/aim/slb.c b/sys/powerpc/aim/slb.c
index df493b4..1a5ce65 100644
--- a/sys/powerpc/aim/slb.c
+++ b/sys/powerpc/aim/slb.c
@@ -40,7 +40,6 @@
#include <vm/vm_map.h>
#include <vm/vm_page.h>
#include <vm/vm_pageout.h>
-#include <vm/vm_phys.h>
#include <machine/md_var.h>
#include <machine/platform.h>
@@ -488,15 +487,22 @@ slb_uma_real_alloc(uma_zone_t zone, int bytes, u_int8_t *flags, int wait)
static vm_offset_t realmax = 0;
void *va;
vm_page_t m;
+ int pflags;
if (realmax == 0)
realmax = platform_real_maxaddr();
*flags = UMA_SLAB_PRIV;
+ if ((wait & (M_NOWAIT | M_USE_RESERVE)) == M_NOWAIT)
+ pflags = VM_ALLOC_INTERRUPT | VM_ALLOC_NOOBJ | VM_ALLOC_WIRED;
+ else
+ pflags = VM_ALLOC_SYSTEM | VM_ALLOC_NOOBJ | VM_ALLOC_WIRED;
+ if (wait & M_ZERO)
+ pflags |= VM_ALLOC_ZERO;
for (;;) {
- m = vm_phys_alloc_contig(1, 0, realmax, PAGE_SIZE,
- PAGE_SIZE);
+ m = vm_page_alloc_contig(NULL, 0, pflags, 1, 0, realmax,
+ PAGE_SIZE, PAGE_SIZE, VM_MEMATTR_DEFAULT);
if (m == NULL) {
if (wait & M_NOWAIT)
return (NULL);
@@ -513,10 +519,6 @@ slb_uma_real_alloc(uma_zone_t zone, int bytes, u_int8_t *flags, int wait)
if ((wait & M_ZERO) && (m->flags & PG_ZERO) == 0)
bzero(va, PAGE_SIZE);
- /* vm_phys_alloc_contig does not track wiring */
- atomic_add_int(&cnt.v_wire_count, 1);
- m->wire_count = 1;
-
return (va);
}
OpenPOWER on IntegriCloud