Deleted Added
full compact
vm_glue.c (253953) vm_glue.c (254025)
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

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

52 * Carnegie Mellon University
53 * Pittsburgh PA 15213-3890
54 *
55 * any improvements or extensions that they make and grant Carnegie the
56 * rights to redistribute these changes.
57 */
58
59#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

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

52 * Carnegie Mellon University
53 * Pittsburgh PA 15213-3890
54 *
55 * any improvements or extensions that they make and grant Carnegie the
56 * rights to redistribute these changes.
57 */
58
59#include <sys/cdefs.h>
60__FBSDID("$FreeBSD: head/sys/vm/vm_glue.c 253953 2013-08-05 08:55:35Z attilio $");
60__FBSDID("$FreeBSD: head/sys/vm/vm_glue.c 254025 2013-08-07 06:21:20Z jeff $");
61
62#include "opt_vm.h"
63#include "opt_kstack_pages.h"
64#include "opt_kstack_max_pages.h"
65
66#include <sys/param.h>
67#include <sys/systm.h>
68#include <sys/limits.h>
69#include <sys/lock.h>
61
62#include "opt_vm.h"
63#include "opt_kstack_pages.h"
64#include "opt_kstack_max_pages.h"
65
66#include <sys/param.h>
67#include <sys/systm.h>
68#include <sys/limits.h>
69#include <sys/lock.h>
70#include <sys/malloc.h>
70#include <sys/mutex.h>
71#include <sys/proc.h>
72#include <sys/racct.h>
73#include <sys/resourcevar.h>
74#include <sys/rwlock.h>
75#include <sys/sched.h>
76#include <sys/sf_buf.h>
77#include <sys/shm.h>
78#include <sys/vmmeter.h>
71#include <sys/mutex.h>
72#include <sys/proc.h>
73#include <sys/racct.h>
74#include <sys/resourcevar.h>
75#include <sys/rwlock.h>
76#include <sys/sched.h>
77#include <sys/sf_buf.h>
78#include <sys/shm.h>
79#include <sys/vmmeter.h>
80#include <sys/vmem.h>
79#include <sys/sx.h>
80#include <sys/sysctl.h>
81#include <sys/_kstack_cache.h>
82#include <sys/eventhandler.h>
83#include <sys/kernel.h>
84#include <sys/ktr.h>
85#include <sys/unistd.h>
86

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

354 /*
355 * Get a kernel virtual address for this thread's kstack.
356 */
357#if defined(__mips__)
358 /*
359 * We need to align the kstack's mapped address to fit within
360 * a single TLB entry.
361 */
81#include <sys/sx.h>
82#include <sys/sysctl.h>
83#include <sys/_kstack_cache.h>
84#include <sys/eventhandler.h>
85#include <sys/kernel.h>
86#include <sys/ktr.h>
87#include <sys/unistd.h>
88

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

356 /*
357 * Get a kernel virtual address for this thread's kstack.
358 */
359#if defined(__mips__)
360 /*
361 * We need to align the kstack's mapped address to fit within
362 * a single TLB entry.
363 */
362 ks = kmem_alloc_nofault_space(kernel_map,
363 (pages + KSTACK_GUARD_PAGES) * PAGE_SIZE, VMFS_TLB_ALIGNED_SPACE);
364 if (vmem_xalloc(kernel_arena, (pages + KSTACK_GUARD_PAGES) * PAGE_SIZE,
365 PAGE_SIZE * 2, 0, 0, VMEM_ADDR_MIN, VMEM_ADDR_MAX,
366 M_BESTFIT | M_NOWAIT, &ks)) {
367 ks = 0;
368 }
364#else
369#else
365 ks = kmem_alloc_nofault(kernel_map,
366 (pages + KSTACK_GUARD_PAGES) * PAGE_SIZE);
370 ks = kva_alloc((pages + KSTACK_GUARD_PAGES) * PAGE_SIZE);
367#endif
368 if (ks == 0) {
369 printf("vm_thread_new: kstack allocation failed\n");
370 vm_object_deallocate(ksobj);
371 return (0);
372 }
373
374 atomic_add_int(&kstacks, 1);

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

417 panic("vm_thread_dispose: kstack already missing?");
418 vm_page_lock(m);
419 vm_page_unwire(m, 0);
420 vm_page_free(m);
421 vm_page_unlock(m);
422 }
423 VM_OBJECT_WUNLOCK(ksobj);
424 vm_object_deallocate(ksobj);
371#endif
372 if (ks == 0) {
373 printf("vm_thread_new: kstack allocation failed\n");
374 vm_object_deallocate(ksobj);
375 return (0);
376 }
377
378 atomic_add_int(&kstacks, 1);

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

421 panic("vm_thread_dispose: kstack already missing?");
422 vm_page_lock(m);
423 vm_page_unwire(m, 0);
424 vm_page_free(m);
425 vm_page_unlock(m);
426 }
427 VM_OBJECT_WUNLOCK(ksobj);
428 vm_object_deallocate(ksobj);
425 kmem_free(kernel_map, ks - (KSTACK_GUARD_PAGES * PAGE_SIZE),
429 kva_free(ks - (KSTACK_GUARD_PAGES * PAGE_SIZE),
426 (pages + KSTACK_GUARD_PAGES) * PAGE_SIZE);
427}
428
429/*
430 * Dispose of a thread's kernel stack.
431 */
432void
433vm_thread_dispose(struct thread *td)

--- 611 unchanged lines hidden ---
430 (pages + KSTACK_GUARD_PAGES) * PAGE_SIZE);
431}
432
433/*
434 * Dispose of a thread's kernel stack.
435 */
436void
437vm_thread_dispose(struct thread *td)

--- 611 unchanged lines hidden ---