Commit 9683c8db authored by Maged Michael's avatar Maged Michael Committed by Facebook GitHub Bot

hazptr: Add warning for using default inline executor for asynchronous reclamation

Summary:
Add warning about using the default inline executor for asynchronous reclamation, which may lead to deadlock if there are unintended circular dependencies. The use of inline executor is likely due to not calling folly::enable_hazptr_thread_pool_executor at some earlier point (e.g., due to not calling folly::init()).

Also changed some function names for easy identification and fixed typos.

Reviewed By: yfeldblum

Differential Revision: D22536210

fbshipit-source-id: 89e74411a909ec97b03e8ff90f7039ab233c087b
parent 6bc436a6
......@@ -638,6 +638,9 @@ class hazptr_domain {
void invoke_reclamation_in_executor(RetiredList& rlist, bool lock) {
auto fn = exec_fn_.load(std::memory_order_acquire);
auto ex = fn ? fn() : get_default_executor();
if (ex == get_default_executor()) {
hazptr_warning_using_inline_executor();
}
auto backlog = exec_backlog_.fetch_add(1, std::memory_order_relaxed);
if (ex) {
ex->add([this, &rlist, lock] {
......@@ -648,15 +651,27 @@ class hazptr_domain {
LOG(INFO) << "Skip asynchronous reclamation by hazptr executor";
}
if (backlog >= 10) {
warning_executor_backlog(backlog);
hazptr_warning_executor_backlog(backlog);
}
}
FOLLY_NOINLINE void warning_executor_backlog(int backlog) {
FOLLY_EXPORT FOLLY_NOINLINE void hazptr_warning_executor_backlog(
int backlog) {
static std::atomic<uint64_t> warning_count{0};
if ((warning_count++ % 10000) == 0) {
LOG(WARNING) << backlog
<< " request backlog for hazptr reclamation executora";
<< " request backlog for hazptr asynchronous "
"reclamation executor";
}
}
FOLLY_EXPORT FOLLY_NOINLINE void hazptr_warning_using_inline_executor() {
static std::atomic<uint64_t> warning_count{0};
if ((warning_count++ % 10000) == 0) {
LOG(WARNING)
<< "Using the default inline executor for asynchronous reclamation "
"may be susceptible to deadlock if the current thread happens to "
"hold a resource needed by the deleter of a reclaimbale object";
}
}
}; // namespace folly
......
......@@ -113,14 +113,16 @@ class hazptr_tc {
entry_[count_++].fill(hprec);
return true;
}
warning_tc_overflow();
hazptr_warning_tc_overflow();
return false;
}
FOLLY_NOINLINE void warning_tc_overflow() {
FOLLY_EXPORT FOLLY_NOINLINE void hazptr_warning_tc_overflow() {
static std::atomic<uint64_t> warning_count{0};
if ((warning_count++ % 10000) == 0) {
LOG(WARNING) << "Hazptr thread cache overflow " << this;
LOG(WARNING) << "Hazptr thread cache overflow "
<< std::this_thread::get_id();
;
}
}
......
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