[lkml]   [2003]   [Dec]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Subjectmlock() "bogus check" (locked > num_physpages/2) _does_ hurt!
Hi everyone,

in kernel 2.4.23, file mm/mlock.c, line 215, there's the following
piece of code:

/* we may lock at most half of physical memory... */
/* (this check is pretty bogus, but doesn't hurt) */
if (locked > num_physpages/2)
goto out;

Obviously, the author already realized this check is bogus,
but the assumption that it doesn't hurt is very wrong... at least
for me: I'm writing a server application that uses much more virtual memory
than there's physical memory (and on 64bit systems, there can be a lot more
virtual memory!). The application needs to access only a small fraction of
the memory used during normal operation, the rest of the virtual memory used
is used for (slowly) rebuilding indicies in the background. So it is completely
ok for me that most of the applications memory is swapped out, and to make sure
that response times are low even after much of the memory is on disk, I use
mlock() to lock the interesting pages in memory.

And yes, I would very much like to use more than half of the physical memory
for that purpose!

Is there any good reason to keep this check in the 2.4 kernel sources?
Is there any good reason to not use a different default value
for the RLIMIT_MEMLOCK value (which is currently 0xffffffffffffffff), instead?

It's good to know the check is not present in the 2.6 sources, but I would
like to get rid of it in 2.4, too...


Lutz Vieweg

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:59    [W:0.023 / U:0.552 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site