Skip to content
Snippets Groups Projects

fix lockless io-stealing

Merged Florian Fischer requested to merge aj46ezos/emper:fix-wait-free-io-stealing into master
3 files
+ 23
4
Compare changes
  • Side-by-side
  • Inline
Files
3
+ 10
2
@@ -233,7 +233,7 @@ static constexpr auto LL_WRITE_MEM_ORDER =
: std::memory_order_seq_cst;
template <CallerEnvironment callerEnvironment>
auto IoContext::tryReapCompletionWaitFree(Fiber *continuation) -> emper::StealingResult {
auto IoContext::tryReapCompletionWaitFree(Fiber **continuation) -> emper::StealingResult {
Completion completion;
struct io_uring_cq *cq = &ring.cq;
@@ -270,7 +270,7 @@ auto IoContext::tryReapCompletionWaitFree(Fiber *continuation) -> emper::Stealin
completion.first = cqe->res;
completion.second = cqe_data;
if (!ahead->compare_exchange_weak(head, head + 1, LL_WRITE_MEM_ORDER, LL_READ_MEM_ORDER))
if (!ahead->compare_exchange_strong(head, head + 1, LL_WRITE_MEM_ORDER, LL_READ_MEM_ORDER))
return emper::StealingResult::LostRace;
trackReqsInUring(-1);
@@ -283,6 +283,14 @@ auto IoContext::tryReapCompletionWaitFree(Fiber *continuation) -> emper::Stealin
return emper::StealingResult::Stolen;
}
// show the compiler our template incarnations
template auto IoContext::tryReapCompletionWaitFree<CallerEnvironment::OWNER>(Fiber **continuation)
-> emper::StealingResult;
template auto IoContext::tryReapCompletionWaitFree<CallerEnvironment::EMPER>(Fiber **continuation)
-> emper::StealingResult;
template auto IoContext::tryReapCompletionWaitFree<CallerEnvironment::ANYWHERE>(
Fiber **continuation) -> emper::StealingResult;
template <CallerEnvironment callerEnvironment, unsigned toReap>
auto IoContext::reapCompletionsLockless(Fiber **continuations) -> unsigned {
Completion reapedCompletions[toReap]; // NOLINT(modernize-avoid-c-arrays)
Loading