Make hugepages work in current git tree
PATCH 1/1 Make hugepages work in current git tree
Somewhere in the move to the paravirt way of doing things hugepages stopped working. This patch fixes hugepages.
--------
arch/x86/include/asm/hugetlb.h +22 -8
@@ -36,16 +36,24 @@ static inline void hugetlb_free_pgd_rangfree_pgd_range (tlb, addr, end, floor, ceiling); } +static inline pte_t huge_ptep_get (pte_t *ptep) +{ +return *ptep; +} +static inline void set_huge_pte_at (struct mm_struct *mm,unsigned long addr,pte_t *ptep,pte_t pte) { -set_pte_at (mm, addr, ptep, pte); +set_pmd ((pmd_t *)ptep,__pmd (pte_val (pte))); }static inline pte_t huge_ptep_get_and_clear (struct mm_struct *mm,unsigned long addr,pte_t *ptep) { -return ptep_get_and_clear (mm, addr, ptep); +pte_t pte =huge_ptep_get (ptep); + +set_huge_pte_at (mm, addr, ptep,__pte (0 )); +return pte; } static inline void huge_ptep_clear_flush(struct vm_area_struct *vma,
@@ -66,19 +74,25 @@ static inline pte_t huge_pte_wrprotect(pstatic inline void huge_ptep_set_wrprotect (struct mm_struct *mm,unsigned long addr,pte_t *ptep) { -ptep_set_wrprotect (mm, addr, ptep); +pte_t pte =huge_ptep_get (ptep); + + pte =pte_wrprotect (pte); +set_huge_pte_at (mm, addr, ptep, pte); }static inline int huge_ptep_set_access_flags (struct vm_area_struct *vma,unsigned long addr,pte_t *ptep,pte_t pte,int dirty) { -return ptep_set_access_flags (vma, addr, ptep, pte, dirty); -} +pte_t oldpte =huge_ptep_get (ptep); +int changed = !pte_same (oldpte, pte); -static inline pte_t huge_ptep_get (pte_t *ptep) -{ -return *ptep; +if (changed && dirty) { +set_huge_pte_at (vma->vm_mm, addr, ptep, pte); +flush_tlb_page (vma, addr); + } + +return changed; }static inline int arch_prepare_hugepage (struct page *page)
Quoted 3 lines · Dave McCracken
Somewhere in the move to the paravirt way of doing things hugepages stopped working. This patch fixes hugepages.
Looks reasonable. I rewrote the commit comment:
Subject: [PATCH] x86/hugetlb: use set_pmd for huge pte operations
On x86, a huge pte is logically a pte, but structurally a pmd. Among other issues, pmds and ptes overload some flags for multiple uses (PAT vs PSE), so it is necessary to know which structural level a pagetable entry is in order interpret it properly.
When huge pages are used within a paravirtualized system, it is therefore appropriate to use the pmd set of function to operate on them, so that the hypervisor can correctly validate the update.
Does this look correct?
J
Quoted 67 lines
Signed-off-by Dave McCracken <[email protected]>--------
arch/x86/include/asm/hugetlb.h +22
-8@@ -36,16 +36,24 @@ static inline void hugetlb_free_pgd_rangfree_pgd_range (tlb, addr, end, floor, ceiling); } +static inline pte_t huge_ptep_get (pte_t *ptep) +{ +return *ptep; +} +static inline void set_huge_pte_at (struct mm_struct *mm,unsigned long addr,pte_t *ptep,pte_t pte) { -set_pte_at (mm, addr, ptep, pte); +set_pmd ((pmd_t *)ptep,__pmd (pte_val (pte))); }static inline pte_t huge_ptep_get_and_clear (struct mm_struct *mm,unsigned long addr,pte_t *ptep) { -return ptep_get_and_clear (mm, addr, ptep); +pte_t pte =huge_ptep_get (ptep); + +set_huge_pte_at (mm, addr, ptep,__pte (0 )); +return pte; } static inline void huge_ptep_clear_flush(struct vm_area_struct *vma,@@ -66,19 +74,25 @@ static inline pte_t huge_pte_wrprotect(pstatic inline void huge_ptep_set_wrprotect (struct mm_struct *mm,unsigned long addr,pte_t *ptep) { -ptep_set_wrprotect (mm, addr, ptep); +pte_t pte =huge_ptep_get (ptep); + + pte =pte_wrprotect (pte); +set_huge_pte_at (mm, addr, ptep, pte); }static inline int huge_ptep_set_access_flags (struct vm_area_struct *vma,unsigned long addr,pte_t *ptep,pte_t pte,int dirty) { -return ptep_set_access_flags (vma, addr, ptep, pte, dirty); -} +pte_t oldpte =huge_ptep_get (ptep); +int changed = !pte_same (oldpte, pte); -static inline pte_t huge_ptep_get (pte_t *ptep) -{ -return *ptep; +if (changed && dirty) { +set_huge_pte_at (vma->vm_mm, addr, ptep, pte); +flush_tlb_page (vma, addr); + } + +return changed; }static inline int arch_prepare_hugepage (struct page *page)
Quoted 9 lines · Jeremy Fitzhardinge
Looks reasonable. I rewrote the commit comment:
Subject: [PATCH] x86/hugetlb: use
set_pmdfor huge pte operationsOn x86, a huge pte is logically a pte, but structurally a pmd. Among other issues, pmds and ptes overload some flags for multiple uses (PAT vs PSE), so it is necessary to know which structural level a pagetable entry is in order interpret it properly.
Quoted 8 lines
When huge pages are used within a paravirtualized system, it is therefore appropriate to use the pmd set of function to operate on them, so that the hypervisor can correctly validate the update.
Signed-off-by Dave McCracken <[email protected]>Signed-off-by Jeremy Fitzhardinge <[email protected]>Does this look correct?
Yes, that's an excellent summary of the issue. Thank you.
Dave McCracken
Quoted 15 lines · Dave McCracken
Quoted 13 lines · Jeremy Fitzhardinge
Looks reasonable. I rewrote the commit comment:
Subject: [PATCH] x86/hugetlb: use
set_pmdfor huge pte operationsOn x86, a huge pte is logically a pte, but structurally a pmd. Among other issues, pmds and ptes overload some flags for multiple uses (PAT vs PSE), so it is necessary to know which structural level a pagetable entry is in order interpret it properly.
When huge pages are used within a paravirtualized system, it is therefore appropriate to use the pmd set of function to operate on them, so that the hypervisor can correctly validate the update.
Quoted 7 lines
Quoted 5 lines
Signed-off-by Dave McCracken <[email protected]>Signed-off-by Jeremy Fitzhardinge <[email protected]>Does this look correct?
Yes, that's an excellent summary of the issue. Thank you.
Have you tested this patch on native as well as under Xen?
J
Quoted 15 lines · Jeremy Fitzhardinge
Quoted 14 lines · Dave McCracken
Quoted 13 lines · Jeremy Fitzhardinge
Looks reasonable. I rewrote the commit comment:
Subject: [PATCH] x86/hugetlb: use
set_pmdfor huge pte operationsOn x86, a huge pte is logically a pte, but structurally a pmd. Among other issues, pmds and ptes overload some flags for multiple uses (PAT vs PSE), so it is necessary to know which structural level a pagetable entry is in order interpret it properly.
When huge pages are used within a paravirtualized system, it is therefore appropriate to use the pmd set of function to operate on them, so that the hypervisor can correctly validate the update.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Signed-off-by Dave McCracken <[email protected]>Signed-off-by Jeremy Fitzhardinge <[email protected]>Does this look correct?
Yes, that's an excellent summary of the issue. Thank you.
Have you tested this patch on native as well as under Xen?
Yes, it works just fine, though see my separate post about building the current git tree without Xen. I'd forgotten I had to patch it to make it build.
Dave McCracken
Sir, attached two patch files for jeremy-kernel 2.6.32.27 and xen-4.0.1.
Current status ,I have the required huge pages' mfn (reserved before dom 0 boots )which we pass on from hypervisor to domain to enable it to use this mfn to make required PTE .
The problem lies that domain is unable to modify the PMD (as mentioned in above conversation) which contains this PTE entry as it lies in guest read-only memory as shown in xen's config.h file.
So,we tried passing this PMD entry in a hypercall to the hypervisor to modify PMD accordingly but while allocation xen crashes.
This is where we are stuck now.
http://xen.1045712.n5.nabble.com/file/n3379235/jeremy2-6-32-27.patch
jeremy2-6-32-27.patch
http://xen.1045712.n5.nabble.com/file/n3379235/xen-patch.patch
xen-patch.patch
Signature · 2 lines
View this message in context: http://xen.1045712.n5.nabble.com/Linux-PATCH-Make-hugepages-work-in-current-git-tree-tp2540492p3379235.html Sent from the Xen - Dev mailing list archive at Nabble.com.