Skip to contentSkip to conversation

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

PATCH In review Stefano Stabellini 3 participants 3 messages Sep 30, 2013 – Oct 3, 2013

lore
Share & tools
lore
#0 lore raw

PATCH v2 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.

Changes in v2:
- check that the slot which we are about to reuse is valid.

---
 xen/arch/arm/mm.c |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)
xen/arch/arm/mm.c +10 -7
index 44ec0e3..21e20fa 100644
@@ -232,7 +232,15 @@ 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 &&
+             map[slot].pt.valid )
+        {
+            /* 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 +248,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
Acked-by on v2 1/1
#1 lore raw
Quoted 3 lines · Stefano Stabellini

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

Quoted 44 lines

Changes in v2:
- check that the slot which we are about to reuse is valid.

---
 xen/arch/arm/mm.c |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)
xen/arch/arm/mm.c +10 -7
index 44ec0e3..21e20fa 100644
@@ -232,7 +232,15 @@ 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 &&
+             map[slot].pt.valid )
+        {
+            /* 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 +248,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