linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* mlock() "bogus check" (locked > num_physpages/2) _does_ hurt!
@ 2003-12-11 18:59 Lutz Vieweg
  2003-12-11 19:14 ` Rob Love
  0 siblings, 1 reply; 2+ messages in thread
From: Lutz Vieweg @ 2003-12-11 18:59 UTC (permalink / raw)
  To: linux-kernel

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...

Regards,

Lutz Vieweg





^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: mlock() "bogus check" (locked > num_physpages/2) _does_ hurt!
  2003-12-11 18:59 mlock() "bogus check" (locked > num_physpages/2) _does_ hurt! Lutz Vieweg
@ 2003-12-11 19:14 ` Rob Love
  0 siblings, 0 replies; 2+ messages in thread
From: Rob Love @ 2003-12-11 19:14 UTC (permalink / raw)
  To: Lutz Vieweg; +Cc: linux-kernel

On Thu, 2003-12-11 at 13:59, Lutz Vieweg wrote:

> Is there any good reason to keep this check in the 2.4 kernel sources?

Not really.

> 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...

It was removed from 2.6 for the reasons you cite.  2.4 could follow
suit.

It does lead to problems, though, where you can memlock too much memory
and lock the machine up.  But we could file that under "don't do that".

	Rob Love



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-12-11 19:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-11 18:59 mlock() "bogus check" (locked > num_physpages/2) _does_ hurt! Lutz Vieweg
2003-12-11 19:14 ` Rob Love

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).