4 ms·
Is MADV_FREE on Linux any better in this regard? It's what the libc allocators tend to use, if I recall correctly.
by LegionMammal978 3y ago
Is MADV_FREE on Linux any better in this regard? It's what the libc allocators tend to use, if I recall correctly.
- vlovich123 3y agoIt would have to be the same problem because there’s no way to free memory without a shootdown AFAIK. As I describe elsewhere, I don’t think there’s any way to free memory to the OS without one as otherwise you can run into race conditions where another process allocating memory gets access to the memory being freed in another process through a stale TLB entry. Here’s a discussion [1] of a hypothetical lazy_munmap option that would initiate the unmap without an immediate shoot down (i.e. the CPUs would lazily evict from the TLB when they notice the request) but no such option exists. It’s also not immediately clear such a hypothetical API could exist on current CPU architectures or if it would require new HW support as I don’t have enough hands-on expertise at that level. Anyway, [1] is an interesting discussion of this idea and the note about huge pages making these even less valuable is interesting to keep in mind. [1] https://news.ycombinator.com/item?id=23216590 https://news.ycombinator.com/item?id=23216590