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-changelog

[Xen-changelog] [xen-unstable] stubdom: make munmap work in batches to f

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] stubdom: make munmap work in batches to fix stack overflow
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 27 Aug 2008 11:23:49 -0700
Delivery-date: Wed, 27 Aug 2008 11:24:14 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1219826844 -3600
# Node ID 846590f850624742ebe98e070b2b4c1a96693eac
# Parent  fa98f03a6bcd571db59548292b6850ef39e4bbc9
stubdom: make munmap work in batches to fix stack overflow

Signed-off-by: Samuel Thibault <samuel.thibault@xxxxxxxxxxxxx>
---
 extras/mini-os/lib/sys.c |   60 +++++++++++++++++++++++++++--------------------
 1 files changed, 35 insertions(+), 25 deletions(-)

diff -r fa98f03a6bcd -r 846590f85062 extras/mini-os/lib/sys.c
--- a/extras/mini-os/lib/sys.c  Wed Aug 27 09:47:08 2008 +0100
+++ b/extras/mini-os/lib/sys.c  Wed Aug 27 09:47:24 2008 +0100
@@ -1143,34 +1143,44 @@ void *mmap(void *start, size_t length, i
     } else ASSERT(0);
 }
 
+#define UNMAP_BATCH ((STACK_SIZE / 2) / sizeof(multicall_entry_t))
 int munmap(void *start, size_t length)
 {
-    int i, n = length / PAGE_SIZE;
-    multicall_entry_t call[n];
-    unsigned char (*data)[PAGE_SIZE] = start;
-    int ret;
+    int total = length / PAGE_SIZE;
     ASSERT(!((unsigned long)start & ~PAGE_MASK));
-    ASSERT(!(length & ~PAGE_MASK));
-
-    for (i = 0; i < n; i++) {
-       call[i].op = __HYPERVISOR_update_va_mapping;
-       call[i].args[0] = (unsigned long) &data[i];
-       call[i].args[1] = 0;
-       call[i].args[2] = 0;
-       call[i].args[3] = UVMF_INVLPG;
-    }
-
-    ret = HYPERVISOR_multicall(call, n);
-    if (ret) {
-       errno = -ret;
-       return -1;
-    }
-
-    for (i = 0; i < n; i++) {
-       if (call[i].result) {
-           errno = call[i].result;
-           return -1;
-       }
+    while (total) {
+        int n = UNMAP_BATCH;
+        if (n > total)
+            n = total;
+        {
+            int i;
+            multicall_entry_t call[n];
+            unsigned char (*data)[PAGE_SIZE] = start;
+            int ret;
+
+            for (i = 0; i < n; i++) {
+                call[i].op = __HYPERVISOR_update_va_mapping;
+                call[i].args[0] = (unsigned long) &data[i];
+                call[i].args[1] = 0;
+                call[i].args[2] = 0;
+                call[i].args[3] = UVMF_INVLPG;
+            }
+
+            ret = HYPERVISOR_multicall(call, n);
+            if (ret) {
+                errno = -ret;
+                return -1;
+            }
+
+            for (i = 0; i < n; i++) {
+                if (call[i].result) {
+                    errno = call[i].result;
+                    return -1;
+                }
+            }
+        }
+        start += n * PAGE_SIZE;
+        total -= n;
     }
     return 0;
 }

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] stubdom: make munmap work in batches to fix stack overflow, Xen patchbot-unstable <=