[openib-general] get_user_pages() vs. sys_mlock() and 2.6 kernel

Libor Michalek libor at topspin.com
Fri Sep 3 16:07:45 PDT 2004


On Tue, Aug 31, 2004 at 05:35:29PM -0500, Timur Tabi wrote:
> What is the reason that sys_mlock() is used instead of get_user_pages()? 
> I know the sys_mlock() is used because other methods of locking pages 
> didn't really lock the pages (i.e. there were still situations where the 
> page would be swapped out).  Doe get_user_pages() have that problem 
> also?  If so, has any checked to see if it's been fixed in the 2.6 kernel?

  Yes, get_user_pages() is the call that has the problem you describe in
the 2.4 kernel, which resulted in the use of sys_mlock. Actually it does
the correct thing, forces the pages to be resident and increments the
reference count, but the swapper does not honor the reference count. The
pte that points to that page can get unmapped and then mapped to another
page, even though the reference count indicates that it should not happen.
Also, the LOCK flag for the VM is checked before the pte is unmapped,
so in the case of sys_mlock the problem does not happen.

  I've seen the problem in test cases, so it definetly can happen in 2.4.
Looking at the 2.6 code the problem appears to be fixed, but I have not
had a chance to run tests to verify it. Good place to take look if you 
are interested is in launder_page() and try_to_unmap() in the kernel.


-Libor



More information about the general mailing list