Skip to content

Commit 830ec3c

Browse files
authored
Merge branch 'main' into fea-tracking-memory-resources
2 parents 550205b + 8d8e1ef commit 830ec3c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

cpp/include/raft/mr/mmap_memory_resource.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,15 @@ class mmap_memory_resource {
9393
auto flags = MAP_ANONYMOUS | MAP_PRIVATE;
9494
void* ptr = nullptr;
9595
if (flags_ & kMmapFileBacked) {
96+
// Note, we don't need the file descriptor to live beyond the call to mmap:
97+
// according to the POSIX specification, mmap retains its own descriptor.
9698
detail::tmpfile_descriptor fd{bytes};
9799
ptr = mmap_verbose(bytes, prot, flags, fileno(fd.value()), 0);
98100
} else {
99101
ptr = mmap_verbose(bytes, prot, flags, -1, 0);
100102
}
101103
if (flags_ & kMmapRequestHugePages) {
104+
// Find a page-aligned subrange of the allocated memory to madvise
102105
auto madvize_start = raft::round_up_safe(reinterpret_cast<uintptr_t>(ptr), kHugePageSize);
103106
auto madvize_end =
104107
raft::round_down_safe(reinterpret_cast<uintptr_t>(ptr) + bytes, kHugePageSize);

0 commit comments

Comments
 (0)