if uvm_fault() fails with KERN_RESOURCE_SHORTAGE, send a SIGKILL

and print a message about it.  this will be used to recover from
out-of-swap conditions.
This commit is contained in:
chs 1999-03-18 04:56:01 +00:00
parent 32783bf7e7
commit ab7269f62a
18 changed files with 168 additions and 47 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.40 1999/02/23 03:20:03 thorpej Exp $ */
/* $NetBSD: trap.c,v 1.41 1999/03/18 04:56:01 chs Exp $ */
/*
* Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
@ -35,7 +35,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.40 1999/02/23 03:20:03 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.41 1999/03/18 04:56:01 chs Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -468,10 +468,15 @@ trap(a0, a1, a2, entry, framep)
goto dopanic;
}
ucode = a0;
i = SIGSEGV;
#ifdef DEBUG
printtrap(a0, a1, a2, entry, framep, 1, user);
#endif
if (rv == KERN_RESOURCE_SHORTAGE) {
printf("UVM: pid %d (%s), uid %d killed: "
"out of swap\n", p->p_pid, p->p_comm,
p->p_cred && p->p_ucred ?
p->p_ucred->cr_uid : -1);
i = SIGKILL;
} else {
i = SIGSEGV;
}
break;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.67 1998/12/15 19:36:36 itohy Exp $ */
/* $NetBSD: trap.c,v 1.68 1999/03/18 04:56:01 chs Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -542,7 +542,14 @@ nogo:
type, code);
panictrap(type, code, v, fp);
}
trapsignal(p, SIGSEGV, v);
if (rv == KERN_RESOURCE_SHORTAGE) {
printf("UVM: pid %d (%s), uid %d killed: out of swap\n",
p->p_pid, p->p_comm,
p->p_cred && p->p_ucred ? p->p_ucred->cr_uid : -1);
trapsignal(p, SIGKILL, v);
} else {
trapsignal(p, SIGSEGV, v);
}
if ((type & T_USER) == 0)
return;
userret(p, fp->f_pc, sticks);

View File

@ -1,4 +1,4 @@
/* $NetBSD: fault.c,v 1.36 1999/02/19 22:32:21 mycroft Exp $ */
/* $NetBSD: fault.c,v 1.37 1999/03/18 04:56:04 chs Exp $ */
/*
* Copyright (c) 1994-1997 Mark Brinicombe.
@ -455,7 +455,15 @@ copyfault:
goto out;
report_abort("", fault_status, fault_address, fault_pc);
trapsignal(p, SIGSEGV, TRAP_CODE);
if (rv == KERN_RESOURCE_SHORTAGE) {
printf("UVM: pid %d (%s), uid %d killed: "
"out of swap\n", p->p_pid, p->p_comm,
p->p_cred && p->p_ucred ?
p->p_ucred->cr_uid : -1);
trapsignal(p, SIGKILL, TRAP_CODE);
} else {
trapsignal(p, SIGSEGV, TRAP_CODE);
}
break;
}
break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.39 1998/12/15 19:36:58 itohy Exp $ */
/* $NetBSD: trap.c,v 1.40 1999/03/18 04:56:01 chs Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -690,7 +690,15 @@ trap(type, code, v, frame)
panictrap(type, code, v, &frame);
}
ucode = v;
i = SIGSEGV;
if (rv == KERN_RESOURCE_SHORTAGE) {
printf("UVM: pid %d (%s), uid %d killed: out of swap\n",
p->p_pid, p->p_comm,
p->p_cred && p->p_ucred ?
p->p_ucred->cr_uid : -1);
i = SIGKILL;
} else {
i = SIGSEGV;
}
break;
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.68 1998/12/15 19:37:01 itohy Exp $ */
/* $NetBSD: trap.c,v 1.69 1999/03/18 04:56:01 chs Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -704,7 +704,15 @@ trap(type, code, v, frame)
goto dopanic;
}
ucode = v;
i = SIGSEGV;
if (rv == KERN_RESOURCE_SHORTAGE) {
printf("UVM: pid %d (%s), uid %d killed: out of swap\n",
p->p_pid, p->p_comm,
p->p_cred && p->p_ucred ?
p->p_ucred->cr_uid : -1);
i = SIGKILL;
} else {
i = SIGSEGV;
}
break;
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.129 1999/02/13 16:10:44 christos Exp $ */
/* $NetBSD: trap.c,v 1.130 1999/03/18 04:56:02 chs Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -553,8 +553,10 @@ trap(frame)
goto we_re_toast;
}
if (rv == KERN_RESOURCE_SHORTAGE) {
printf("UVM: process %d killed: out of swap space\n",
p->p_pid);
printf("UVM: pid %d (%s), uid %d killed: out of swap\n",
p->p_pid, p->p_comm,
p->p_cred && p->p_ucred ?
p->p_ucred->cr_uid : -1);
trapsignal(p, SIGKILL, T_PAGEFLT);
} else {
trapsignal(p, SIGSEGV, T_PAGEFLT);

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.68 1998/12/22 08:47:07 scottr Exp $ */
/* $NetBSD: trap.c,v 1.69 1999/03/18 04:56:02 chs Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -692,7 +692,15 @@ copyfault:
goto dopanic;
}
ucode = v;
i = SIGSEGV;
if (rv == KERN_RESOURCE_SHORTAGE) {
printf("UVM: pid %d (%s), uid %d killed: out of swap\n",
p->p_pid, p->p_comm,
p->p_cred && p->p_ucred ?
p->p_ucred->cr_uid : -1);
i = SIGKILL;
} else {
i = SIGSEGV;
}
break;
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.104 1999/03/05 22:18:07 mhitch Exp $ */
/* $NetBSD: trap.c,v 1.105 1999/03/18 04:56:02 chs Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -43,7 +43,7 @@
*/
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.104 1999/03/05 22:18:07 mhitch Exp $");
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.105 1999/03/18 04:56:02 chs Exp $");
#include "opt_cputype.h" /* which mips CPU levels do we support? */
#include "opt_inet.h"
@ -582,7 +582,16 @@ trap(status, cause, vaddr, opc, frame)
}
if ((type & T_USER) == 0)
goto copyfault;
sig = (rv == KERN_PROTECTION_FAILURE) ? SIGBUS : SIGSEGV;
if (rv == KERN_RESOURCE_SHORTAGE) {
printf("UVM: pid %d (%s), uid %d killed: out of swap\n",
p->p_pid, p->p_comm,
p->p_cred && p->p_ucred ?
p->p_ucred->cr_uid : -1);
sig = SIGKILL;
} else {
sig = (rv == KERN_PROTECTION_FAILURE) ?
SIGBUS : SIGSEGV;
}
ucode = vaddr;
break; /* SIGNAL */
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.27 1999/02/14 17:54:30 scw Exp $ */
/* $NetBSD: trap.c,v 1.28 1999/03/18 04:56:02 chs Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -697,7 +697,15 @@ trap(type, code, v, frame)
goto dopanic;
}
ucode = v;
i = SIGSEGV;
if (rv == KERN_RESOURCE_SHORTAGE) {
printf("UVM: pid %d (%s), uid %d killed: out of swap\n",
p->p_pid, p->p_comm,
p->p_cred && p->p_ucred ?
p->p_ucred->cr_uid : -1);
i = SIGKILL;
} else {
i = SIGSEGV;
}
break;
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.10 1999/01/13 09:26:00 abs Exp $ */
/* $NetBSD: trap.c,v 1.11 1999/03/18 04:56:03 chs Exp $ */
/*
* This file was taken from mvme68k/mvme68k/trap.c
@ -641,7 +641,15 @@ copyfault:
goto dopanic;
}
ucode = v;
i = SIGSEGV;
if (rv == KERN_RESOURCE_SHORTAGE) {
printf("UVM: pid %d (%s), uid %d killed: out of swap\n",
p->p_pid, p->p_comm,
p->p_cred && p->p_ucred ?
p->p_ucred->cr_uid : -1);
i = SIGKILL;
} else {
i = SIGSEGV;
}
break;
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.33 1998/11/11 06:43:50 thorpej Exp $ */
/* $NetBSD: trap.c,v 1.34 1999/03/18 04:56:03 chs Exp $ */
/*-
* Copyright (c) 1996 Matthias Pfaller. All rights reserved.
@ -486,8 +486,10 @@ trap(frame)
goto we_re_toast;
}
if (rv == KERN_RESOURCE_SHORTAGE) {
printf("UVM: process %d killed: out of swap space\n",
p->p_pid);
printf("UVM: pid %d (%s), uid %d killed: out of swap\n",
p->p_pid, p->p_comm,
p->p_cred && p->p_ucred ?
p->p_ucred->cr_uid : -1);
trapsignal(p, SIGKILL, T_ABT);
} else {
trapsignal(p, SIGSEGV, T_ABT);

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.14 1998/07/05 06:49:08 jonathan Exp $ */
/* $NetBSD: trap.c,v 1.15 1999/03/18 04:56:03 chs Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -558,7 +558,15 @@ trap(statusReg, causeReg, vadr, pc, args)
goto err;
}
ucode = vadr;
i = SIGSEGV;
if (rv == KERN_RESOURCE_SHORTAGE) {
printf("UVM: pid %d (%s), uid %d killed: out of swap\n",
p->p_pid, p->p_comm,
p->p_cred && p->p_ucred ?
p->p_ucred->cr_uid : -1);
i = SIGKILL;
} else {
i = SIGSEGV;
}
break;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.16 1999/03/15 01:29:07 tsubai Exp $ */
/* $NetBSD: trap.c,v 1.17 1999/03/18 04:56:03 chs Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
@ -145,7 +145,15 @@ trap(frame)
break;
#endif
}
trapsignal(p, SIGSEGV, EXC_DSI);
if (rv == KERN_RESOURCE_SHORTAGE) {
printf("UVM: pid %d (%s), uid %d killed: out of swap\n",
p->p_pid, p->p_comm,
p->p_cred && p->p_ucred ?
p->p_ucred->cr_uid : -1);
trapsignal(p, SIGKILL, EXC_DSI);
} else {
trapsignal(p, SIGSEGV, EXC_DSI);
}
break;
case EXC_ISI|EXC_USER:
{

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.82 1999/03/18 04:27:54 chs Exp $ */
/* $NetBSD: trap.c,v 1.83 1999/03/18 04:56:03 chs Exp $ */
/*
* Copyright (c) 1996
@ -858,8 +858,10 @@ kfault:
return;
}
if (rv == KERN_RESOURCE_SHORTAGE) {
printf("UVM: process %d killed: out of swap space\n",
p->p_pid);
printf("UVM: pid %d (%s), uid %d killed: out of swap\n",
p->p_pid, p->p_comm,
p->p_cred && p->p_ucred ?
p->p_ucred->cr_uid : -1);
trapsignal(p, SIGKILL, (u_int)v);
} else
trapsignal(p, SIGSEGV, (u_int)v);

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.24 1999/03/18 03:25:55 eeh Exp $ */
/* $NetBSD: trap.c,v 1.25 1999/03/18 04:56:03 chs Exp $ */
/*
* Copyright (c) 1996
@ -1148,7 +1148,15 @@ kfault:
Debugger();
}
#endif
trapsignal(p, SIGSEGV, (u_long)addr);
if (rv == KERN_RESOURCE_SHORTAGE) {
printf("UVM: pid %d (%s), uid %d killed: out of swap\n",
p->p_pid, p->p_comm,
p->p_cred && p->p_ucred ?
p->p_ucred->cr_uid : -1);
trapsignal(p, SIGKILL, (u_long)addr);
} else {
trapsignal(p, SIGSEGV, (u_long)addr);
}
}
if ((tstate & TSTATE_PRIV) == 0) {
userret(p, pc, sticks);

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.83 1998/12/15 19:37:12 itohy Exp $ */
/* $NetBSD: trap.c,v 1.84 1999/03/18 04:56:04 chs Exp $ */
/*
* Copyright (c) 1994 Gordon W. Ross
@ -575,7 +575,15 @@ trap(type, code, v, tf)
goto dopanic;
}
ucode = v;
sig = SIGSEGV;
if (rv == KERN_RESOURCE_SHORTAGE) {
printf("UVM: pid %d (%s), uid %d killed: out of swap\n",
p->p_pid, p->p_comm,
p->p_cred && p->p_ucred ?
p->p_ucred->cr_uid : -1);
sig = SIGKILL;
} else {
sig = SIGSEGV;
}
break;
} /* T_MMUFLT */
} /* switch */

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.42 1999/03/13 15:16:48 ragge Exp $ */
/* $NetBSD: trap.c,v 1.43 1999/03/18 04:56:04 chs Exp $ */
/*
* Copyright (c) 1994 Ludd, University of Lule}, Sweden.
* All rights reserved.
@ -226,10 +226,16 @@ if(faultdebug)printf("trap accflt type %lx, code %lx, pc %lx, psl %lx\n",
panic("Segv in kernel mode: pc %x addr %x",
(u_int)frame->pc, (u_int)frame->code);
}
ufault: if (rv == KERN_RESOURCE_SHORTAGE)
printf("Pid %d killed: out of memory.\n",
p->p_pid);
sig = SIGSEGV;
ufault: if (rv == KERN_RESOURCE_SHORTAGE) {
printf("UVM: pid %d (%s), uid %d killed: "
"out of swap\n",
p->p_pid, p->p_comm,
p->p_cred && p->p_ucred ?
p->p_ucred->cr_uid : -1);
sig = SIGKILL;
} else {
sig = SIGSEGV;
}
} else
trapsig = 0;
break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.27 1999/03/16 16:30:23 minoura Exp $ */
/* $NetBSD: trap.c,v 1.28 1999/03/18 04:56:04 chs Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -730,7 +730,15 @@ trap(type, code, v, frame)
goto dopanic;
}
ucode = v;
i = SIGSEGV;
if (rv == KERN_RESOURCE_SHORTAGE) {
printf("UVM: pid %d (%s), uid %d killed: out of swap\n",
p->p_pid, p->p_comm,
p->p_cred && p->p_ucred ?
p->p_ucred->cr_uid : -1);
i = SIGKILL;
} else {
i = SIGSEGV;
}
break;
}
}