Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion iocore/io_uring/I_IO_URING.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class IOUringContext

void submit();
void service();
void submit_and_wait(int ms);
void submit_and_wait(ink_hrtime delay);

int register_eventfd();

Expand Down
7 changes: 3 additions & 4 deletions iocore/io_uring/io_uring.cc
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,14 @@ IOUringContext::service()
}

void
IOUringContext::submit_and_wait(int ms)
IOUringContext::submit_and_wait(ink_hrtime delay)
{
ink_hrtime t = ink_hrtime_from_msec(ms);
timespec ts = ink_hrtime_to_timespec(t);
timespec ts = ink_hrtime_to_timespec(delay);
__kernel_timespec timeout = {ts.tv_sec, ts.tv_nsec};
io_uring_cqe *cqe = nullptr;

int ret;
if (ms == -1) {
if (delay == -1) {
ret = io_uring_submit(&ring);
} else {
ret = io_uring_submit_and_wait_timeout(&ring, &cqe, 1, &timeout, nullptr);
Expand Down
15 changes: 10 additions & 5 deletions iocore/io_uring/unit_tests/test_diskIO.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#include "I_IO_URING.h"
#include "tscore/ts_file.h"
#include "tscore/ink_hrtime.h"

#include <functional>

Expand Down Expand Up @@ -66,6 +67,10 @@ template <typename F> class FunctionHolderHandler : public IOUringCompletionHand
f(c->res);
}

std::string id() const override {
return "holder";
}

private:
F f;
};
Expand Down Expand Up @@ -136,13 +141,13 @@ TEST_CASE("disk_io", "[io_uring]")
REQUIRE(fd != -1);

io_uring_write(ctx, fd, "hello", 5, [](int result) { REQUIRE(result == 5); });
ctx.submit_and_wait(100);
ctx.submit_and_wait(100*HRTIME_MSECOND);
io_uring_close(ctx, fd, [&fd](int result) {
REQUIRE(result == 0);
fd = -1;
});

ctx.submit_and_wait(100);
ctx.submit_and_wait(100 * HRTIME_MSECOND);

REQUIRE(fd == -1);

Expand All @@ -155,7 +160,7 @@ TEST_CASE("disk_io", "[io_uring]")
REQUIRE("hello"sv == std::string_view(buffer, result));
});

ctx.submit_and_wait(100);
ctx.submit_and_wait(100 * HRTIME_MSECOND);
}

void
Expand Down Expand Up @@ -259,8 +264,8 @@ TEST_CASE("net_io", "[io_uring]")
connected = true;
});

ctx.submit_and_wait(1000);
ctx.submit_and_wait(1 * HRTIME_SECOND);

REQUIRE(server.clients == 1);
REQUIRE(connected);
}
}
2 changes: 1 addition & 1 deletion iocore/net/IOUringNetAccept.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ IOUringNetAccept::acceptLoopEvent(int event, void *ep)
// setup eventfd for activity?

do {
ctx->submit_and_wait(1000);
ctx->submit_and_wait(1*HRTIME_SECOND);
} while (!TSSystemState::is_event_system_shut_down());
Warning("Accept loop stopped!");

Expand Down
2 changes: 1 addition & 1 deletion src/traffic_server/traffic_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2234,7 +2234,7 @@ main(int /* argc ATS_UNUSED */, const char **argv)

while (!TSSystemState::is_event_system_shut_down()) {
#if TS_USE_LINUX_IO_URING == 1
ur->submit_and_wait(1000);
ur->submit_and_wait(1 * HRTIME_SECOND);
#else
sleep(1);
#endif
Expand Down