Date: Tue, 08 Jan 2019 11:15:32 +0000 From: bugzilla-noreply@freebsd.org To: emulation@FreeBSD.org Subject: [Bug 230160] linuxulator doesn't implement madvise(MADV_DONTNEED) correctly Message-ID: <bug-230160-4077-7YtbmPW8p2@https.bugs.freebsd.org/bugzilla/> In-Reply-To: <bug-230160-4077@https.bugs.freebsd.org/bugzilla/> References: <bug-230160-4077@https.bugs.freebsd.org/bugzilla/>
index | next in thread | previous in thread | raw e-mail
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=230160 David Chisnall <theraven@FreeBSD.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |theraven@FreeBSD.org --- Comment #1 from David Chisnall <theraven@FreeBSD.org> --- It's actually worse than as described. Linux's value for `MADV_DONTNEED` is 8, which corresponds to FreeBSD's `MADV_NOCORE`, so we're not even getting the FreeBSD `MADV_DONTNEED` behaviour. This test program demonstrates the problem. Compiled on Linux, it runs to completion on a real Linux system and dies in the last assert on FreeBSD. ``` #include <sys/mman.h> #include <assert.h> int main(void) { char *page = mmap(0, 4096, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); assert(page != MAP_FAILED); page[0] = 42; assert(page[0] == 42); madvise(page, 4096, MADV_DONTNEED); assert(page[0] == 0); } ``` This `madvise` flag is commonly used by memory allocators to guarantee zeroed memory for reuse. It would be nice if we had a `MADV_ZERO` that did the same thing as Linux's `MADV_DONTNEED` for shared memory as well as anonymous memory. -- You are receiving this mail because: You are the assignee for the bug.help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-230160-4077-7YtbmPW8p2>
