Skip to contentSkip to conversation

x86/p2m: also clear defer_nested_flush on error

PATCH Applied Jan Beulich 4 participants 4 messages Apr 15, 2014 – Apr 24, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/p2m: also clear defer_nested_flush on error

While presumably benign (domain creation ought to fail when P2M setup fails) let's be on the safe side and clear the flag as intended. And actually, the code can be streamlined quite a bit by recognizing that the only difference between the success and error cases is the message printed in each case. With that, a stray spin_unlock() also goes away.

xen/arch/x86/mm/p2m.c +4 -10
@@ -435,18 +435,12 @@ int p2m_alloc_table(struct p2m_domain *p
     p2m->defer_nested_flush = 1;
     rc = p2m_set_entry(p2m, 0, _mfn(INVALID_MFN), PAGE_ORDER_4K,
                        p2m_invalid, p2m->default_access);
-    if ( rc )
-        goto error;
     p2m->defer_nested_flush = 0;
-
-    P2M_PRINTK("p2m table initialised for slot zero\n");
-    p2m_unlock(p2m);
-    return 0;
-
-    spin_unlock(&p2m->domain->page_alloc_lock);
- error:
-    P2M_PRINTK("failed to initialise p2m table for slot zero. rc:%d\n", rc);
     p2m_unlock(p2m);
+    if ( !rc )
+        P2M_PRINTK("p2m table initialised for slot zero\n");
+    else
+        P2M_PRINTK("failed to initialise p2m table for slot zero (%d)\n", rc);
     return rc;
 }
 

x86/p2m: also clear defer_nested_flush on error

While presumably benign (domain creation ought to fail when P2M setup fails) let's be on the safe side and clear the flag as intended. And actually, the code can be streamlined quite a bit by recognizing that the only difference between the success and error cases is the message printed in each case. With that, a stray spin_unlock() also goes away.

xen/arch/x86/mm/p2m.c +4 -10
@@ -435,18 +435,12 @@ int p2m_alloc_table(struct p2m_domain *p
     p2m->defer_nested_flush = 1;
     rc = p2m_set_entry(p2m, 0, _mfn(INVALID_MFN), PAGE_ORDER_4K,
                        p2m_invalid, p2m->default_access);
-    if ( rc )
-        goto error;
     p2m->defer_nested_flush = 0;
-
-    P2M_PRINTK("p2m table initialised for slot zero\n");
-    p2m_unlock(p2m);
-    return 0;
-
-    spin_unlock(&p2m->domain->page_alloc_lock);
- error:
-    P2M_PRINTK("failed to initialise p2m table for slot zero. rc:%d\n", rc);
     p2m_unlock(p2m);
+    if ( !rc )
+        P2M_PRINTK("p2m table initialised for slot zero\n");
+    else
+        P2M_PRINTK("failed to initialise p2m table for slot zero (%d)\n", rc);
     return rc;
 }
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Jan Beulich

While presumably benign (domain creation ought to fail when P2M setup fails) let's be on the safe side and clear the flag as intended. And actually, the code can be streamlined quite a bit by recognizing that the only difference between the success and error cases is the message printed in each case. With that, a stray spin_unlock() also goes away.

I would like to hope that any optimising compiler would make that dead spin_unlock() disappear, but it is certainly good to properly get rid of it.

Quoted 31 lines
xen/arch/x86/mm/p2m.c +4 -10
@@ -435,18 +435,12 @@ int p2m_alloc_table(struct p2m_domain *p
     p2m->defer_nested_flush = 1;
     rc = p2m_set_entry(p2m, 0, _mfn(INVALID_MFN), PAGE_ORDER_4K,
                        p2m_invalid, p2m->default_access);
-    if ( rc )
-        goto error;
     p2m->defer_nested_flush = 0;
-
-    P2M_PRINTK("p2m table initialised for slot zero\n");
-    p2m_unlock(p2m);
-    return 0;
-
-    spin_unlock(&p2m->domain->page_alloc_lock);
- error:
-    P2M_PRINTK("failed to initialise p2m table for slot zero. rc:%d\n", rc);
     p2m_unlock(p2m);
+    if ( !rc )
+        P2M_PRINTK("p2m table initialised for slot zero\n");
+    else
+        P2M_PRINTK("failed to initialise p2m table for slot zero (%d)\n", rc);
     return rc;
 }
 
Quoted 4 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Reviewed-by on v1 1/1
#2 lore raw
In reply to Jan Beulich
Quoted 7 lines · Jan Beulich

While presumably benign (domain creation ought to fail when P2M setup fails) let's be on the safe side and clear the flag as intended. And actually, the code can be streamlined quite a bit by recognizing that the only difference between the success and error cases is the message printed in each case. With that, a stray spin_unlock() also goes away.

Nice cleanup!

Quoted 25 lines
xen/arch/x86/mm/p2m.c +4 -10
@@ -435,18 +435,12 @@ int p2m_alloc_table(struct p2m_domain *p
     p2m->defer_nested_flush = 1;
     rc = p2m_set_entry(p2m, 0, _mfn(INVALID_MFN), PAGE_ORDER_4K,
                        p2m_invalid, p2m->default_access);
-    if ( rc )
-        goto error;
     p2m->defer_nested_flush = 0;
-
-    P2M_PRINTK("p2m table initialised for slot zero\n");
-    p2m_unlock(p2m);
-    return 0;
-
-    spin_unlock(&p2m->domain->page_alloc_lock);
- error:
-    P2M_PRINTK("failed to initialise p2m table for slot zero. rc:%d\n", rc);
     p2m_unlock(p2m);
+    if ( !rc )
+        P2M_PRINTK("p2m table initialised for slot zero\n");
+    else
+        P2M_PRINTK("failed to initialise p2m table for slot zero (%d)\n", rc);
     return rc;
 }
Applied
#3 lore raw
In reply to Jan Beulich
Quoted 7 lines · Jan Beulich

While presumably benign (domain creation ought to fail when P2M setup fails) let's be on the safe side and clear the flag as intended. And actually, the code can be streamlined quite a bit by recognizing that the only difference between the success and error cases is the message printed in each case. With that, a stray spin_unlock() also goes away.

Applied, thanks.

Tim.