Skip to content

Commit 1996e12

Browse files
spikehfacebook-github-bot
authored andcommitted
IoUringProvidedBufferRing: madvise MADV_NOHUGEPAGE to workaround kernel v6.9 pin user pages bug
Summary: There is a known issue in v6.9 when pinning huge user pages that causes it to EFAULT. The bug is in an optimisation for handling large folios. The error is propagated back to userspace and throws an exception in IoUringProvidedBufferRing. The bug is fixed in v6.11 and above. But to workaround the issue in v6.9, madvise MADV_NOHUGEPAGE and disable huge pages to avoid the buggy optimisation. Reviewed By: yfeldblum Differential Revision: D72265355 fbshipit-source-id: f3a359e1e470bf1344f41bea9418ed6a42a49a42
1 parent 5764794 commit 1996e12

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

folly/io/async/IoUringProvidedBufferRing.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,10 @@ IoUringProvidedBufferRing::ProvidedBuffersBuffer::ProvidedBuffersBuffer(
7575
ringPtr_ = (struct io_uring_buf_ring*)buffer_;
7676

7777
if (huge_pages) {
78-
int ret = madvise(buffer_, allSize_, MADV_HUGEPAGE);
78+
int ret = ::madvise(buffer_, allSize_, MADV_HUGEPAGE);
7979
PLOG_IF(ERROR, ret) << "cannot enable huge pages";
80+
} else {
81+
::madvise(buffer_, allSize_, MADV_NOHUGEPAGE);
8082
}
8183
}
8284

0 commit comments

Comments
 (0)