Subject: Re: lazy mlock?
To: None <Richard.Earnshaw@buzzard.freeserve.co.uk>
From: Jason R Thorpe <thorpej@wasabisystems.com>
List: tech-kern
Date: 04/16/2002 15:22:01
On Tue, Apr 16, 2002 at 11:03:15PM +0100, Richard Earnshaw wrote:

 > So, how hard would it be to add a syscall that would only lock a page into 
 > memory if it were really needed?  That is, we start with an empty set of 
 > locked pages, then as a page is referenced it is loaded and locked in 
 > place (so that it won't be swapped out again later).  This way, pages that 
 > aren't referenced will never be locked, and pages that are will only pay 
 > the fetch cost once (on first reference).  For something like ntp this 
 > would surely be perfectly adequate.

Hm...

ntpd(8) uses the mlockall(2) system call to do this... maybe we could
add 2 additional flags ... MCL_CURRENT_LAZY and MCL_FUTURE_LAZY which
implement your suggested semantics ... I don't think it would be that
hard to implement, but it's been a while since I implemented mlockall(2),
so I'd have to wrap my head around that code again...

-- 
        -- Jason R. Thorpe <thorpej@wasabisystems.com>