Deleted Added
full compact
vm_kern.c (98450) vm_kern.c (98455)
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

--- 47 unchanged lines hidden (view full) ---

56 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
57 * School of Computer Science
58 * Carnegie Mellon University
59 * Pittsburgh PA 15213-3890
60 *
61 * any improvements or extensions that they make and grant Carnegie the
62 * rights to redistribute these changes.
63 *
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

--- 47 unchanged lines hidden (view full) ---

56 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
57 * School of Computer Science
58 * Carnegie Mellon University
59 * Pittsburgh PA 15213-3890
60 *
61 * any improvements or extensions that they make and grant Carnegie the
62 * rights to redistribute these changes.
63 *
64 * $FreeBSD: head/sys/vm/vm_kern.c 98450 2002-06-19 20:47:18Z jeff $
64 * $FreeBSD: head/sys/vm/vm_kern.c 98455 2002-06-19 23:49:57Z jeff $
65 */
66
67/*
68 * Kernel memory management.
69 */
70
71#include <sys/param.h>
72#include <sys/systm.h>

--- 234 unchanged lines hidden (view full) ---

307 vm_map_t map;
308 vm_size_t size;
309 int flags;
310{
311 vm_offset_t offset, i;
312 vm_map_entry_t entry;
313 vm_offset_t addr;
314 vm_page_t m;
65 */
66
67/*
68 * Kernel memory management.
69 */
70
71#include <sys/param.h>
72#include <sys/systm.h>

--- 234 unchanged lines hidden (view full) ---

307 vm_map_t map;
308 vm_size_t size;
309 int flags;
310{
311 vm_offset_t offset, i;
312 vm_map_entry_t entry;
313 vm_offset_t addr;
314 vm_page_t m;
315 int pflags;
315
316 GIANT_REQUIRED;
317
318 size = round_page(size);
319 addr = vm_map_min(map);
320
321 /*
322 * Locate sufficient space in the map. This will give us the final

--- 18 unchanged lines hidden (view full) ---

341 (long)size, (long)map->size);
342 goto bad;
343 }
344 offset = addr - VM_MIN_KERNEL_ADDRESS;
345 vm_object_reference(kmem_object);
346 vm_map_insert(map, kmem_object, offset, addr, addr + size,
347 VM_PROT_ALL, VM_PROT_ALL, 0);
348
316
317 GIANT_REQUIRED;
318
319 size = round_page(size);
320 addr = vm_map_min(map);
321
322 /*
323 * Locate sufficient space in the map. This will give us the final

--- 18 unchanged lines hidden (view full) ---

342 (long)size, (long)map->size);
343 goto bad;
344 }
345 offset = addr - VM_MIN_KERNEL_ADDRESS;
346 vm_object_reference(kmem_object);
347 vm_map_insert(map, kmem_object, offset, addr, addr + size,
348 VM_PROT_ALL, VM_PROT_ALL, 0);
349
349 for (i = 0; i < size; i += PAGE_SIZE) {
350 int pflags;
351 /*
352 * Note: if M_NOWAIT specified alone, allocate from
353 * interrupt-safe queues only (just the free list). If
354 * M_USE_RESERVE is also specified, we can also
355 * allocate from the cache. Neither of the latter two
356 * flags may be specified from an interrupt since interrupts
357 * are not allowed to mess with the cache queue.
358 */
359retry:
360 if ((flags & (M_NOWAIT|M_USE_RESERVE)) == M_NOWAIT)
361 pflags = VM_ALLOC_INTERRUPT;
362 else
363 pflags = VM_ALLOC_SYSTEM;
350 /*
351 * Note: if M_NOWAIT specified alone, allocate from
352 * interrupt-safe queues only (just the free list). If
353 * M_USE_RESERVE is also specified, we can also
354 * allocate from the cache. Neither of the latter two
355 * flags may be specified from an interrupt since interrupts
356 * are not allowed to mess with the cache queue.
357 */
364
358
365 if (flags & M_ZERO)
366 pflags |= VM_ALLOC_ZERO;
359 if ((flags & (M_NOWAIT|M_USE_RESERVE)) == M_NOWAIT)
360 pflags = VM_ALLOC_INTERRUPT;
361 else
362 pflags = VM_ALLOC_SYSTEM;
367
363
364 if (flags & M_ZERO)
365 pflags |= VM_ALLOC_ZERO;
366
367
368 for (i = 0; i < size; i += PAGE_SIZE) {
369retry:
368 m = vm_page_alloc(kmem_object, OFF_TO_IDX(offset + i), pflags);
369
370 /*
371 * Ran out of space, free everything up and return. Don't need
372 * to lock page queues here as we know that the pages we got
373 * aren't on any queues.
374 */
375 if (m == NULL) {

--- 14 unchanged lines hidden (view full) ---

390 m = vm_page_lookup(kmem_object,
391 OFF_TO_IDX(offset + i));
392 vm_page_free(m);
393 }
394 vm_map_delete(map, addr, addr + size);
395 vm_map_unlock(map);
396 goto bad;
397 }
370 m = vm_page_alloc(kmem_object, OFF_TO_IDX(offset + i), pflags);
371
372 /*
373 * Ran out of space, free everything up and return. Don't need
374 * to lock page queues here as we know that the pages we got
375 * aren't on any queues.
376 */
377 if (m == NULL) {

--- 14 unchanged lines hidden (view full) ---

392 m = vm_page_lookup(kmem_object,
393 OFF_TO_IDX(offset + i));
394 vm_page_free(m);
395 }
396 vm_map_delete(map, addr, addr + size);
397 vm_map_unlock(map);
398 goto bad;
399 }
400 if (flags & M_ZERO && (m->flags & PG_ZERO) == 0)
401 vm_page_zero_fill(m);
398 vm_page_flag_clear(m, PG_ZERO);
399 m->valid = VM_PAGE_BITS_ALL;
400 }
401
402 /*
403 * Mark map entry as non-pageable. Assert: vm_map_insert() will never
404 * be able to extend the previous entry so there will be a new entry
405 * exactly corresponding to this address range and it will have

--- 117 unchanged lines hidden ---
402 vm_page_flag_clear(m, PG_ZERO);
403 m->valid = VM_PAGE_BITS_ALL;
404 }
405
406 /*
407 * Mark map entry as non-pageable. Assert: vm_map_insert() will never
408 * be able to extend the previous entry so there will be a new entry
409 * exactly corresponding to this address range and it will have

--- 117 unchanged lines hidden ---