Stefano Stabellini
2013-Sep-27 17:45 UTC
[PATCH] xen/arm: map_domain_page: reuse slots with avail == 0
If a slot has avail == 0 but still points to the right mfn, reuse it. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> --- xen/arch/arm/mm.c | 15 ++++++++------- 1 files changed, 8 insertions(+), 7 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 44ec0e3..cbcb769 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -232,7 +232,13 @@ void *map_domain_page(unsigned long mfn) i < DOMHEAP_ENTRIES; slot = (slot + 1) % DOMHEAP_ENTRIES, i++ ) { - if ( map[slot].pt.avail == 0 ) + if ( map[slot].pt.avail < 0xf && map[slot].pt.base == slot_mfn ) + { + /* This slot already points to the right place; reuse it */ + map[slot].pt.avail++; + break; + } + else if ( map[slot].pt.avail == 0 ) { /* Commandeer this 2MB slot */ pte = mfn_to_xen_entry(slot_mfn); @@ -240,12 +246,7 @@ void *map_domain_page(unsigned long mfn) write_pte(map + slot, pte); break; } - else if ( map[slot].pt.avail < 0xf && map[slot].pt.base == slot_mfn ) - { - /* This slot already points to the right place; reuse it */ - map[slot].pt.avail++; - break; - } + } /* If the map fills up, the callers have misbehaved. */ BUG_ON(i == DOMHEAP_ENTRIES); -- 1.7.2.5
Tim Deegan
2013-Sep-27 18:24 UTC
Re: [PATCH] xen/arm: map_domain_page: reuse slots with avail == 0
At 18:45 +0100 on 27 Sep (1380307517), Stefano Stabellini wrote:> If a slot has avail == 0 but still points to the right mfn, reuse it. > > Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> > --- > xen/arch/arm/mm.c | 15 ++++++++------- > 1 files changed, 8 insertions(+), 7 deletions(-) > > diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c > index 44ec0e3..cbcb769 100644 > --- a/xen/arch/arm/mm.c > +++ b/xen/arch/arm/mm.c > @@ -232,7 +232,13 @@ void *map_domain_page(unsigned long mfn) > i < DOMHEAP_ENTRIES; > slot = (slot + 1) % DOMHEAP_ENTRIES, i++ ) > { > - if ( map[slot].pt.avail == 0 ) > + if ( map[slot].pt.avail < 0xf && map[slot].pt.base == slot_mfn )This needs to check pt.valid as well, in case this path is ever used to map frame 0. Tim.
Stefano Stabellini
2013-Sep-30 12:04 UTC
Re: [PATCH] xen/arm: map_domain_page: reuse slots with avail == 0
On Fri, 27 Sep 2013, Tim Deegan wrote:> At 18:45 +0100 on 27 Sep (1380307517), Stefano Stabellini wrote: > > If a slot has avail == 0 but still points to the right mfn, reuse it. > > > > Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> > > --- > > xen/arch/arm/mm.c | 15 ++++++++------- > > 1 files changed, 8 insertions(+), 7 deletions(-) > > > > diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c > > index 44ec0e3..cbcb769 100644 > > --- a/xen/arch/arm/mm.c > > +++ b/xen/arch/arm/mm.c > > @@ -232,7 +232,13 @@ void *map_domain_page(unsigned long mfn) > > i < DOMHEAP_ENTRIES; > > slot = (slot + 1) % DOMHEAP_ENTRIES, i++ ) > > { > > - if ( map[slot].pt.avail == 0 ) > > + if ( map[slot].pt.avail < 0xf && map[slot].pt.base == slot_mfn ) > > This needs to check pt.valid as well, in case this path is ever used to > map frame 0.right