From 7d341a2e17659f3856661674e5dbcf273f26a665 Mon Sep 17 00:00:00 2001 From: Florian Fischer <florian.fischer@muhq.space> Date: Sat, 26 Feb 2022 12:45:22 +0100 Subject: [PATCH] fix build of test waitfree io-stealing --- .gitlab-ci.yml | 11 +++++++++++ emper/io/IoContext.cpp | 12 ++++++++++-- emper/io/IoContext.hpp | 2 +- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d4f0cf39..3591f70c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -159,6 +159,10 @@ clang-tidy: variables: EMPER_IO_LOCKLESS_CQ: 'true' +.emper-io-waitfree-stealing: + variables: + EMPER_IO_WAITFREE_STEALING: 'true' + .default-library-static: variables: EMPER_DEFAULT_LIBRARY: 'static' @@ -435,6 +439,13 @@ test-lockless-io-stealing: - .emper-io-stealing - .emper-lockless-cq +test-waitfree-io-stealing: + extends: + - .test + - .emper-io-stealing + - .emper-lockless-cq + - .emper-io-waitfree-stealing + test-io-stealing-pipe-no-completer: extends: - .test diff --git a/emper/io/IoContext.cpp b/emper/io/IoContext.cpp index b183abf0..10ecca47 100644 --- a/emper/io/IoContext.cpp +++ b/emper/io/IoContext.cpp @@ -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) diff --git a/emper/io/IoContext.hpp b/emper/io/IoContext.hpp index a877a748..2a0ba954 100644 --- a/emper/io/IoContext.hpp +++ b/emper/io/IoContext.hpp @@ -270,7 +270,7 @@ class IoContext : public Logger<LogSubsystem::IO> { } template <CallerEnvironment callerEnvironment> - [[nodiscard]] auto tryReapCompletionWaitFree(Fiber *continuation) -> emper::StealingResult; + [[nodiscard]] auto tryReapCompletionWaitFree(Fiber **continuation) -> emper::StealingResult; template <CallerEnvironment callerEnvironment, unsigned toReap> [[nodiscard]] auto reapCompletionsLockless(Fiber **continuations) -> unsigned; -- GitLab