Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
memory: Force the kernel to enable working HugeTLB allocation
If huge page allocation fails then do one of two things: - Increase sysctl kernel.shmmax if the maximum shared memory allocation size is less than the size of one huge page. (That is a misconfigured kernel from our perspective.) Fixes #366. - Increase sysctl vm.nr_hugepages otherwise to have the kernel reserve a new huge page that we can allocate. (Try this up to three times per allocation, as before.) To change system-wide sysctl values is a fairly presumptuious thing to do. For this reason we now print clear messages about what we are doing: [memory: Enabling huge pages for shm: sysctl kernel.shmmax 1000000 -> 2097152] [memory: Provisioned a huge page: sysctl vm.nr_hugepages 0 -> 1] [memory: Provisioned a huge page: sysctl vm.nr_hugepages 1 -> 2] [memory: Provisioned a huge page: sysctl vm.nr_hugepages 2 -> 3] [memory: Provisioned a huge page: sysctl vm.nr_hugepages 3 -> 4] [memory: Provisioned a huge page: sysctl vm.nr_hugepages 4 -> 5] On balance I feel that it is reasonable that we ask for forgiveness rather than permission on these operations. This is all done with ljsyscall instead of procfs. This is much nicer!
- Loading branch information