make vm_enough_memory more efficient
Subsystems (2)
PATCH 1/1 make vm_enough_memory more efficient
vm_enough_memory seems to call si_meminfo just to get the total RAM, which seems far too expensive. This replaces the comment saying "this is crap" with some code that's less crap.
Not heavily tested (compiles and boots), but seems pretty obvious.
M.
mm/mmap.c +1 -7
@@ -72,7 +72,6 @@ inline void vm_unacct_memory(long pages)int vm_enough_memory (long pages) {unsigned long free, allowed; -struct sysinfo i;atomic_add (pages, &vm_committed_space);
@@ -113,12 +112,7 @@ int vm_enough_memory(long pages)return 0 ; } -/* -* FIXME: need to add arch hooks to get the bits we need -* without this higher overhead crap -*/ -si_meminfo (&i); - allowed = i.totalram * sysctl_overcommit_ratio /100 ; + allowed = totalram_pages * sysctl_overcommit_ratio /100 ; allowed += total_swap_pages;if (atomic_read (&vm_committed_space) < allowed)
Quoted 6 lines · Martin J. Bligh
vm_enough_memoryseems to callsi_meminfojust to get the total RAM, which seems far too expensive. This replaces the comment saying "this is crap" with some code that's less crap.Not heavily tested (compiles and boots), but seems pretty obvious.
Yup, obviously correct.
The really hurtful part of vm_enough_memory() is the call to get_page_cache_size(), which has to go over every CPU's local VM statistics in get_page_state().
But I guess you're running with sysctl_overcommit_memory != 0.
Quoted 7 lines
Quoted 5 lines
vm_enough_memoryseems to callsi_meminfojust to get the total RAM, which seems far too expensive. This replaces the comment saying "this is crap" with some code that's less crap.Not heavily tested (compiles and boots), but seems pretty obvious.
Yup, obviously correct.
Cool.
Quoted 5 lines
The really hurtful part of
vm_enough_memory()is the call toget_page_cache_size(), which has to go over every CPU's local VM statistics inget_page_state().But I guess you're running with
sysctl_overcommit_memory!= 0.
Yup, I manually disable that because it's so expensive. I'll see if I can make the default case cheaper as well.
M.