Subject: uvm_fault running out of VM when it shouldn't
To: None <tech-kern@netbsd.org>
From: Ben Harris <bjh21@netbsd.org>
List: tech-kern
Date: 08/18/2000 16:38:25
Various people (me included) have found that it's impossible to boot a
usable NetBSD/arm26 system with only 4 Mb of RAM.  Usually, init or a
single-user shell gets a SIGSEGV, with uvm_hist claiming "out of VM".
Looking through uxm_fault.c, there seem to be several places where it does
things like this before sleeping waiting for RAM:

--------8<--------
                if (uvmexp.swpgonly == uvmexp.swpages) {
                        UVMHIST_LOG(maphist,
                            "<- failed.  out of VM",0,0,0,0);
                        /* XXX instrumentation */
                        return (KERN_RESOURCE_SHORTAGE);
                }
-------->8--------

On a machine which doesn't have any swap configured, I believe
uvmexp.swpgonly and uvmexp.swpages are both zero, so if the fault handler
ever needs to wait for RAM, it will fail.  This seems wrong to me, since
it's possible for the pagedaemon to free RAM even if there's no swap
available by throwing away clean pages (like processes' text
pages).  Thus, if these tests were removed, systems that would otherwise
segfault might be able to carry on running for long enough to run
swapctl(8) and enable some swap.  Of course, this would prevent the system
recovering from a _real_ memory exhaustion situation, so perhaps a more
careful heuristic is needed.

Is my analysis here right?  Unfortunately, I'm not in the vicinity of a
4Mb machine to test this on right now.

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