2.6.16 hugetlbfs problem

From: Mark Rustad
Date: Wed Mar 22 2006 - 17:07:43 EST


Folks,

I seem to be having trouble using hugetlbfs with kernel 2.6.16. I have a small test program that worked with 2.6.16-rc5, but fails with 2.6.16-rc6 or the release. The program is below. Given a path to a file on a hugetlbfs, it opens/creates the file, mmaps it and tries to access the first word. On 2.6.16-rc5, it works. On 2.6.16, it hangs page-faulting until it is killed.

#include <stdint.h>
#include <unistd.h>
#include <sys/types.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>


int main(int argc, char *argv[])
{
unsigned len = 4 * 1024 * 1024;
void *vaddr = (void *)0x48000000;
int hfd;
void *p;
int *ip;

if (!argc || !argv[1] || !argv[1][0]) {
fprintf(stderr, "Missing argument\n");
return 1;
}
hfd = open(argv[1], O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
if (hfd < 0) {
perror("open");
return 1;
}
p = mmap(vaddr, len, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED,
hfd, 0);
if (p == MAP_FAILED) {
perror("mmap");
fprintf(stderr, "mmap failed at %p\n", vaddr);
return 1;
}
ip = p;
*ip = 0; // This loops on page faults
close(hfd);
printf("Size %d in file %s\n", len, argv[1]);

return 0;
}

Any ideas?

--
Mark Rustad, MRustad@xxxxxxx

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/