Record stack growth, done inline to avoid another function call on

every user page fault.

XXX Should make uvm_grow() an inline.
This commit is contained in:
thorpej 2002-09-29 16:49:45 +00:00
parent d54826f715
commit 50d060cc52

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.72 2002/06/23 03:00:19 mrg Exp $ */ /* $NetBSD: trap.c,v 1.73 2002/09/29 16:49:45 thorpej Exp $ */
/* /*
* Copyright (c) 1994 Ludd, University of Lule}, Sweden. * Copyright (c) 1994 Ludd, University of Lule}, Sweden.
@ -150,8 +150,10 @@ trap(struct trapframe *frame)
u_int rv, addr, umode; u_int rv, addr, umode;
struct proc *p = curproc; struct proc *p = curproc;
u_quad_t oticks = 0; u_quad_t oticks = 0;
struct vmspace *vm;
struct vm_map *map; struct vm_map *map;
vm_prot_t ftype; vm_prot_t ftype;
vsize_t nss;
uvmexp.traps++; uvmexp.traps++;
if ((umode = USERMODE(frame))) { if ((umode = USERMODE(frame))) {
@ -228,10 +230,13 @@ if(faultdebug)printf("trap accflt type %lx, code %lx, pc %lx, psl %lx\n",
* bother doing it here. * bother doing it here.
*/ */
addr = trunc_page(frame->code); addr = trunc_page(frame->code);
if ((umode == 0) && (frame->code < 0)) if ((umode == 0) && (frame->code < 0)) {
vm = NULL;
map = kernel_map; map = kernel_map;
else } else {
map = &p->p_vmspace->vm_map; vm = p->p_vmspace;
map = &vm->vm_map;
}
if (frame->trap & T_WRITE) if (frame->trap & T_WRITE)
ftype = VM_PROT_WRITE; ftype = VM_PROT_WRITE;
@ -242,6 +247,21 @@ if(faultdebug)printf("trap accflt type %lx, code %lx, pc %lx, psl %lx\n",
KERNEL_PROC_LOCK(p); KERNEL_PROC_LOCK(p);
else else
KERNEL_LOCK(LK_CANRECURSE|LK_EXCLUSIVE); KERNEL_LOCK(LK_CANRECURSE|LK_EXCLUSIVE);
nss = 0;
if (map != kernel_map &&
(caddr_t)addr >= vm->vm_maxsaddr &&
(caddr_t)addr < (caddr_t)USRSTACK) {
nss = btoc(USRSTACK - addr);
if (nss > btoc(p->p_rlimit[RLIMIT_STACK].rlim_cur)) {
/*
* Set nss to 0, since this case is not
* a "stack extension".
*/
nss = 0;
}
}
rv = uvm_fault(map, addr, 0, ftype); rv = uvm_fault(map, addr, 0, ftype);
if (rv != 0) { if (rv != 0) {
if (umode == 0) { if (umode == 0) {
@ -260,8 +280,11 @@ if(faultdebug)printf("trap accflt type %lx, code %lx, pc %lx, psl %lx\n",
} else { } else {
sig = SIGSEGV; sig = SIGSEGV;
} }
} else } else {
trapsig = 0; trapsig = 0;
if (nss != 0 && nss > vm->vm_ssize)
vm->vm_ssize = nss;
}
if (umode) if (umode)
KERNEL_PROC_UNLOCK(p); KERNEL_PROC_UNLOCK(p);
else else