Skip to content

Commit 2484ca9

Browse files
committed
mm: Introduce vma_is_special_huge
For VM_PFNMAP and VM_MIXEDMAP vmas that want to support transhuge pages and -page table entries, introduce vma_is_special_huge() that takes the same codepaths as vma_is_dax(). The use of "special" follows the definition in memory.c, vm_normal_page(): "Special" mappings do not wish to be associated with a "struct page" (either it doesn't exist, or it exists but they don't want to touch it) For PAGE_SIZE pages, "special" is determined per page table entry to be able to deal with COW pages. But since we don't have huge COW pages, we can classify a vma as either "special huge" or "normal huge". Cc: Andrew Morton <[email protected]> Cc: Michal Hocko <[email protected]> Cc: "Matthew Wilcox (Oracle)" <[email protected]> Cc: "Kirill A. Shutemov" <[email protected]> Cc: Ralph Campbell <[email protected]> Cc: "Jérôme Glisse" <[email protected]> Cc: "Christian König" <[email protected]> Cc: Dan Williams <[email protected]> Signed-off-by: Thomas Hellstrom (VMware) <[email protected]> Acked-by: Christian König <[email protected]> Acked-by: Andrew Morton <[email protected]>
1 parent f05a384 commit 2484ca9

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

include/linux/mm.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2867,6 +2867,23 @@ extern long copy_huge_page_from_user(struct page *dst_page,
28672867
const void __user *usr_src,
28682868
unsigned int pages_per_huge_page,
28692869
bool allow_pagefault);
2870+
2871+
/**
2872+
* vma_is_special_huge - Are transhuge page-table entries considered special?
2873+
* @vma: Pointer to the struct vm_area_struct to consider
2874+
*
2875+
* Whether transhuge page-table entries are considered "special" following
2876+
* the definition in vm_normal_page().
2877+
*
2878+
* Return: true if transhuge page-table entries should be considered special,
2879+
* false otherwise.
2880+
*/
2881+
static inline bool vma_is_special_huge(const struct vm_area_struct *vma)
2882+
{
2883+
return vma_is_dax(vma) || (vma->vm_file &&
2884+
(vma->vm_flags & (VM_PFNMAP | VM_MIXEDMAP)));
2885+
}
2886+
28702887
#endif /* CONFIG_TRANSPARENT_HUGEPAGE || CONFIG_HUGETLBFS */
28712888

28722889
#ifdef CONFIG_DEBUG_PAGEALLOC

mm/huge_memory.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1802,7 +1802,7 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma,
18021802
orig_pmd = pmdp_huge_get_and_clear_full(tlb->mm, addr, pmd,
18031803
tlb->fullmm);
18041804
tlb_remove_pmd_tlb_entry(tlb, pmd, addr);
1805-
if (vma_is_dax(vma)) {
1805+
if (vma_is_special_huge(vma)) {
18061806
if (arch_needs_pgtable_deposit())
18071807
zap_deposited_table(tlb->mm, pmd);
18081808
spin_unlock(ptl);
@@ -2066,7 +2066,7 @@ int zap_huge_pud(struct mmu_gather *tlb, struct vm_area_struct *vma,
20662066
*/
20672067
pudp_huge_get_and_clear_full(tlb->mm, addr, pud, tlb->fullmm);
20682068
tlb_remove_pud_tlb_entry(tlb, pud, addr);
2069-
if (vma_is_dax(vma)) {
2069+
if (vma_is_special_huge(vma)) {
20702070
spin_unlock(ptl);
20712071
/* No zero page support yet */
20722072
} else {
@@ -2175,7 +2175,7 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd,
21752175
*/
21762176
if (arch_needs_pgtable_deposit())
21772177
zap_deposited_table(mm, pmd);
2178-
if (vma_is_dax(vma))
2178+
if (vma_is_special_huge(vma))
21792179
return;
21802180
page = pmd_page(_pmd);
21812181
if (!PageDirty(page) && pmd_dirty(_pmd))

0 commit comments

Comments
 (0)