}
}
+#ifdef CONFIG_FINEGRAINED_THP
static int thp_pte_alloc_locked(struct mm_struct *mm, pmd_t *pmd)
{
pgtable_t new = pte_alloc_one(mm);
return __pgprot(pmd_val(pfn_pmd(pfn, __pgprot(0))) ^ pmd_val(pmd));
}
+#endif
void __split_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd,
unsigned long address, bool freeze, struct page *page)
}
repeat:
+#ifdef CONFIG_FINEGRAINED_THP
if (pmd_trans_huge(*pmd) && !vm_normal_page_pmd(vma, address, *pmd)) {
struct mm_struct *mm = vma->vm_mm;
unsigned long haddr = address & HPAGE_PMD_MASK;
pmd_pfn(orig_pmd),
thp_pmd_pgprot(orig_pmd));
goto out;
- } else if (pmd_trans_huge(*pmd) && vm_normal_page_pmd(vma, address, *pmd)) {
+ } else
+#endif /* CONFIG_FINEGRAINED_THP */
+ if (pmd_trans_huge(*pmd) && vm_normal_page_pmd(vma, address, *pmd)) {
if (!page) {
page = pmd_page(*pmd);
/*
{
return arch_remap_pte_range(mm, pmd, addr, end, pfn, prot);
}
-#else /* CONFIG_FINEGRAINED_THP */
-static int remap_pte_range(struct mm_struct *mm, pmd_t *pmd,
- unsigned long addr, unsigned long end,
- unsigned long pfn, pgprot_t prot)
-{
- pte_t *pte, *mapped_pte;
- spinlock_t *ptl;
- int err = 0;
- mapped_pte = pte = pte_alloc_map_lock(mm, pmd, addr, &ptl);
- if (!pte)
- return -ENOMEM;
- arch_enter_lazy_mmu_mode();
- do {
- BUG_ON(!pte_none(*pte));
- if (!pfn_modify_allowed(pfn, prot)) {
- err = -EACCES;
- break;
- }
-
- set_pte_at(mm, addr, pte, pte_mkspecial(pfn_pte(pfn, prot)));
- pfn++;
- pte++;
- addr += PAGE_SIZE;
- } while (addr != end);
- arch_leave_lazy_mmu_mode();
- pte_unmap_unlock(mapped_pte, ptl);
- return err;
-}
-#endif /* CONFIG_FINEGRAINED_THP */
-#ifdef CONFIG_TRANSPARENT_HUGEPAGE
static int remap_try_huge_pmd(struct mm_struct *mm, pmd_t *pmd, unsigned long addr,
unsigned long end, unsigned long pfn,
pgprot_t prot)
return ret;
}
-#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
+#else /* CONFIG_FINEGRAINED_THP */
+static int remap_pte_range(struct mm_struct *mm, pmd_t *pmd,
+ unsigned long addr, unsigned long end,
+ unsigned long pfn, pgprot_t prot)
+{
+ pte_t *pte, *mapped_pte;
+ spinlock_t *ptl;
+ int err = 0;
+
+ mapped_pte = pte = pte_alloc_map_lock(mm, pmd, addr, &ptl);
+ if (!pte)
+ return -ENOMEM;
+ arch_enter_lazy_mmu_mode();
+ do {
+ BUG_ON(!pte_none(*pte));
+ if (!pfn_modify_allowed(pfn, prot)) {
+ err = -EACCES;
+ break;
+ }
+
+ set_pte_at(mm, addr, pte, pte_mkspecial(pfn_pte(pfn, prot)));
+ pfn++;
+ pte++;
+ addr += PAGE_SIZE;
+ } while (addr != end);
+ arch_leave_lazy_mmu_mode();
+ pte_unmap_unlock(mapped_pte, ptl);
+ return err;
+}
+#endif /* CONFIG_FINEGRAINED_THP */
static inline int remap_pmd_range(struct mm_struct *mm, pud_t *pud,
unsigned long addr, unsigned long end,
VM_BUG_ON(pmd_trans_huge(*pmd));
do {
next = pmd_addr_end(addr, end);
-
-#ifdef CONFIG_TRANSPARENT_HUGEPAGE
+#ifdef CONFIG_FINEGRAINED_THP
if (remap_try_huge_pmd(mm, pmd, addr, next,
pfn + (addr >> PAGE_SHIFT), prot))
continue;
-#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
+#endif /* CONFIG_FINEGRAINED_THP */
err = remap_pte_range(mm, pmd, addr, next,
pfn + (addr >> PAGE_SHIFT), prot);
if (err)