From 7841bf68c0c1357f600597301f27b6547097b24d Mon Sep 17 00:00:00 2001 From: bjh21 Date: Sun, 24 Sep 2006 20:54:14 +0000 Subject: [PATCH] uvm_fault has been sensible about when to return ENOMEM for some time now, so it's reasonable for us to kill processes when we get it returned, rather than sleeping. Do that. --- sys/arch/acorn26/acorn26/except.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/sys/arch/acorn26/acorn26/except.c b/sys/arch/acorn26/acorn26/except.c index 72a13bab6cc2..d57b036285d3 100644 --- a/sys/arch/acorn26/acorn26/except.c +++ b/sys/arch/acorn26/acorn26/except.c @@ -1,4 +1,4 @@ -/* $NetBSD: except.c,v 1.12 2006/07/19 21:11:39 ad Exp $ */ +/* $NetBSD: except.c,v 1.13 2006/09/24 20:54:14 bjh21 Exp $ */ /*- * Copyright (c) 1998, 1999, 2000 Ben Harris * All rights reserved. @@ -31,11 +31,12 @@ #include -__KERNEL_RCSID(0, "$NetBSD: except.c,v 1.12 2006/07/19 21:11:39 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: except.c,v 1.13 2006/09/24 20:54:14 bjh21 Exp $"); #include "opt_ddb.h" #include +#include #include #include #include @@ -205,14 +206,7 @@ do_fault(struct trapframe *tf, struct lwp *l, KASSERT(current_intr_depth == 0); - for (;;) { - error = uvm_fault(map, va, atype); - if (error != ENOMEM) - break; - log(LOG_WARNING, "pid %d.%d: VM shortage, sleeping\n", - l->l_proc->p_pid, l->l_lid); - tsleep(&lbolt, PVM, "abtretry", 0); - } + error = uvm_fault(map, va, atype); if (error != 0) { ksiginfo_t ksi; @@ -225,7 +219,15 @@ do_fault(struct trapframe *tf, struct lwp *l, return; } KSI_INIT_TRAP(&ksi); - ksi.ksi_signo = SIGSEGV; + + if (error == ENOMEM) { + printf("UVM: pid %d (%s), uid %d killed: " + "out of swap\n", + l->l_proc->p_pid, l->l_proc->p_comm, + l->l_cred ? kauth_cred_geteuid(l->l_cred) : -1); + ksi.ksi_signo = SIGKILL; + } else + ksi.ksi_signo = SIGSEGV; ksi.ksi_code = (error == EPERM) ? SEGV_ACCERR : SEGV_MAPERR; ksi.ksi_addr = (void *) va; trapsignal(l, &ksi);