]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/mini-os.git/commitdiff
minios: Optimize mmap(open("/dev/mem"))
authorKeir Fraser <keir.fraser@citrix.com>
Fri, 23 Oct 2009 08:59:45 +0000 (09:59 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Fri, 23 Oct 2009 08:59:45 +0000 (09:59 +0100)
Set map_frames_ex's stride parameter to 0 and increment to 1 to avoid
building an explicit list of mfns.

Signed-Off-By: Samuel Thibault <samuel.thibault@ens-lyon.org>
lib/sys.c

index 1284f5a7144293f8e490edfbb1687d73e4f6b9a1..6e12be0f4aa8b02512b61ca528a5dd332aceef90 100644 (file)
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -1256,11 +1256,8 @@ void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset
         unsigned long zero = 0;
         return map_frames_ex(&zero, n, 0, 0, 1, DOMID_SELF, 0, 0);
     } else if (files[fd].type == FTYPE_MEM) {
-        int i;
-        unsigned long mfns[n];
-        for (i = 0; i < n; i++)
-            mfns[i] = ((unsigned long) offset + (i * PAGE_SIZE)) >> PAGE_SHIFT;
-        return map_frames_ex(mfns, n, 1, 0, 1, DOMID_IO, 0, _PAGE_PRESENT|_PAGE_RW);
+        unsigned long first_mfn = offset >> PAGE_SHIFT;
+        return map_frames_ex(&first_mfn, n, 0, 1, 1, DOMID_IO, 0, _PAGE_PRESENT|_PAGE_RW);
     } else ASSERT(0);
 }