Subject: Re: kern/36169: 1sec+ delays using msync(2) with flags MS_ASYNC |
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: Brian de Alwis <bsd@cs.ubc.ca>
List: netbsd-bugs
Date: 08/29/2007 18:40:03
The following reply was made to PR kern/36169; it has been noted by GNATS.

From: Brian de Alwis <bsd@cs.ubc.ca>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/36169: 1sec+ delays using msync(2) with flags MS_ASYNC |
	MS_INVALIDATE
Date: Wed, 29 Aug 2007 12:35:45 -0600

 I will say upfront that I have no knowledge of the UVM.  But I
 thought I'd give a go at tracing through the kernel implementation
 of msync.
 
 The implementation of sys___msync13() in uvm/uvm_mmap.c maps
 MS_INVALIDATE to PGO_FREE.  Might PGO_DEACTIVATE be the better
 choice?  uvm/uvm_pager.h says:
 
     #define PGO_DEACTIVATE  0x004   /* deactivate flushed pages */
     #define PGO_FREE        0x008   /* free flushed pages */
     /* if PGO_FREE is not set then the pages stay where they are. */
 
 I tried this change and booted a kernel using qemu, and the delays
 with MS_INVALIDATE disappear.  However I have no idea what are the
 possible consequences of this change, nor whether this satisfies
 the requirements of MS_INVALIDATE.
 
 --- uvm/uvm_mmap.c.old      2007-08-29 12:20:33.000000000 -0600
 +++ uvm/uvm_mmap.c  2007-08-29 11:11:10.000000000 -0600
 @@ -634,7 +634,7 @@
  
         uvmflags = PGO_CLEANIT;
         if (flags & MS_INVALIDATE)
 -               uvmflags |= PGO_FREE;
 +               uvmflags |= PGO_DEACTIVATE;     /* bsd: was PGO_FREE */
         if (flags & MS_SYNC)
                 uvmflags |= PGO_SYNCIO;
  
 
 -- 
   Brian de Alwis | Software Practices Lab | UBC | http://www.cs.ubc.ca/~bsd/
       "Amusement to an observing mind is study." - Benjamin Disraeli