[Bug 230160] linuxulator doesn't implement madvise(MADV_DONTNEED) correctly
bugzilla-noreply at freebsd.org
bugzilla-noreply at freebsd.org
Tue Jan 8 11:15:34 UTC 2019
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=230160
David Chisnall <theraven at FreeBSD.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |theraven at FreeBSD.org
--- Comment #1 from David Chisnall <theraven at 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.
More information about the freebsd-emulation
mailing list