Skip to contentSkip to conversation

xen/arm: map_domain_page: reuse slots with avail == 0

PATCH Superseded Stefano Stabellini 2 participants 3 messages Sep 27, 2013 – Sep 30, 2013

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 xen/arch/arm/mm.c |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)
xen/arch/arm/mm.c +8 -7
index 44ec0e3..cbcb769 100644
@@ -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);
Signature · 1 line
1.7.2.5
#1 lore raw
Quoted 12 lines · Stefano Stabellini

If a slot has avail == 0 but still points to the right mfn, reuse it.

---
 xen/arch/arm/mm.c |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)
xen/arch/arm/mm.c +0 -0
index 44ec0e3..cbcb769 100644

xen/arch/arm/mm.c void *map_domain_page(unsigned long mfn) · line 235

Quoted 5 lines
xen/arch/arm/mm.c +1 -1
@@ -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.

#2 lore raw
Quoted 8 lines · Tim Deegan
Quoted 7 lines · Stefano Stabellini

If a slot has avail == 0 but still points to the right mfn, reuse it.

---
 xen/arch/arm/mm.c |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)
Quoted 13 lines

xen/arch/arm/mm.c void *map_domain_page(unsigned long mfn) · line 235

Quoted 10 lines
xen/arch/arm/mm.c +1 -1
index 44ec0e3..cbcb769 100644
@@ -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