Summary: | arm/sheevaplug fails fsx when mmap operations are enabled | ||
---|---|---|---|
Product: | Base System | Reporter: | Kirk Russell <kirk> |
Component: | arm | Assignee: | freebsd-arm (Nobody) <freebsd-arm> |
Status: | Closed Overcome By Events | ||
Severity: | Affects Only Me | CC: | thj |
Priority: | Normal | ||
Version: | 9.0-CURRENT | ||
Hardware: | Any | ||
OS: | Any |
Description
Kirk Russell
2011-07-15 18:50:08 UTC
The problem still occurs in current (r234281). Interestingly it only seems to occur when using a USB stick. It doesn't happen when using NFS, or a loop-mounted file system (over NFS). The following code frequently (but not always!) triggers the problem as well: #include <stdio.h> #include <string.h> #include <unistd.h> #include <fcntl.h> #include <sys/mman.h> #define FILE_NAME "test.img" /* Also occurs with offset = 0, but not as frequently */ #define OFFSET 4096 int main(int argc, char **argv) { int fd, i; char buff[1024]; char *map; (void)argc; (void)argv; /* Make sure the file doesn't exist when we start */ unlink(FILE_NAME); fd = open(FILE_NAME, O_CREAT | O_RDWR); if (fd < 0) { perror("Failed to open " FILE_NAME); return 1; } /* mmap write (beyond what is currently written) */ for (i = 0; i < 1024; i++) { buff[i] = i % 128; } /* Truncate the file up */ ftruncate(fd, OFFSET + 1024); map = mmap(NULL, 1024, PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, fd, OFFSET); if (map == (char*)-1) { perror("Failed to mmap "); return 1; } memcpy(map, buff, 1024); msync(map, 1024, MS_SYNC); munmap(map, 1024); /* Now read() and check if all bytes are written correctly */ lseek(fd, OFFSET, SEEK_SET); read(fd, buff, 1024); for (i = 0; i < 1024; i++) { if (buff[i] != (i % 128)) printf("After mmap: offset %d is %d, not %d as expected\n", i, buff[i], i % 128); } close(fd); return 0; } This may be related to problem: arm/162159: [panic] USB errors leading to panic on DockStar 9.0-RC1/arm What is the output to the mmap program? --Mark Tinguely. The sample program above has the following output: root@openrd:/mnt# /bin/kp After mmap: offset 32 is 0, not 32 as expected After mmap: offset 33 is 0, not 33 as expected After mmap: offset 34 is 0, not 34 as expected ... After mmap: offset 61 is 0, not 61 as expected After mmap: offset 62 is 0, not 62 as expected After mmap: offset 63 is 0, not 63 as expected After mmap: offset 224 is 0, not 96 as expected After mmap: offset 225 is 0, not 97 as expected ... That's confirmed by hexdump-ing the test.img file afterwards. I'm also able to reproduce the problem described in arm/162159. You're probably right about the relation. The problem looks very similar too: 32-byte sections that are 0 rather than the expected values. Based on a suggestion from Ian Lepore I switched the data cache from write-back to write-through mode. In that case the problem doesn't occur. Ian suggested this might indicate a problem in the busdma cacheline flush code, but unfortunately I'm somewhat out of my depth there. For bugs matching the following criteria: Status: In Progress Changed: (is less than) 2014-06-01 Reset to default assignee and clear in-progress tags. Mail being skipped FreeBSD dropped support for ARMv5 on the 2020/01/02 this commit is a good place to start reading from: https://lists.freebsd.org/pipermail/svn-src-all/2020-January/191927.html |