Subject: NetBSD1.6 UVM problem?
To: 'tech-kern@netbsd.org' <tech-kern@netbsd.org>
From: Sylvain Fontaine <sfontaine@hyperchip.com>
List: tech-kern
Date: 12/06/2002 11:35:13
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C29D45.739B3150
Content-Type: text/plain;
	charset="iso-8859-1"


I found a behavior with the UVM that seems to be wrong.
My system has no swap space. 1G of RAM.

Here's what I see:
- Create a file of 100M on a MFS of 100M.  Then 200M are removed from free,
100M active, 100M file.
  I'm left with about 730M of free mem now, but with 100M file memory
available when needed.
- I start a program that calloc (not malloc) 800M.  I expect file memory to
be returned to me.
  The test program does callocation by 100M slices.
- The page deamon does not react until its free_target is not under.  About
~~500k.
- When the page deamon finds the free_target not to be met, it starts
recovering pages, 
  but there's a race condition freeing/allocating and my test app wins...
resulting in faulting
  and being killed by the UVM when uvm_fault returns ENOMEM.  


I found two solutions:
1) In this condition, when I know there is still memory I can retrieve from
file memory,
    I call uvm_wait, and tell the pagedeamon to overlook the free_target and
to free 
    some pages because I need some, even if the free_target is met.
2) Increraese the free target to 1/20 of my memory ~50M... This way the race
begins sooner
    And the pagedeamon wins.

Sylvain

  



------_=_NextPart_001_01C29D45.739B3150
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
5.5.2653.12">
<TITLE>NetBSD1.6 UVM problem?</TITLE>
</HEAD>
<BODY>
<BR>

<P><FONT SIZE=3D2 FACE=3D"Arial">I found a behavior with the UVM that =
seems to be wrong.</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">My system has no swap space. 1G of =
RAM.</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">Here's what I see:</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">- Create a file of 100M on a MFS of =
100M.&nbsp; Then 200M are removed from free, 100M active, 100M =
file.</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">&nbsp; I'm left with about 730M of =
free mem now, but with 100M file memory available when needed.</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">- I start a program that calloc (not =
malloc) 800M.&nbsp; I expect file memory to be returned to me.</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">&nbsp; The test program does =
callocation by 100M slices.</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">- The page deamon does not react =
until its free_target is not under.&nbsp; About ~500k.</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">- When the page deamon finds the =
free_target not to be met, it starts recovering pages, </FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">&nbsp; but there's a race condition =
freeing/allocating and my test app wins... resulting in faulting</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">&nbsp; and being killed by the UVM =
when uvm_fault returns ENOMEM.&nbsp; </FONT>
</P>
<BR>

<P><FONT SIZE=3D2 FACE=3D"Arial">I found two solutions:</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">1) In this condition, when I know =
there is still memory I can retrieve from file memory,</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">&nbsp;&nbsp;&nbsp; I call uvm_wait, =
and tell the pagedeamon to overlook the free_target and to free </FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">&nbsp;&nbsp;&nbsp; some pages because =
I need some, even if the free_target is met.</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">2) Increraese the free target to 1/20 =
of my memory ~50M... This way the race begins sooner</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">&nbsp;&nbsp;&nbsp; And the pagedeamon =
wins.</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">Sylvain</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">&nbsp; </FONT>
</P>
<BR>

</BODY>
</HTML>
------_=_NextPart_001_01C29D45.739B3150--