Commit d6ed060e authored by Dan Melnic's avatar Dan Melnic Committed by Facebook GitHub Bot

Add flags to set the io_uring mlock rlimit

Summary: Add flags to set the io_uring mlock rlimit

Reviewed By: danobi, kevin-vigor

Differential Revision: D24063687

fbshipit-source-id: be7cdad10797c087a21370ce42811a9752e4f61a
parent 9151f52b
......@@ -24,6 +24,12 @@
#include <glog/logging.h>
static constexpr int64_t kUnlimitedMlock = -1;
DEFINE_int64(
io_uring_mlock_size,
kUnlimitedMlock,
"Maximum bytes to mlock - use 0 for no changes, -1 for unlimited");
namespace {
class SQGroupInfoRegistry {
private:
......@@ -248,6 +254,23 @@ bool IoUringBackend::FdRegistry::free(
IoUringBackend::IoUringBackend(Options options)
: PollIoBackend(options),
fdRegistry_(ioRing_, options.useRegisteredFds ? options.capacity : 0) {
FOLLY_MAYBE_UNUSED static bool sMlockInit = []() {
int ret = 0;
if (FLAGS_io_uring_mlock_size) {
struct rlimit rlim;
if (FLAGS_io_uring_mlock_size == kUnlimitedMlock) {
rlim.rlim_cur = RLIM_INFINITY;
rlim.rlim_max = RLIM_INFINITY;
} else {
rlim.rlim_cur = FLAGS_io_uring_mlock_size;
rlim.rlim_max = FLAGS_io_uring_mlock_size;
}
ret = setrlimit(RLIMIT_MEMLOCK, &rlim); // best effort
}
return ret ? false : true;
}();
::memset(&ioRing_, 0, sizeof(ioRing_));
::memset(&params_, 0, sizeof(params_));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment