thp: don't allow transparent hugepage support without PSE
authorAndrea Arcangeli <aarcange@redhat.com>
Thu, 13 Jan 2011 23:47:09 +0000 (15:47 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 14 Jan 2011 01:32:45 +0000 (17:32 -0800)
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>
arch/x86/include/asm/pgtable.h
mm/huge_memory.c

index c48ba055f69337ac15d1b14ddc2a040f674728cc..18601c86fab18700c6cf7ad9a42b20d4582f769a 100644 (file)
@@ -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)
index b6facc35e8932d8b612e0d78ac48056f4c2aa815..915809b16edfb606989f17e4d6ab534c27751a14 100644 (file)
@@ -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)) {