Commit d1403e66 authored by Maged Michael's avatar Maged Michael Committed by Facebook Github Bot

hazptr: Make reclamation in executor behave the same as without executor

Summary: Make the behavior of reclamation using an executor be the same as without an executor, in particular reclamation of the tagged list is skipped if it is found to be locked.

Reviewed By: davidtgoldblatt

Differential Revision: D19325821

fbshipit-source-id: 2eae06b320717aa1122d7cc7afdd4c58791fbfa8
parent 4e7473be
...@@ -305,7 +305,7 @@ class hazptr_domain { ...@@ -305,7 +305,7 @@ class hazptr_domain {
if (std::is_same<Atom<int>, std::atomic<int>>{} && if (std::is_same<Atom<int>, std::atomic<int>>{} &&
this == &default_hazptr_domain<Atom>() && this == &default_hazptr_domain<Atom>() &&
FLAGS_folly_hazptr_use_executor) { FLAGS_folly_hazptr_use_executor) {
invoke_reclamation_in_executor(); invoke_reclamation_in_executor(rlist, lock);
} else { } else {
do_reclamation(rlist, lock); do_reclamation(rlist, lock);
} }
...@@ -612,14 +612,14 @@ class hazptr_domain { ...@@ -612,14 +612,14 @@ class hazptr_domain {
return rec; return rec;
} }
void invoke_reclamation_in_executor() { void invoke_reclamation_in_executor(RetiredList& rlist, bool lock) {
auto fn = exec_fn_.load(std::memory_order_acquire); auto fn = exec_fn_.load(std::memory_order_acquire);
auto ex = fn ? fn() : get_default_executor(); auto ex = fn ? fn() : get_default_executor();
auto backlog = exec_backlog_.fetch_add(1, std::memory_order_relaxed); auto backlog = exec_backlog_.fetch_add(1, std::memory_order_relaxed);
if (ex) { if (ex) {
ex->add([this] { ex->add([this, &rlist, lock] {
exec_backlog_.store(0, std::memory_order_relaxed); exec_backlog_.store(0, std::memory_order_relaxed);
reclamation_by_executor(); do_reclamation(rlist, lock);
}); });
} else { } else {
LOG(INFO) << "Skip asynchronous reclamation by hazptr executor"; LOG(INFO) << "Skip asynchronous reclamation by hazptr executor";
...@@ -629,18 +629,6 @@ class hazptr_domain { ...@@ -629,18 +629,6 @@ class hazptr_domain {
<< " request backlog for hazptr reclamation executora"; << " request backlog for hazptr reclamation executora";
} }
} }
/** reclamation_by_executor */
void reclamation_by_executor() {
uint64_t time = std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::steady_clock::now().time_since_epoch())
.count() +
kSyncTimePeriod;
tagged_sync_time_.store(time, std::memory_order_relaxed);
untagged_sync_time_.store(time, std::memory_order_relaxed);
do_reclamation(tagged_, RetiredList::kAlsoLock);
do_reclamation(untagged_, RetiredList::kDontLock);
}
}; // hazptr_domain }; // hazptr_domain
/** /**
......
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