Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

thp: don't allow transparent hugepage support without PSE

Archs implementing Transparent Hugepage Support must implement a function
called has_transparent_hugepage to be sure the virtual or physical CPU
supports Transparent Hugepages.

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>

authored by

Andrea Arcangeli and committed by
Linus Torvalds
4b7167b9 94fcc585

+13
+5
arch/x86/include/asm/pgtable.h
··· 160 160 { 161 161 return pmd_val(pmd) & _PAGE_PSE; 162 162 } 163 + 164 + static inline int has_transparent_hugepage(void) 165 + { 166 + return cpu_has_pse; 167 + } 163 168 #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ 164 169 165 170 static inline pte_t pte_set_flags(pte_t pte, pteval_t set)
+8
mm/huge_memory.c
··· 487 487 int err; 488 488 #ifdef CONFIG_SYSFS 489 489 static struct kobject *hugepage_kobj; 490 + #endif 490 491 492 + err = -EINVAL; 493 + if (!has_transparent_hugepage()) { 494 + transparent_hugepage_flags = 0; 495 + goto out; 496 + } 497 + 498 + #ifdef CONFIG_SYSFS 491 499 err = -ENOMEM; 492 500 hugepage_kobj = kobject_create_and_add("transparent_hugepage", mm_kobj); 493 501 if (unlikely(!hugepage_kobj)) {