[parisc-linux] unreliable mmap on 720
Jochen Friedrich
jochen@scram.de
Thu, 15 Aug 2002 23:49:24 +0200 (CEST)
Hi,
i recognized that mmap operations seem unreliable on HP720 platform. The
following test program (taken from cyrus imap configure) demonstrates the
problem:
#include <sys/types.h>
#include <sys/mman.h>
#include <fcntl.h>
main()
{
char *base;
int fd = open("testmmap", O_RDWR|O_CREAT|O_TRUNC, 0666);
if (fd == -1)
{
printf("can't open testmmap\n");
exit(1);
}
if (write(fd, "test", 4) != 4)
{
printf("can't write testmmap\n");
exit(1);
}
fsync(fd);
base = mmap((caddr_t)0, 100, PROT_READ, MAP_SHARED
#ifdef MAP_FILE
| MAP_FILE
#endif
#ifdef MAP_VARIABLE
| MAP_VARIABLE
#endif
, fd, 0L);
if (base == (caddr_t)-1)
{
printf("can't mmap testmmap\n");
exit(1);
}
if (strncmp(base, "test", 4) != 0)
{
printf("memory not test\n");
exit(1);
}
if (write(fd, "test", 4) != 4)
{
printf("can't append testmmap\n");
exit(1);
}
fsync(fd);
if (strncmp(base+4, "test", 4) != 0)
{
printf("memory not testtest: %s\n", base);
exit(1);
}
exit(0);
}
# ./testmmap
memory not testtest: test
# ./testmmap
# ./testmmap
# ./testmmap
# ./testmmap
# ./testmmap
# ./testmmap
# ./testmmap
# ./testmmap
# ./testmmap
# ./testmmap
memory not testtest: testtest
This only seems to happen on 720 (i couldn't replicate the bug on a 715
with the same kernel booted up). Things seem to get worse if the load on
the box rises (if the test is done on an idle machine, testmmap works
without problems). Weird...
This is 2.4.19-pa3.
Cheers,
--jochen