Skip to contentSkip to conversation

mm: enforce THP for VM_NOHUGEPAGE dax mappings

PATCH In review Yang Shi 2 participants 3 messages Sep 28, 2018

Subsystems (2)
lore
Share & tools
lore

Yang Shi

author
#0 lore raw

PATCH 1/1 mm: enforce THP for VM_NOHUGEPAGE dax mappings

commit baabda261424517110ea98c6651f632ebf2561e3 ("mm: always enable thp for dax mappings") says madvise hguepage policy makes less sense for dax, and force enabling thp for dax mappings in all cases, even though THP is set to "never".

However, transparent_hugepage_enabled() may return false if VM_NOHUGEPAGE is set even though the mapping is dax.

So, move is_vma_dax() check to the very beginning to enforce THP for dax mappings in all cases.

Cc Dan Williams <[email protected]>
Cc Jan Kara <[email protected]>
Cc Ross Zwisler <[email protected]>
Cc "Kirill A. Shutemov" <[email protected]>

---
I didn't find anyone mention the check should be before VM_NOHUGEPAGE in the review for Dan's original patch. And, that patch commit log states clearly that THP for dax mapping for all cases even though THP is never. So, I'm supposed it should behave in this way.

 include/linux/huge_mm.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
include/linux/huge_mm.h +3 -3
index 99c19b0..b2ad305 100644
@@ -95,6 +95,9 @@ extern ssize_t single_hugepage_flag_show(struct kobject *kobj,
 
 static inline bool transparent_hugepage_enabled(struct vm_area_struct *vma)
 {
+	if (vma_is_dax(vma))
+		return true;
+
 	if (vma->vm_flags & VM_NOHUGEPAGE)
 		return false;
 
@@ -107,9 +110,6 @@ static inline bool transparent_hugepage_enabled(struct vm_area_struct *vma)
 	if (transparent_hugepage_flags & (1 << TRANSPARENT_HUGEPAGE_FLAG))
 		return true;
 
-	if (vma_is_dax(vma))
-		return true;
-
 	if (transparent_hugepage_flags &
 				(1 << TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG))
 		return !!(vma->vm_flags & VM_HUGEPAGE);
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 17 lines · On Fri, Sep 28, 2018 at 3:34 PM <[email protected]> wrote:

commit baabda261424517110ea98c6651f632ebf2561e3 ("mm: always enable thp for dax mappings") says madvise hguepage policy makes less sense for dax, and force enabling thp for dax mappings in all cases, even though THP is set to "never".

However, transparent_hugepage_enabled() may return false if VM_NOHUGEPAGE is set even though the mapping is dax.

So, move is_vma_dax() check to the very beginning to enforce THP for dax mappings in all cases.

Cc Dan Williams <[email protected]>
Cc Jan Kara <[email protected]>
Cc Ross Zwisler <[email protected]>
Cc "Kirill A. Shutemov" <[email protected]>
Quoted 5 lines

---
I didn't find anyone mention the check should be before VM_NOHUGEPAGE in the review for Dan's original patch. And, that patch commit log states clearly that THP for dax mapping for all cases even though THP is never. So, I'm supposed it should behave in this way.

No, if someone explicitly does MADV_NOHUGEPAGE then the kernel should honor that, even if the mapping is DAX.

author
#2 lore raw
Quoted 22 lines · Dan Williams
Quoted 16 lines · On Fri, Sep 28, 2018 at 3:34 PM <[email protected]> wrote:

commit baabda261424517110ea98c6651f632ebf2561e3 ("mm: always enable thp for dax mappings") says madvise hguepage policy makes less sense for dax, and force enabling thp for dax mappings in all cases, even though THP is set to "never".

However, transparent_hugepage_enabled() may return false if VM_NOHUGEPAGE is set even though the mapping is dax.

So, move is_vma_dax() check to the very beginning to enforce THP for dax mappings in all cases.

Cc Dan Williams <[email protected]>
Cc Jan Kara <[email protected]>
Cc Ross Zwisler <[email protected]>
Cc "Kirill A. Shutemov" <[email protected]>
Quoted 5 lines

---
I didn't find anyone mention the check should be before VM_NOHUGEPAGE in the review for Dan's original patch. And, that patch commit log states clearly that THP for dax mapping for all cases even though THP is never. So, I'm supposed it should behave in this way.

Quoted 2 lines

No, if someone explicitly does MADV_NOHUGEPAGE then the kernel should honor that, even if the mapping is DAX.

Thanks for confirming this. Actually, I had the same question before I came up with this patch. "all cases" sounds a little bit misleading.