From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH] x86/p2m: also clear defer_nested_flush on error Date: Tue, 15 Apr 2014 15:17:53 +0100 Message-ID: <534D3F91.9070106@citrix.com> References: <534D59DF02000078000090A1@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2797277158064310747==" Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Wa4BT-0002E3-Eo for xen-devel@lists.xenproject.org; Tue, 15 Apr 2014 14:17:59 +0000 In-Reply-To: <534D59DF02000078000090A1@nat28.tlf.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich Cc: xen-devel , Tim Deegan List-Id: xen-devel@lists.xenproject.org --===============2797277158064310747== Content-Type: multipart/alternative; boundary="------------020001050206050707070107" --------------020001050206050707070107 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit On 15/04/14 15:10, Jan Beulich wrote: > 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. > > Signed-off-by: Jan Beulich Reviewed-by: Andrew Cooper 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. > > --- a/xen/arch/x86/mm/p2m.c > +++ b/xen/arch/x86/mm/p2m.c > @@ -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 > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel --------------020001050206050707070107 Content-Type: text/html; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit
On 15/04/14 15:10, Jan Beulich wrote:
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.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

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.


--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -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
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

--------------020001050206050707070107-- --===============2797277158064310747== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --===============2797277158064310747==--