Commit 5af17ef1 authored by Altan Alpay's avatar Altan Alpay Committed by Jordan DeLong

AsyncIO::initializeContext() should provide more debug output when io_queue_init fails

Summary: It would be good idea to provide more information if the io_queue_init() failed due to resource allocation.

Test Plan:
Run standart tests + manual testing
1. fbconfig -r folly/experimental/ && fbmake runtests
2. Ask a capacity larger than aio_max_nr and check failure messages

Reviewed By: agartrell@fb.com

FB internal diff: D965260
parent 6e442037
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <cerrno> #include <cerrno>
#include <stdexcept> #include <stdexcept>
#include <string> #include <string>
#include <fstream>
#include <boost/intrusive/parent_from_member.hpp> #include <boost/intrusive/parent_from_member.hpp>
#include <glog/logging.h> #include <glog/logging.h>
...@@ -139,6 +140,22 @@ void AsyncIO::initializeContext() { ...@@ -139,6 +140,22 @@ void AsyncIO::initializeContext() {
if (!ctxSet_.load(std::memory_order_relaxed)) { if (!ctxSet_.load(std::memory_order_relaxed)) {
int rc = io_queue_init(capacity_, &ctx_); int rc = io_queue_init(capacity_, &ctx_);
// returns negative errno // returns negative errno
if (rc == -EAGAIN) {
long aio_nr, aio_max;
std::unique_ptr<FILE, int(*)(FILE*)>
fp(fopen("/proc/sys/fs/aio-nr", "r"), fclose);
PCHECK(fp);
CHECK_EQ(fscanf(fp.get(), "%ld", &aio_nr), 1);
std::unique_ptr<FILE, int(*)(FILE*)>
aio_max_fp(fopen("/proc/sys/fs/aio-max-nr", "r"), fclose);
PCHECK(aio_max_fp);
CHECK_EQ(fscanf(aio_max_fp.get(), "%ld", &aio_max), 1);
LOG(ERROR) << "No resources for requested capacity of " << capacity_;
LOG(ERROR) << "aio_nr " << aio_nr << ", aio_max_nr " << aio_max;
}
checkKernelError(rc, "AsyncIO: io_queue_init failed"); checkKernelError(rc, "AsyncIO: io_queue_init failed");
DCHECK(ctx_); DCHECK(ctx_);
ctxSet_.store(true, std::memory_order_release); ctxSet_.store(true, std::memory_order_release);
......
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