From: Andrea Arcangeli Date: Thu, 13 Jan 2011 23:47:09 +0000 (-0800) Subject: thp: don't allow transparent hugepage support without PSE X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=4b7167b9ff9b7f3f528cbc4c7d02ebd275b9b10c;p=GitHub%2FLineageOS%2Fandroid_kernel_samsung_universal7580.git 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 Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index c48ba055f69..18601c86fab 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -160,6 +160,11 @@ static inline int pmd_trans_huge(pmd_t pmd) { return pmd_val(pmd) & _PAGE_PSE; } + +static inline int has_transparent_hugepage(void) +{ + return cpu_has_pse; +} #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ static inline pte_t pte_set_flags(pte_t pte, pteval_t set) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index b6facc35e89..915809b16ed 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -487,7 +487,15 @@ static int __init hugepage_init(void) int err; #ifdef CONFIG_SYSFS static struct kobject *hugepage_kobj; +#endif + err = -EINVAL; + if (!has_transparent_hugepage()) { + transparent_hugepage_flags = 0; + goto out; + } + +#ifdef CONFIG_SYSFS err = -ENOMEM; hugepage_kobj = kobject_create_and_add("transparent_hugepage", mm_kobj); if (unlikely(!hugepage_kobj)) {