tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: mlock() issues
cryintothebluesky%googlemail.com@localhost (Sad Clouds) writes:
>Hi, I've been trying to figure out why it's not possible to lock more
>than 666MB of memory, and I'm beginning to think it might be a kernel
>issue.
>This is what I'm doing:
>Run program as root.
>Lock only memory segments that are multiples of system page size.
>ulimit -l is set to unlimited.
>proc.curproc.rlimit.memorylocked.soft = 697976149
>proc.curproc.rlimit.memorylocked.hard = 2093928448
>With all of the above set, for some reason it's not possible to lock
>more than 666MB.
That's what your soft limit is set to.
On my -current/amd64 system I have:
memorylocked 2704186 kbytes
proc.curproc.rlimit.memorylocked.soft = 2769087146
proc.curproc.rlimit.memorylocked.hard = 8307261440
and a programm running under mlockall(MLC_CURRENT|MCL_FUTURE)
can allocate about 2.6GB. So far, so fine.
However, when I set the limit to 6GB (6144m):
memorylocked 6291456 kbytes
proc.curproc.rlimit.memorylocked.soft = 6442450944
proc.curproc.rlimit.memorylocked.hard = 8307261440
this has no effect and the program still can only allocate 2.6GB.
The reason for this is that there is a global UVM limit:
% vmstat -s|grep wired
3177 pages wired
676717 maximum wired pages
The soft rlimit and the UVM limit happen to be the same size,
which is one third of the real memory.
uvm_pdaemon.c:
uvmexp.wiredmax = uvmexp.npages / 3;
kern_proc.c:
lim = MIN(VM_MAXUSER_ADDRESS, ctob((rlim_t)uvmexp.free));
...
limit0.pl_rlimit[RLIMIT_MEMLOCK].rlim_cur = lim / 3;
--
--
Michael van Elst
Internet: mlelstv%serpens.de@localhost
"A potential Snark may lurk in every tree."
Home |
Main Index |
Thread Index |
Old Index