diff options
author | jeff <jeff@FreeBSD.org> | 2002-06-19 23:49:57 +0000 |
---|---|---|
committer | jeff <jeff@FreeBSD.org> | 2002-06-19 23:49:57 +0000 |
commit | 4a3cef9fbf32011fd241cdb4112f8bc5b3b2afdb (patch) | |
tree | b75ddf7624e52fa2980784b620c9a98d14684b39 /sys | |
parent | 646109847c07435683a51fce2a08ee5355172758 (diff) | |
download | FreeBSD-src-4a3cef9fbf32011fd241cdb4112f8bc5b3b2afdb.zip FreeBSD-src-4a3cef9fbf32011fd241cdb4112f8bc5b3b2afdb.tar.gz |
- Move the computation of pflags out of the page allocation loop in
kmem_malloc()
- zero fill pages if PG_ZERO bit is not set after allocation in kmem_malloc()
Suggested by: alc, jake
Diffstat (limited to 'sys')
-rw-r--r-- | sys/vm/vm_kern.c | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/sys/vm/vm_kern.c b/sys/vm/vm_kern.c index 53464d8..4219181 100644 --- a/sys/vm/vm_kern.c +++ b/sys/vm/vm_kern.c @@ -312,6 +312,7 @@ kmem_malloc(map, size, flags) vm_map_entry_t entry; vm_offset_t addr; vm_page_t m; + int pflags; GIANT_REQUIRED; @@ -346,25 +347,26 @@ kmem_malloc(map, size, flags) vm_map_insert(map, kmem_object, offset, addr, addr + size, VM_PROT_ALL, VM_PROT_ALL, 0); - for (i = 0; i < size; i += PAGE_SIZE) { - int pflags; - /* - * Note: if M_NOWAIT specified alone, allocate from - * interrupt-safe queues only (just the free list). If - * M_USE_RESERVE is also specified, we can also - * allocate from the cache. Neither of the latter two - * flags may be specified from an interrupt since interrupts - * are not allowed to mess with the cache queue. - */ -retry: - if ((flags & (M_NOWAIT|M_USE_RESERVE)) == M_NOWAIT) - pflags = VM_ALLOC_INTERRUPT; - else - pflags = VM_ALLOC_SYSTEM; + /* + * Note: if M_NOWAIT specified alone, allocate from + * interrupt-safe queues only (just the free list). If + * M_USE_RESERVE is also specified, we can also + * allocate from the cache. Neither of the latter two + * flags may be specified from an interrupt since interrupts + * are not allowed to mess with the cache queue. + */ + + if ((flags & (M_NOWAIT|M_USE_RESERVE)) == M_NOWAIT) + pflags = VM_ALLOC_INTERRUPT; + else + pflags = VM_ALLOC_SYSTEM; + + if (flags & M_ZERO) + pflags |= VM_ALLOC_ZERO; - if (flags & M_ZERO) - pflags |= VM_ALLOC_ZERO; + for (i = 0; i < size; i += PAGE_SIZE) { +retry: m = vm_page_alloc(kmem_object, OFF_TO_IDX(offset + i), pflags); /* @@ -395,6 +397,8 @@ retry: vm_map_unlock(map); goto bad; } + if (flags & M_ZERO && (m->flags & PG_ZERO) == 0) + vm_page_zero_fill(m); vm_page_flag_clear(m, PG_ZERO); m->valid = VM_PAGE_BITS_ALL; } |