From 5af17ef1bca56aa570d383daf78d1185419d76ba Mon Sep 17 00:00:00 2001 From: Altan Alpay Date: Thu, 12 Sep 2013 14:08:01 -0700 Subject: [PATCH] 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 --- folly/experimental/io/AsyncIO.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/folly/experimental/io/AsyncIO.cpp b/folly/experimental/io/AsyncIO.cpp index 83558e83..3ad69a05 100644 --- a/folly/experimental/io/AsyncIO.cpp +++ b/folly/experimental/io/AsyncIO.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -139,6 +140,22 @@ void AsyncIO::initializeContext() { if (!ctxSet_.load(std::memory_order_relaxed)) { int rc = io_queue_init(capacity_, &ctx_); // returns negative errno + if (rc == -EAGAIN) { + long aio_nr, aio_max; + std::unique_ptr + fp(fopen("/proc/sys/fs/aio-nr", "r"), fclose); + PCHECK(fp); + CHECK_EQ(fscanf(fp.get(), "%ld", &aio_nr), 1); + + std::unique_ptr + 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"); DCHECK(ctx_); ctxSet_.store(true, std::memory_order_release); -- 2.34.1