Skip to contentSkip to conversation

thp: handle file COW faults

PATCH New [email protected] 1 participant 1 message Jul 26, 2016

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 96/126 thp: handle file COW faults

From: "Kirill A. Shutemov" <[email protected]>
Subject: thp: handle file COW faults

File COW for THP is handled on pte level: just split the pmd.

It's not clear how benefitial would be allocation of huge pages on COW faults. And it would require some code to make them work.

I think at some point we can consider teaching khugepaged to collapse pages in COW mappings, but allocating huge on fault is probably overkill.

---

 mm/memory.c |    5 +++++
 1 file changed, 5 insertions(+)
mm/memory.c renamed from mm/memory.c~thp-handle-file-cow-faults +5 -0
diff -puN mm/memory.c~thp-handle-file-cow-faults mm/memory.c
@@ -3446,6 +3446,11 @@ static int wp_huge_pmd(struct fault_env
 	if (fe->vma->vm_ops->pmd_fault)
 		return fe->vma->vm_ops->pmd_fault(fe->vma, fe->address, fe->pmd,
 				fe->flags);
+
+	/* COW handled on pte level: split pmd */
+	VM_BUG_ON_VMA(fe->vma->vm_flags & VM_SHARED, fe->vma);
+	split_huge_pmd(fe->vma, fe->pmd, fe->address);
+
 	return VM_FAULT_FALLBACK;
 }
 

_