aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mm/Kconfig28
-rw-r--r--mm/nommu.c2
2 files changed, 29 insertions, 1 deletions
diff --git a/mm/Kconfig b/mm/Kconfig
index 57971d2ab848..c2b57d81e153 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -225,3 +225,31 @@ config HAVE_MLOCKED_PAGE_BIT
225 225
226config MMU_NOTIFIER 226config MMU_NOTIFIER
227 bool 227 bool
228
229config NOMMU_INITIAL_TRIM_EXCESS
230 int "Turn on mmap() excess space trimming before booting"
231 depends on !MMU
232 default 1
233 help
234 The NOMMU mmap() frequently needs to allocate large contiguous chunks
235 of memory on which to store mappings, but it can only ask the system
236 allocator for chunks in 2^N*PAGE_SIZE amounts - which is frequently
237 more than it requires. To deal with this, mmap() is able to trim off
238 the excess and return it to the allocator.
239
240 If trimming is enabled, the excess is trimmed off and returned to the
241 system allocator, which can cause extra fragmentation, particularly
242 if there are a lot of transient processes.
243
244 If trimming is disabled, the excess is kept, but not used, which for
245 long-term mappings means that the space is wasted.
246
247 Trimming can be dynamically controlled through a sysctl option
248 (/proc/sys/vm/nr_trim_pages) which specifies the minimum number of
249 excess pages there must be before trimming should occur, or zero if
250 no trimming is to occur.
251
252 This option specifies the initial value of this option. The default
253 of 1 says that all excess pages should be trimmed.
254
255 See Documentation/nommu-mmap.txt for more information.
diff --git a/mm/nommu.c b/mm/nommu.c
index 809998aa7b50..67cd1a487ee6 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -66,7 +66,7 @@ struct percpu_counter vm_committed_as;
66int sysctl_overcommit_memory = OVERCOMMIT_GUESS; /* heuristic overcommit */ 66int sysctl_overcommit_memory = OVERCOMMIT_GUESS; /* heuristic overcommit */
67int sysctl_overcommit_ratio = 50; /* default is 50% */ 67int sysctl_overcommit_ratio = 50; /* default is 50% */
68int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT; 68int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
69int sysctl_nr_trim_pages = 1; /* page trimming behaviour */ 69int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
70int heap_stack_gap = 0; 70int heap_stack_gap = 0;
71 71
72atomic_long_t mmap_pages_allocated; 72atomic_long_t mmap_pages_allocated;