Skip to content

Commit 4b7167b

Browse files
aagittorvalds
authored andcommitted
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 <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 94fcc58 commit 4b7167b

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

arch/x86/include/asm/pgtable.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,11 @@ static inline int pmd_trans_huge(pmd_t pmd)
160160
{
161161
return pmd_val(pmd) & _PAGE_PSE;
162162
}
163+
164+
static inline int has_transparent_hugepage(void)
165+
{
166+
return cpu_has_pse;
167+
}
163168
#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
164169

165170
static inline pte_t pte_set_flags(pte_t pte, pteval_t set)

mm/huge_memory.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,15 @@ static int __init hugepage_init(void)
487487
int err;
488488
#ifdef CONFIG_SYSFS
489489
static struct kobject *hugepage_kobj;
490+
#endif
490491

492+
err = -EINVAL;
493+
if (!has_transparent_hugepage()) {
494+
transparent_hugepage_flags = 0;
495+
goto out;
496+
}
497+
498+
#ifdef CONFIG_SYSFS
491499
err = -ENOMEM;
492500
hugepage_kobj = kobject_create_and_add("transparent_hugepage", mm_kobj);
493501
if (unlikely(!hugepage_kobj)) {

0 commit comments

Comments
 (0)