/ go Public
runtime: use MADV_FREE on linux as well #23687
FrozenDueToAge help wanted NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
On linux currently sysUnused uses
madvise(MADV_DONTNEED)to signal the kernel that a range of allocated memory contains unneeded data. After a successful call, the range (but not the data it contained before the call to
madvise) is still available but the first access to that range will unconditionally incur a page fault (needed to 0-fill the range).
A potentially faster alternative is
MADV_FREE, available since linux 4.5 (and already used for bsd). The mechanism is very similar, but the page fault will only be incurred if the kernel, between the call to
madviseand the first access, decides to reuse that memory for something else.
Off the top of my head, there are two ways to support both pre-4.5 and 4.5+ kernels:
MADV_FREEfails): this is e.g. what node does
madvise(MADV_FREE)on an allocated but unused range)
The text was updated successfully, but these errors were encountered: