Skip to content
Snippets Groups Projects
Commit 3fb3892b authored by Florian Fischer's avatar Florian Fischer
Browse files

[IoContext] don't manually invalidate broken chains after linux 5.15

parent f40fd830
No related branches found
No related tags found
1 merge request!248Deprecate IoContext submit broken chain logic
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "emper-version.h" #include "emper-version.h"
#include "emper.hpp" #include "emper.hpp"
#include "io/Future.hpp" #include "io/Future.hpp"
#include "lib/LinuxVersion.hpp"
void async(Fiber* fiber) { void async(Fiber* fiber) {
assert(fiber != nullptr); assert(fiber != nullptr);
...@@ -44,6 +45,8 @@ void async(const Fiber::fiber_fun0_t& function, workeraffinity_t* affinity) { ...@@ -44,6 +45,8 @@ void async(const Fiber::fiber_fun0_t& function, workeraffinity_t* affinity) {
namespace emper { namespace emper {
bool IO_MUST_INVALIDATE_BROKEN_CHAIN = EMPER_LINUX_LT("5.15.0");
auto getFullVersion() -> std::string { return EMPER_FULL_VERSION; } auto getFullVersion() -> std::string { return EMPER_FULL_VERSION; }
static void ensure_no_current_runtime() { static void ensure_no_current_runtime() {
......
...@@ -130,6 +130,16 @@ static const bool IO_URING_SQPOLL = ...@@ -130,6 +130,16 @@ static const bool IO_URING_SQPOLL =
#endif #endif
; ;
// Initialize this bool in Emper.cpp because it needs code evaluation
// (LinuxVersion::compare) during runtime.
// Using a static variable here means EACH object file including this header has to
// evaluate the needed code during library initialization.
// An extern variable results in a single execution during initialization of the
// Emper.cpp object.
// This also has the advantage that the probability we crash because printing
// warnings during the comparison use not yet initialized components is reduced.
extern bool IO_MUST_INVALIDATE_BROKEN_CHAIN;
static const bool IO_URING_SHARED_WQ = static const bool IO_URING_SHARED_WQ =
#ifdef EMPER_IO_URING_SHARED_WQ #ifdef EMPER_IO_URING_SHARED_WQ
true true
......
...@@ -197,7 +197,14 @@ void IoContext::submitAndWait(Future &future, unsigned wait_nr) { ...@@ -197,7 +197,14 @@ void IoContext::submitAndWait(Future &future, unsigned wait_nr) {
// broken chains. This means that all sqes in a chain except the broken one will // broken chains. This means that all sqes in a chain except the broken one will
// result in cqes with result -ECANCELD and the invalid one will // result in cqes with result -ECANCELD and the invalid one will
// generate a cqe with the appropriate error code // generate a cqe with the appropriate error code
if (unlikely(static_cast<unsigned>(submitted) < prepared)) {
// When 5.15 is released with
// https://lore.kernel.org/io-uring/180ec124-79b1-2274-4570-9b0d6620d512@linux.alibaba.com/T/#t
// the kernel will consume the whole broken chain and we
// don't need to manually invalidate not submitted sqes.
// This allows SQPOLL to work for invalid chains.
if (unlikely(static_cast<unsigned>(submitted) < prepared) &&
emper::IO_MUST_INVALIDATE_BROKEN_CHAIN) {
cancelUnsubmittedChainParts<callerEnvironment>(future); cancelUnsubmittedChainParts<callerEnvironment>(future);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment