WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 10/10] xen/mmu: Warn against races.

To: linux-kernel@xxxxxxxxxxxxxxx, jeremy@xxxxxxxx, hpa@xxxxxxxxx
Subject: [Xen-devel] [PATCH 10/10] xen/mmu: Warn against races.
From: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
Date: Tue, 21 Dec 2010 16:37:40 -0500
Cc: Konrad Rzeszutek Wilk <konrad@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxx, Jan Beulich <JBeulich@xxxxxxxxxx>, Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
Delivery-date: Tue, 21 Dec 2010 14:00:13 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <1292967460-15709-1-git-send-email-konrad.wilk@xxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <1292967460-15709-1-git-send-email-konrad.wilk@xxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
The initial bootup code uses set_phys_to_machine quite a lot, and after
bootup it would be the balloon driver. The balloon driver does have
mutex lock so this should not be necessary - but just in case, add
a warning if we do hit this scenario.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
---
 arch/x86/xen/mmu.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index b2b8733..86d3bd3 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -549,13 +549,15 @@ bool __set_phys_to_machine(unsigned long pfn, unsigned 
long mfn)
        idx = p2m_index(pfn);
 
        if (mfn == INVALID_P2M_ENTRY) {
-               /* If it is INVALID, swap over.. */
+               /* Ballon lock should inhibit racing, but just in case.*/
                if (p2m_top[topidx] == p2m_mid_identity) {
-                       p2m_top[topidx] = p2m_mid_missing;
+                       WARN_ON(cmpxchg(&p2m_top[topidx], p2m_mid_identity,
+                               p2m_mid_missing) != p2m_mid_identity);
                        return 1;
                }
                if (p2m_top[topidx][mididx] == p2m_identity) {
-                       p2m_top[topidx][mididx] = p2m_missing;
+                       WARN_ON(cmpxchg(&p2m_top[topidx][mididx], p2m_identity,
+                               p2m_missing) != p2m_identity);
                        return 1;
                }
        }
-- 
1.7.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>