* [Linux PATCH] Make hugepages work in current git tree
@ 2010-04-28 14:08 Dave McCracken
2010-04-29 19:30 ` Jeremy Fitzhardinge
0 siblings, 1 reply; 6+ messages in thread
From: Dave McCracken @ 2010-04-28 14:08 UTC (permalink / raw)
To: Jeremy Fitzhardinge, Jan Beulich; +Cc: Xen Developers List
Somewhere in the move to the paravirt way of doing things hugepages
stopped working. This patch fixes hugepages.
Signed-off-by: Dave McCracken <dave.mccracken@oracle.com>
--------
--- 2.6-xen/arch/x86/include/asm/hugetlb.h 2009-10-29 17:48:21.000000000 -0500
+++ 2.6-xen-huge/arch/x86/include/asm/hugetlb.h 2010-04-21 09:50:40.000000000 -0500
@@ -36,16 +36,24 @@ static inline void hugetlb_free_pgd_rang
free_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(p
static 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)
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [Linux PATCH] Make hugepages work in current git tree
2010-04-28 14:08 [Linux PATCH] Make hugepages work in current git tree Dave McCracken
@ 2010-04-29 19:30 ` Jeremy Fitzhardinge
2010-04-29 21:43 ` Dave McCracken
0 siblings, 1 reply; 6+ messages in thread
From: Jeremy Fitzhardinge @ 2010-04-29 19:30 UTC (permalink / raw)
To: Dave McCracken; +Cc: Xen Developers List, Jan Beulich
On 04/28/2010 07:08 AM, Dave McCracken wrote:
> 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.
Signed-off-by: Dave McCracken <dave.mccracken@oracle.com>
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Does this look correct?
J
> Signed-off-by: Dave McCracken <dave.mccracken@oracle.com>
>
> --------
>
> --- 2.6-xen/arch/x86/include/asm/hugetlb.h 2009-10-29 17:48:21.000000000 -0500
> +++ 2.6-xen-huge/arch/x86/include/asm/hugetlb.h 2010-04-21 09:50:40.000000000 -0500
> @@ -36,16 +36,24 @@ static inline void hugetlb_free_pgd_rang
> free_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(p
> static 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)
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: Re: [Linux PATCH] Make hugepages work in current git tree
2010-04-29 19:30 ` Jeremy Fitzhardinge
@ 2010-04-29 21:43 ` Dave McCracken
2010-04-29 21:51 ` Jeremy Fitzhardinge
0 siblings, 1 reply; 6+ messages in thread
From: Dave McCracken @ 2010-04-29 21:43 UTC (permalink / raw)
To: xen-devel; +Cc: Jeremy Fitzhardinge, Jan Beulich
On Thursday 29 April 2010, Jeremy Fitzhardinge wrote:
> 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.
>
> Signed-off-by: Dave McCracken <dave.mccracken@oracle.com>
> Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
>
> Does this look correct?
Yes, that's an excellent summary of the issue. Thank you.
Dave McCracken
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Re: [Linux PATCH] Make hugepages work in current git tree
2010-04-29 21:43 ` Dave McCracken
@ 2010-04-29 21:51 ` Jeremy Fitzhardinge
2010-04-30 19:34 ` Dave McCracken
0 siblings, 1 reply; 6+ messages in thread
From: Jeremy Fitzhardinge @ 2010-04-29 21:51 UTC (permalink / raw)
To: Dave McCracken; +Cc: xen-devel, Jan Beulich
On 04/29/2010 02:43 PM, Dave McCracken wrote:
> On Thursday 29 April 2010, Jeremy Fitzhardinge wrote:
>
>> 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.
>>
>> Signed-off-by: Dave McCracken <dave.mccracken@oracle.com>
>> Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
>>
>> 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
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: Re: [Linux PATCH] Make hugepages work in current git tree
2010-04-29 21:51 ` Jeremy Fitzhardinge
@ 2010-04-30 19:34 ` Dave McCracken
2011-02-10 12:51 ` Kaustubh Kabra
0 siblings, 1 reply; 6+ messages in thread
From: Dave McCracken @ 2010-04-30 19:34 UTC (permalink / raw)
To: Jeremy Fitzhardinge; +Cc: xen-devel, Jan Beulich
On Thursday 29 April 2010, Jeremy Fitzhardinge wrote:
> On 04/29/2010 02:43 PM, Dave McCracken wrote:
> > On Thursday 29 April 2010, Jeremy Fitzhardinge wrote:
> >> 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.
> >>
> >> Signed-off-by: Dave McCracken <dave.mccracken@oracle.com>
> >> Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
> >>
> >> 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
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-02-10 12:51 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-28 14:08 [Linux PATCH] Make hugepages work in current git tree Dave McCracken
2010-04-29 19:30 ` Jeremy Fitzhardinge
2010-04-29 21:43 ` Dave McCracken
2010-04-29 21:51 ` Jeremy Fitzhardinge
2010-04-30 19:34 ` Dave McCracken
2011-02-10 12:51 ` Kaustubh Kabra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).