Skip site navigation (1)Skip section navigation (2)
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/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D230160

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` i=
s 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 =3D mmap(0, 4096, PROT_READ | PROT_WRITE, MAP_ANON |
MAP_PRIVATE, -1, 0);
        assert(page !=3D MAP_FAILED);
        page[0] =3D 42;
        assert(page[0] =3D=3D 42);
        madvise(page, 4096, MADV_DONTNEED);
        assert(page[0] =3D=3D 0);
}
```

This `madvise` flag is commonly used by memory allocators to guarantee zero=
ed
memory for reuse.  It would be nice if we had a `MADV_ZERO` that did the sa=
me
thing as Linux's `MADV_DONTNEED` for shared memory as well as anonymous mem=
ory.

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-230160-4077-7YtbmPW8p2>