From: Christoph Lameter Subject: [HUGE] make_huge_pte: Take pfn parameter instead of struct page The huge VM_PFNMAP functionality requires that we can install a pte from a pfn. struct page references can be easily converted to pfns. So switch the parameter to be a pfn and convert on the callsites from pages to pfns. Signed-off-by: Christoph Lameter Index: linux-2.6/mm/hugetlb.c =================================================================== --- linux-2.6.orig/mm/hugetlb.c 2008-04-10 13:05:40.000000000 -0700 +++ linux-2.6/mm/hugetlb.c 2008-04-10 13:06:32.000000000 -0700 @@ -709,17 +709,16 @@ .fault = hugetlb_vm_op_fault, }; -static pte_t make_huge_pte(struct vm_area_struct *vma, struct page *page, +static pte_t make_huge_pte(struct vm_area_struct *vma, unsigned long pfn, int writable) { - pte_t entry; + pte_t entry = pfn_pte(pfn, vma->vm_page_prot); + + if (writable) + entry = pte_mkwrite(pte_mkdirty(entry)); + else + entry = pte_wrprotect(entry); - if (writable) { - entry = - pte_mkwrite(pte_mkdirty(mk_pte(page, vma->vm_page_prot))); - } else { - entry = pte_wrprotect(mk_pte(page, vma->vm_page_prot)); - } entry = pte_mkyoung(entry); entry = pte_mkhuge(entry); @@ -876,7 +875,7 @@ if (likely(pte_same(*ptep, pte))) { /* Break COW */ set_huge_pte_at(mm, address, ptep, - make_huge_pte(vma, new_page, 1)); + make_huge_pte(vma, page_to_pfn(new_page), 1)); /* Make the old page be freed below */ new_page = old_page; } @@ -945,8 +944,8 @@ if (!pte_none(*ptep)) goto backout; - new_pte = make_huge_pte(vma, page, ((vma->vm_flags & VM_WRITE) - && (vma->vm_flags & VM_SHARED))); + new_pte = make_huge_pte(vma, page_to_pfn(page), + ((vma->vm_flags & VM_WRITE) && (vma->vm_flags & VM_SHARED))); set_huge_pte_at(mm, address, ptep, new_pte); if (write_access && !(vma->vm_flags & VM_SHARED)) {