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

[Xen-users] mmap within domUs

To: xen-users@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-users] mmap within domUs
From: Jure Koren <jure.koren@xxxxxxxxxxx>
Date: Fri, 3 Oct 2008 09:54:49 +0200
Delivery-date: Fri, 03 Oct 2008 00:55:42 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-users-request@lists.xensource.com?subject=help>
List-id: Xen user discussion <xen-users.lists.xensource.com>
List-post: <mailto:xen-users@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-users>, <mailto:xen-users-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-users>, <mailto:xen-users-request@lists.xensource.com?subject=unsubscribe>
Organization: Zemanta
Sender: xen-users-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: KMail/1.9.10
Hello xen-users!

We've been having issues with mmap on several (all we tested to date) of our 
linux guest instances. The short C program that yields correct results on 
normal kernels but fails to actually read the file into memory when run under 
a domU kernel (tested with 2.6.16.33, 2.6.18, 2.6.21.7) is this:

#define _FILE_OFFSET_BITS   64

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>

#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>

int main() {
    int *where;
    int fd;
    struct stat st_buf;
    fd = open("piggy", O_RDONLY);
    fstat(fd, &st_buf);
    where = mmap(NULL, st_buf.st_size, PROT_READ, MAP_SHARED | MAP_POPULATE, 
fd, 0);
    printf("Finished\n");
    while(1) {
        sleep(10);
    }
    munmap(where, st_buf.st_size);
    close(fd);
    return 0;
}

If you gcc -o mmap mmap.c, then create a piggy file of some gigabytes (but 
less than you have available memory, of course) and then run mmap, the file 
will be read from disk into memory and top will show a RES size of piggy file 
size plus some extra kbytes.

If you do the same from within a domU instance, the mmap call will return a 
valid pointer immediately, the VIRT will properly inflate but the RES will 
not and the file will not be read into memory.

While it's possible we're doing something horribly wrong (and if anyone sees 
an obvious error we don't, please point it out), I would like to know if 
anyone else has had trouble with mmap within domU kernels before and if so, 
if and how you have gotten it to work?

Thank you all for your time in advance,

-- 
Jure Koren
Zemanta Ltd, London, Ljubljana
www.zemanta.com

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-users] mmap within domUs, Jure Koren <=