Skip to content

Commit 13ece88

Browse files
aarcange-rhtorvalds
authored andcommitted
thp: transparent hugepage config choice
Allow to choose between the always|madvise default for page faults and khugepaged at config time. madvise guarantees zero risk of higher memory footprint for applications (applications using madvise(MADV_HUGEPAGE) won't risk to use any more memory by backing their virtual regions with hugepages). Initially set the default to N and don't depend on EMBEDDED. Signed-off-by: Andrea Arcangeli <aarcange@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent ce83d21 commit 13ece88

2 files changed

Lines changed: 30 additions & 2 deletions

File tree

‎mm/Kconfig‎

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,8 @@ config NOMMU_INITIAL_TRIM_EXCESS
303303
See Documentation/nommu-mmap.txt for more information.
304304

305305
config TRANSPARENT_HUGEPAGE
306-
bool "Transparent Hugepage Support" if EMBEDDED
306+
bool "Transparent Hugepage Support"
307307
depends on X86 && MMU
308-
default y
309308
help
310309
Transparent Hugepages allows the kernel to use huge pages and
311310
huge tlb transparently to the applications whenever possible.
@@ -316,6 +315,30 @@ config TRANSPARENT_HUGEPAGE
316315

317316
If memory constrained on embedded, you may want to say N.
318317

318+
choice
319+
prompt "Transparent Hugepage Support sysfs defaults"
320+
depends on TRANSPARENT_HUGEPAGE
321+
default TRANSPARENT_HUGEPAGE_ALWAYS
322+
help
323+
Selects the sysfs defaults for Transparent Hugepage Support.
324+
325+
config TRANSPARENT_HUGEPAGE_ALWAYS
326+
bool "always"
327+
help
328+
Enabling Transparent Hugepage always, can increase the
329+
memory footprint of applications without a guaranteed
330+
benefit but it will work automatically for all applications.
331+
332+
config TRANSPARENT_HUGEPAGE_MADVISE
333+
bool "madvise"
334+
help
335+
Enabling Transparent Hugepage madvise, will only provide a
336+
performance improvement benefit to the applications using
337+
madvise(MADV_HUGEPAGE) but it won't risk to increase the
338+
memory footprint of applications without a guaranteed
339+
benefit.
340+
endchoice
341+
319342
#
320343
# UP and nommu archs use km based percpu allocator
321344
#

‎mm/huge_memory.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@
2727
* allocations.
2828
*/
2929
unsigned long transparent_hugepage_flags __read_mostly =
30+
#ifdef CONFIG_TRANSPARENT_HUGEPAGE_ALWAYS
3031
(1<<TRANSPARENT_HUGEPAGE_FLAG)|
32+
#endif
33+
#ifdef CONFIG_TRANSPARENT_HUGEPAGE_MADVISE
34+
(1<<TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG)|
35+
#endif
3136
(1<<TRANSPARENT_HUGEPAGE_DEFRAG_FLAG)|
3237
(1<<TRANSPARENT_HUGEPAGE_DEFRAG_KHUGEPAGED_FLAG);
3338

0 commit comments

Comments
 (0)