[PATCH] D96626: Support: mapped_file_region: Pass MAP_NORESERVE to mmap
Joseph Tremoulet via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 22 08:47:33 PDT 2021
JosephTremoulet added a subscriber: ruiu.
JosephTremoulet added a comment.
In D96626#2640715 <https://reviews.llvm.org/D96626#2640715>, @labath wrote:
> I haven't checked the manpage or the linux kernel behavior, but intuitively, I would expect that a shared mapping should not trigger an OOM, because at any point the kernel can decide to flush the dirty pages to disk (that's actually one technique for creating a per-process swap file).
I tried it out empirically and yes, I'm seeing success for a shared read/write mapping of a very large file without needing MAP_NORESERVE. But the line in the man page saying "In kernels before 2.6, this flag had effect only for private writable mappings" was bugging me, so I went looking through kernel and manpage history. What I found is that shared read/write mappings using "huge TLB pages" will do the reservation check (and this was added in 2.6) and thus can fail without MAP_NORESERVE. And the docs for the huge TLB page feature [1] explain "Huge pages cannot be swapped out under memory pressure." Since we're never passing MAP_HUGETLB in the mapped_file_region code, I believe this case is moot and it's only private read/write mappings that can have the prompt failure.
Perhaps @ruiu has thoughts about the linker's perspective? (though I realize LLD was brought up as just one example of a caller that might care about this flag)
Thanks.
1 - https://www.kernel.org/doc/Documentation/vm/hugetlbpage.txt
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D96626/new/
https://reviews.llvm.org/D96626
More information about the llvm-commits
mailing list