Skip to content

Commit

Permalink
dax: don't use set_huge_zero_page()
Browse files Browse the repository at this point in the history
This is another place where DAX assumed that pgtable_t was a pointer.
Open code the important parts of set_huge_zero_page() in DAX and make
set_huge_zero_page() static again.

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Kirill A. Shutemov authored and Linus Torvalds committed Sep 8, 2015
1 parent da14676 commit d295e34
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
18 changes: 12 additions & 6 deletions fs/dax.c
Original file line number Diff line number Diff line change
Expand Up @@ -572,18 +572,24 @@ int __dax_pmd_fault(struct vm_area_struct *vma, unsigned long address,
unmap_mapping_range(mapping, pgoff << PAGE_SHIFT, PMD_SIZE, 0);

if (!write && !buffer_mapped(&bh) && buffer_uptodate(&bh)) {
bool set;
spinlock_t *ptl;
struct mm_struct *mm = vma->vm_mm;
pmd_t entry;
struct page *zero_page = get_huge_zero_page();

if (unlikely(!zero_page))
goto fallback;

ptl = pmd_lock(mm, pmd);
set = set_huge_zero_page(NULL, mm, vma, pmd_addr, pmd,
zero_page);
spin_unlock(ptl);
ptl = pmd_lock(vma->vm_mm, pmd);
if (!pmd_none(*pmd)) {
spin_unlock(ptl);
goto fallback;
}

entry = mk_pmd(zero_page, vma->vm_page_prot);
entry = pmd_mkhuge(entry);
set_pmd_at(vma->vm_mm, pmd_addr, pmd, entry);
result = VM_FAULT_NOPAGE;
spin_unlock(ptl);
} else {
sector = bh.b_blocknr << (blkbits - 9);
length = bdev_direct_access(bh.b_bdev, sector, &kaddr, &pfn,
Expand Down
3 changes: 0 additions & 3 deletions include/linux/huge_mm.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,6 @@ static inline bool is_huge_zero_pmd(pmd_t pmd)
}

struct page *get_huge_zero_page(void);
bool set_huge_zero_page(pgtable_t pgtable, struct mm_struct *mm,
struct vm_area_struct *vma, unsigned long haddr,
pmd_t *pmd, struct page *zero_page);

#else /* CONFIG_TRANSPARENT_HUGEPAGE */
#define HPAGE_PMD_SHIFT ({ BUILD_BUG(); 0; })
Expand Down
2 changes: 1 addition & 1 deletion mm/huge_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ static inline gfp_t alloc_hugepage_gfpmask(int defrag, gfp_t extra_gfp)
}

/* Caller must hold page table lock. */
bool set_huge_zero_page(pgtable_t pgtable, struct mm_struct *mm,
static bool set_huge_zero_page(pgtable_t pgtable, struct mm_struct *mm,
struct vm_area_struct *vma, unsigned long haddr, pmd_t *pmd,
struct page *zero_page)
{
Expand Down

0 comments on commit d295e34

Please sign in to comment.