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] Fix one wrong sanity checking in memory add

To: Keir Fraser <keir.fraser@xxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] Fix one wrong sanity checking in memory add
From: "Jiang, Yunhong" <yunhong.jiang@xxxxxxxxx>
Date: Thu, 4 Feb 2010 16:54:56 +0800
Accept-language: en-US
Acceptlanguage: en-US
Cc: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Thu, 04 Feb 2010 01:30:36 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
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>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: Acqld7mNmm1KIGUFQUqQrOxPh+47KA==
Thread-topic: [PATCH] Fix one wrong sanity checking in memory add
Fix one wrong sanity checking in memory add

Current, memory hot-add will fail if the new added memory is bigger than 
current max_pages. This is really a stupid checking, considering user may 
hot-add the biggest address riser card firstly.

This patch fix this issue. It check if all new added memory is un-populated, if 
yes, then it is ok.

Signed-off-by: Jiang, Yunhong <yunhong.jiang@xxxxxxxxx>

diff -r 9b59e50c245a xen/arch/x86/x86_64/mm.c
--- a/xen/arch/x86/x86_64/mm.c  Thu Feb 04 14:56:43 2010 +0800
+++ b/xen/arch/x86/x86_64/mm.c  Thu Feb 04 16:52:14 2010 +0800
@@ -1332,15 +1332,32 @@ int transfer_pages_to_heap(struct mem_ho
 
 int mem_hotadd_check(unsigned long spfn, unsigned long epfn)
 {
-    unsigned long s, e, length;
-
-    if ( (spfn >= epfn) || (spfn < max_page) )
+    unsigned long s, e, length, sidx, eidx;
+
+    if ( (spfn >= epfn) )
+        return 0;
+
+    if (pfn_to_pdx(epfn) > (FRAMETABLE_SIZE / sizeof(*frame_table)))
         return 0;
 
     if ( (spfn | epfn) & ((1UL << PAGETABLE_ORDER) - 1) )
         return 0;
 
     if ( (spfn | epfn) & pfn_hole_mask )
+        return 0;
+
+    /* Make sure the new range is not present now */
+    sidx = ((pfn_to_pdx(spfn) + PDX_GROUP_COUNT - 1)  & ~(PDX_GROUP_COUNT - 1))
+            / PDX_GROUP_COUNT;
+    eidx = (pfn_to_pdx(epfn - 1) & ~(PDX_GROUP_COUNT - 1)) / PDX_GROUP_COUNT;
+    if (sidx >= eidx)
+        return 0;
+
+    s = find_next_zero_bit(pdx_group_valid, eidx, sidx);
+    if ( s > eidx )
+        return 0;
+    e = find_next_bit(pdx_group_valid, eidx, s);
+    if ( e < eidx )
         return 0;
 
     /* Caculate at most required m2p/compat m2p/frametable pages */
@@ -1433,8 +1450,11 @@ int memory_add(unsigned long spfn, unsig
         goto destroy_frametable;
 
     /* Set max_page as setup_m2p_table will use it*/
-    max_page = epfn;
-    max_pdx = pfn_to_pdx(max_page - 1) + 1;
+    if (max_page < epfn)
+    {
+        max_page = epfn;
+        max_pdx = pfn_to_pdx(max_page - 1) + 1;
+    }
     total_pages += epfn - spfn;
 
     set_pdx_range(spfn, epfn);
@@ -1443,7 +1463,7 @@ int memory_add(unsigned long spfn, unsig
     if ( ret )
         goto destroy_m2p;
 
-    for ( i = old_max; i < epfn; i++ )
+    for ( i = spfn; i < epfn; i++ )
         if ( iommu_map_page(dom0, i, i) )
             break;
 


Attachment: check_memory_hotplug.patch
Description: check_memory_hotplug.patch

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] Fix one wrong sanity checking in memory add, Jiang, Yunhong <=