--- Comment #2 from Mark Johnston <[hidden email]> ---
Yes, we should probably just extend our madvise(2) to implement Linux's
MADV_DONTNEED. Some care is needed, as we currently assume that madvise(2) is
advisory and so may be ignored for pages in some transient busy state.
However, we cannot correctly do this when implementing Linux MADV_DONTNEED for
private anonymous memory.
I don't really like the idea of having a generic MADV_ZERO. First, Linux
MADV_DONTNEED only "zeroes" the page if it belongs to a private mapping. Pages
belonging to shared mappings should be handled the same way as FreeBSD's
MADV_DONTNEED, from my reading of the man page. So that name would be
misleading. Second, I think it's pretty widely agreed that Linux's
implementation choice here is a historical mistake. We should emulate it, but
I don't think it makes much sense to do so in a generic fashion. I'd just add
an undocumented MADV_DONTNEED_LINUX.