-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
excessively large page table on 64-bit platforms #4448
Comments
Comment author: smimram Here are two runs of liquidsoap: $ OCAMLRUNPARAM="v=12" ./liquidsoap 'output.dummy(blank())' $ OCAMLRUNPARAM="v=12" ./liquidsoap 'output.dummy(blank())' The processor is an "AMD Athlon(tm) 64 Processor 3500+", running Debian testing, and the kernel is 2.6.22-2-amd64. ocaml comes from the 3.10.0-8 Debian package. $ grep USE_MMAP |
Comment author: @xavierleroy While you're at it, and if your OS is Lunix, the output of the following command is interesting as well: cat /proc/sys/kernel/randomize_va_space (Thanks, Basile.) |
Comment author: smimram Here it is: $ cat /proc/sys/kernel/randomize_va_space and by the way, the problem disappears if I echo 0 > /proc/sys/kernel/randomize_va_space |
Comment author: adamc Linux distro is Fedora 5. $ uname -a $ grep USE_MMAP $ cat /proc/sys/kernel/randomize_va_space |
Comment author: @Chris00
In fact, randomization seems to be in the stock kernel: I have compiled Linux 2.6.23.1 #1 SMP Tue Nov 13 22:17:50 CET 2007 x86_64 GNU/Linux downloaded from kernel.org a few days ago (no patches applied) and I have $ cat /proc/sys/kernel/randomize_va_space Thanks for your work, |
Comment author: @mmottl According to Adam, who filed the initial bug report, turning off address randomization in the kernel makes the problem go away. Though this solution is good enough for us for the while being, it would certainly be helpful if we could find a more general solution. Some applications might be so sensitive that people don't want to turn off this important security feature. I am not sure whether this might help, but it seems that Linux has at least some respect for the "start" argument to mmap, i.e. takes it as a hint where to place the mapping. By starting out with "NULL" for the initial mapping and then just storing the start of the page following the current mapping in a global variable for the next allocation looks like a very simple thing to try. It may not be a perfect solution, since the kernel is not required to return a mapping at this address, but it may be good enough and does not require a substantial rewrite of the page handling code. |
Comment author: Vladimir Shabanov $ cat /proc/sys/kernel/randomize_va_space $ grep USE_MMAP System is Debian testing, 2.6.21-2-amd64 kernel. native executable, works ok, output is always the same: bytecode executable: Problem disappears after native output with randomize_va_space=0: bytecode output with randomize_va_space=0: |
Comment author: Vladimir Shabanov Forgot the processor: |
Comment author: @mmottl I can confirm now that passing a hint to mmap seems to fix the problem in the OCaml-runtime, though I haven't been able to test yet whether this will generally work well. If you change the function caml_aligned_mmap in byterun/unix.c as follows: char * caml_aligned_mmap (asize_t size, int modulo, void **block) then the problem with exploding page tables seems to go away. In one case it seemed to me that one may have to add more than just two page tables to get nearby address space, but I unfortunately don't have time now to find out when this may be necessary. This is at least a starting point for a cheap solution that may work well enough until a better implementation of page table management is available. |
Comment author: @xavierleroy Markus's suggestion looks like a good temporary workaround. I applied it in the 3.10 release branch. Meanwhile, I'm experimenting with replacing the page table by a hash table, with good results so far. This is candidate for inclusion in the trunk after more testing. |
Comment author: @xavierleroy In CVS trunk, reimplemented the page table as a sparse data structure (hash table). Preliminary tests are OK, both correctness-wise and performance-wise. More testing is welcome. |
Comment author: @xavierleroy The new implementation of page tables in 3.11 seems to work. I'm closing this PR. |
Original bug ID: 4448
Reporter: @xavierleroy
Assigned to: @xavierleroy
Status: closed (set by @xavierleroy on 2009-02-01T08:38:06Z)
Resolution: fixed
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Monitored by: "Vladimir Shabanov" adamc toots till @Chris00 smimram @oandrieu @yakobowski @alainfrisch @mmottl
Bug description
As reported on the caml-list, some users of 64-bit platforms noticed large page tables being allocated, e.g. "Growing page table to 104640820 entries". The goal of this PR is to better understand the situations where this occurs. Please add notes to this PR describing in particular:
Your platform: processor, OS version (esp. which Linux distro), kernel version.
The output of the following command:
grep USE_MMAP
ocamlc -where
/caml/config.hThe text was updated successfully, but these errors were encountered: