Deleted Added
full compact
vm_kern.c (267548) vm_kern.c (269728)
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 267548 2014-06-16 18:15:27Z attilio $");
66__FBSDID("$FreeBSD: head/sys/vm/vm_kern.c 269728 2014-08-08 17:12:03Z 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/proc.h>
74#include <sys/malloc.h>

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

197 vm_page_free(m);
198 }
199 vmem_free(vmem, addr, size);
200 return (0);
201 }
202 if ((flags & M_ZERO) && (m->flags & PG_ZERO) == 0)
203 pmap_zero_page(m);
204 m->valid = VM_PAGE_BITS_ALL;
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/proc.h>
74#include <sys/malloc.h>

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

197 vm_page_free(m);
198 }
199 vmem_free(vmem, addr, size);
200 return (0);
201 }
202 if ((flags & M_ZERO) && (m->flags & PG_ZERO) == 0)
203 pmap_zero_page(m);
204 m->valid = VM_PAGE_BITS_ALL;
205 pmap_enter(kernel_pmap, addr + i, VM_PROT_ALL, m, VM_PROT_ALL,
206 TRUE);
205 pmap_enter(kernel_pmap, addr + i, m, VM_PROT_ALL,
206 VM_PROT_ALL | PMAP_ENTER_WIRED, 0);
207 }
208 VM_OBJECT_WUNLOCK(object);
209 return (addr);
210}
211
212/*
213 * Allocates a region from the kernel address map and physically
214 * contiguous pages within the specified address range to the kernel

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

250 return (0);
251 }
252 end_m = m + atop(size);
253 tmp = addr;
254 for (; m < end_m; m++) {
255 if ((flags & M_ZERO) && (m->flags & PG_ZERO) == 0)
256 pmap_zero_page(m);
257 m->valid = VM_PAGE_BITS_ALL;
207 }
208 VM_OBJECT_WUNLOCK(object);
209 return (addr);
210}
211
212/*
213 * Allocates a region from the kernel address map and physically
214 * contiguous pages within the specified address range to the kernel

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

250 return (0);
251 }
252 end_m = m + atop(size);
253 tmp = addr;
254 for (; m < end_m; m++) {
255 if ((flags & M_ZERO) && (m->flags & PG_ZERO) == 0)
256 pmap_zero_page(m);
257 m->valid = VM_PAGE_BITS_ALL;
258 pmap_enter(kernel_pmap, tmp, VM_PROT_ALL, m, VM_PROT_ALL, true);
258 pmap_enter(kernel_pmap, tmp, m, VM_PROT_ALL,
259 VM_PROT_ALL | PMAP_ENTER_WIRED, 0);
259 tmp += PAGE_SIZE;
260 }
261 VM_OBJECT_WUNLOCK(object);
262 return (addr);
263}
264
265/*
266 * kmem_suballoc:

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

373 VM_OBJECT_WUNLOCK(object);
374 return (KERN_NO_SPACE);
375 }
376 if (flags & M_ZERO && (m->flags & PG_ZERO) == 0)
377 pmap_zero_page(m);
378 KASSERT((m->oflags & VPO_UNMANAGED) != 0,
379 ("kmem_malloc: page %p is managed", m));
380 m->valid = VM_PAGE_BITS_ALL;
260 tmp += PAGE_SIZE;
261 }
262 VM_OBJECT_WUNLOCK(object);
263 return (addr);
264}
265
266/*
267 * kmem_suballoc:

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

374 VM_OBJECT_WUNLOCK(object);
375 return (KERN_NO_SPACE);
376 }
377 if (flags & M_ZERO && (m->flags & PG_ZERO) == 0)
378 pmap_zero_page(m);
379 KASSERT((m->oflags & VPO_UNMANAGED) != 0,
380 ("kmem_malloc: page %p is managed", m));
381 m->valid = VM_PAGE_BITS_ALL;
381 pmap_enter(kernel_pmap, addr + i, VM_PROT_ALL, m, VM_PROT_ALL,
382 TRUE);
382 pmap_enter(kernel_pmap, addr + i, m, VM_PROT_ALL,
383 VM_PROT_ALL | PMAP_ENTER_WIRED, 0);
383 }
384 VM_OBJECT_WUNLOCK(object);
385
386 return (KERN_SUCCESS);
387}
388
389void
390kmem_unback(vm_object_t object, vm_offset_t addr, vm_size_t size)

--- 174 unchanged lines hidden ---
384 }
385 VM_OBJECT_WUNLOCK(object);
386
387 return (KERN_SUCCESS);
388}
389
390void
391kmem_unback(vm_object_t object, vm_offset_t addr, vm_size_t size)

--- 174 unchanged lines hidden ---