Date: Mon, 3 Nov 2014 06:40:57 +0300 From: rozhuk.im@gmail.com To: <freebsd-hackers@freebsd.org> Subject: pagedaemon + rtorrent = fail Message-ID: <5456f94c.247d700a.771d.ffff869e@mx.google.com>
next in thread | raw e-mail | index | archive | help
[-- Attachment #1 --] Problem described here: https://forums.freebsd.org/threads/heavy-use-rtorrent-ufs-issues.14503/ http://www.bsdportal.ru/viewtopic.php?f=9&t=25194 http://forum.lissyara.su/viewtopic.php?f=53&t=39944 Swap is off: vm.swap_enabled=0 and no swap devices. I wrote a small program to demonstrate the problem. The program creates a file size of 2*"RAM size", map() block size specified, records in each page by byte, unmap(), map() next block... Once a file is written to more "RAM size" OOM kills the program and random demons. In the TOP program does not consume more than the write_block size (32 mb) for recording. Check the parameters before the test run. [-- Attachment #2 --] /* rtorrent + FreeBSD pagedaemon prombel simulator * 2014 Rozhuk Ivan <rozhuk.im@gmail.com> * * compile-command: "clang -Wall -O2 -o testvm testvm.c" */ #include <sys/cdefs.h> #include <sys/types.h> #include <sys/stat.h> // chmod, fchmod, umask #include <sys/uio.h> /* readv, preadv, writev, pwritev */ #include <sys/mman.h> /* mmap, munmap */ #include <errno.h> #include <fcntl.h> /* open, fcntl */ #include <stdio.h> /* snprintf, fprintf */ #include <string.h> /* bcopy, bzero, memcpy, memmove, memset, strnlen, strerror... */ #include <unistd.h> /* close, write, sysconf */ #include <stdlib.h> /* malloc, exit */ #define LOG_ERR(error, descr) \ fprintf(stdout, "fn: %s, line: %i, error: %i - %s, %s\n", \ __FUNCTION__, __LINE__, error, strerror(error), descr); int main(int argc, char *argv[]) { int error = 0, fd; const char *file_name = (const char *)"/testvn.tmp"; off_t mb = (1024 * 1024); /* 1 megabyte. */ off_t file_size = (10 * 1024 * mb); /* Set to x2 RAM size. */ off_t write_size = (32 * mb); /* Write block size. */ off_t i, j, page_size; uint8_t *mem; fd = open(file_name, (O_RDWR | O_CREAT), 0600); if (-1 == fd) { error = errno; LOG_ERR(error, "open()"); goto err_out; } if (0 != flock(fd, LOCK_EX)) { error = errno; LOG_ERR(error, "flock()"); goto err_out; } if (0 != ftruncate(fd, file_size)) { error = errno; LOG_ERR(error, "ftruncate()"); goto err_out; } page_size = sysconf(_SC_PAGE_SIZE); for (i = 0; i < (file_size / write_size); i ++) { mem = mmap(NULL, write_size, (PROT_READ | PROT_WRITE), (MAP_SHARED | MAP_NOCORE), fd, (i * write_size)); if (MAP_FAILED == mem) { error = errno; LOG_ERR(error, "mmap()"); goto err_out; } for (j = 0; j < (write_size / page_size); j ++) { mem[(j * page_size)] = 1; } munmap(mem, file_size); } err_out: close(fd); //unlink(file_name); /* Delete file to free all mem. */ return (error); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5456f94c.247d700a.771d.ffff869e>
