Subject: Re: sleep and retry on ENOMEM (out of swap) instead of killing
To: None <reed@reedmedia.net>
From: Ben Harris <bjh21@netbsd.org>
List: tech-kern
Date: 07/23/2003 12:37:34
In article <Pine.LNX.4.43.0307221802310.14484-100000@pilchuck.reedmedia.net> you write:
>Is there any way to implement the kernel to sleep for a moment and retry
>at least one time instead of killing the process when out of swap?

NetBSD/acorn26 does this, largely because I tend to run it on
ludicrously under-powered machines.  My code (in
sys/acorn26/acorn26/except.c::do_fault()) says:

	for (;;) {
		error = uvm_fault(map, va, 0, 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);
	}

NetBSD/i386 has rather different code in trap(), but it should be possible
to do something similar.

-- 
Ben Harris                                                   <bjh21@netbsd.org>
Portmaster, NetBSD/acorn26           <URL:http://www.netbsd.org/Ports/acorn26/>