vm_kern.c (238561) | vm_kern.c (243040) |
---|---|
1/*- 2 * Copyright (c) 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * The Mach Operating System project at Carnegie-Mellon University. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 49 unchanged lines hidden (view full) --- 58 * rights to redistribute these changes. 59 */ 60 61/* 62 * Kernel memory management. 63 */ 64 65#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * The Mach Operating System project at Carnegie-Mellon University. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 49 unchanged lines hidden (view full) --- 58 * rights to redistribute these changes. 59 */ 60 61/* 62 * Kernel memory management. 63 */ 64 65#include <sys/cdefs.h> |
66__FBSDID("$FreeBSD: head/sys/vm/vm_kern.c 238561 2012-07-18 05:21:34Z alc $"); | 66__FBSDID("$FreeBSD: head/sys/vm/vm_kern.c 243040 2012-11-14 20:01:40Z kib $"); |
67 68#include <sys/param.h> 69#include <sys/systm.h> 70#include <sys/kernel.h> /* for ticks and hz */ 71#include <sys/eventhandler.h> 72#include <sys/lock.h> 73#include <sys/mutex.h> 74#include <sys/proc.h> --- 142 unchanged lines hidden (view full) --- 217 if (vm_map_findspace(map, vm_map_min(map), size, &addr)) { 218 vm_map_unlock(map); 219 return (0); 220 } 221 offset = addr - VM_MIN_KERNEL_ADDRESS; 222 vm_object_reference(object); 223 vm_map_insert(map, object, offset, addr, addr + size, VM_PROT_ALL, 224 VM_PROT_ALL, 0); | 67 68#include <sys/param.h> 69#include <sys/systm.h> 70#include <sys/kernel.h> /* for ticks and hz */ 71#include <sys/eventhandler.h> 72#include <sys/lock.h> 73#include <sys/mutex.h> 74#include <sys/proc.h> --- 142 unchanged lines hidden (view full) --- 217 if (vm_map_findspace(map, vm_map_min(map), size, &addr)) { 218 vm_map_unlock(map); 219 return (0); 220 } 221 offset = addr - VM_MIN_KERNEL_ADDRESS; 222 vm_object_reference(object); 223 vm_map_insert(map, object, offset, addr, addr + size, VM_PROT_ALL, 224 VM_PROT_ALL, 0); |
225 if ((flags & (M_NOWAIT | M_USE_RESERVE)) == M_NOWAIT) 226 pflags = VM_ALLOC_INTERRUPT | VM_ALLOC_NOBUSY; 227 else 228 pflags = VM_ALLOC_SYSTEM | VM_ALLOC_NOBUSY; 229 if (flags & M_ZERO) 230 pflags |= VM_ALLOC_ZERO; | 225 pflags = malloc2vm_flags(flags) | VM_ALLOC_NOBUSY; |
231 VM_OBJECT_LOCK(object); 232 end_offset = offset + size; 233 for (; offset < end_offset; offset += PAGE_SIZE) { 234 tries = 0; 235retry: 236 m = vm_page_alloc_contig(object, OFF_TO_IDX(offset), pflags, 1, 237 low, high, PAGE_SIZE, 0, memattr); 238 if (m == NULL) { --- 52 unchanged lines hidden (view full) --- 291 if (vm_map_findspace(map, vm_map_min(map), size, &addr)) { 292 vm_map_unlock(map); 293 return (0); 294 } 295 offset = addr - VM_MIN_KERNEL_ADDRESS; 296 vm_object_reference(object); 297 vm_map_insert(map, object, offset, addr, addr + size, VM_PROT_ALL, 298 VM_PROT_ALL, 0); | 226 VM_OBJECT_LOCK(object); 227 end_offset = offset + size; 228 for (; offset < end_offset; offset += PAGE_SIZE) { 229 tries = 0; 230retry: 231 m = vm_page_alloc_contig(object, OFF_TO_IDX(offset), pflags, 1, 232 low, high, PAGE_SIZE, 0, memattr); 233 if (m == NULL) { --- 52 unchanged lines hidden (view full) --- 286 if (vm_map_findspace(map, vm_map_min(map), size, &addr)) { 287 vm_map_unlock(map); 288 return (0); 289 } 290 offset = addr - VM_MIN_KERNEL_ADDRESS; 291 vm_object_reference(object); 292 vm_map_insert(map, object, offset, addr, addr + size, VM_PROT_ALL, 293 VM_PROT_ALL, 0); |
299 if ((flags & (M_NOWAIT | M_USE_RESERVE)) == M_NOWAIT) 300 pflags = VM_ALLOC_INTERRUPT | VM_ALLOC_NOBUSY; 301 else 302 pflags = VM_ALLOC_SYSTEM | VM_ALLOC_NOBUSY; 303 if (flags & M_ZERO) 304 pflags |= VM_ALLOC_ZERO; 305 if (flags & M_NODUMP) 306 pflags |= VM_ALLOC_NODUMP; | 294 pflags = malloc2vm_flags(flags) | VM_ALLOC_NOBUSY; |
307 VM_OBJECT_LOCK(object); 308 tries = 0; 309retry: 310 m = vm_page_alloc_contig(object, OFF_TO_IDX(offset), pflags, 311 atop(size), low, high, alignment, boundary, memattr); 312 if (m == NULL) { 313 VM_OBJECT_UNLOCK(object); 314 if (tries < ((flags & M_NOWAIT) != 0 ? 1 : 3)) { --- 167 unchanged lines hidden (view full) --- 482 * entry exactly corresponding to this address range and it 483 * will have wired_count == 0. 484 */ 485 found = vm_map_lookup_entry(map, addr, &entry); 486 KASSERT(found && entry->start == addr && entry->end == addr + size && 487 entry->wired_count == 0 && (entry->eflags & MAP_ENTRY_IN_TRANSITION) 488 == 0, ("kmem_back: entry not found or misaligned")); 489 | 295 VM_OBJECT_LOCK(object); 296 tries = 0; 297retry: 298 m = vm_page_alloc_contig(object, OFF_TO_IDX(offset), pflags, 299 atop(size), low, high, alignment, boundary, memattr); 300 if (m == NULL) { 301 VM_OBJECT_UNLOCK(object); 302 if (tries < ((flags & M_NOWAIT) != 0 ? 1 : 3)) { --- 167 unchanged lines hidden (view full) --- 470 * entry exactly corresponding to this address range and it 471 * will have wired_count == 0. 472 */ 473 found = vm_map_lookup_entry(map, addr, &entry); 474 KASSERT(found && entry->start == addr && entry->end == addr + size && 475 entry->wired_count == 0 && (entry->eflags & MAP_ENTRY_IN_TRANSITION) 476 == 0, ("kmem_back: entry not found or misaligned")); 477 |
490 if ((flags & (M_NOWAIT|M_USE_RESERVE)) == M_NOWAIT) 491 pflags = VM_ALLOC_INTERRUPT | VM_ALLOC_WIRED; 492 else 493 pflags = VM_ALLOC_SYSTEM | VM_ALLOC_WIRED; | 478 pflags = malloc2vm_flags(flags) | VM_ALLOC_WIRED; |
494 | 479 |
495 if (flags & M_ZERO) 496 pflags |= VM_ALLOC_ZERO; 497 if (flags & M_NODUMP) 498 pflags |= VM_ALLOC_NODUMP; 499 | |
500 VM_OBJECT_LOCK(kmem_object); 501 for (i = 0; i < size; i += PAGE_SIZE) { 502retry: 503 m = vm_page_alloc(kmem_object, OFF_TO_IDX(offset + i), pflags); 504 505 /* 506 * Ran out of space, free everything up and return. Don't need 507 * to lock page queues here as we know that the pages we got --- 219 unchanged lines hidden --- | 480 VM_OBJECT_LOCK(kmem_object); 481 for (i = 0; i < size; i += PAGE_SIZE) { 482retry: 483 m = vm_page_alloc(kmem_object, OFF_TO_IDX(offset + i), pflags); 484 485 /* 486 * Ran out of space, free everything up and return. Don't need 487 * to lock page queues here as we know that the pages we got --- 219 unchanged lines hidden --- |