Skip to content

Commit 8e6bb60

Browse files
Matan-Bavikivity
authored andcommitted
src/core/reactor: introduce reactor::get_backend_name()
reactor_backend_selector determines which reactor backends are available on the system. The selected backend is stored in reactor::_backend, but there is currently no way to query the selected backend type at runtime. Add reactor::get_backend_name(), which exposes the backend name via engine().get_backend_name(). Note: While smp::configure() does log the selected backend using reactor_opts, a runtime getter is useful for user visibility. Signed-off-by: Matan Breizman <mbreizma@redhat.com>
1 parent ed94253 commit 8e6bb60

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

include/seastar/core/reactor.hh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,8 @@ public:
499499
return queue != _io_queues.end() ? queue->second.get() : nullptr;
500500
}
501501

502+
std::string_view get_backend_name() const;
503+
502504
private:
503505
future<> update_bandwidth_for_queues(internal::priority_class pc, uint64_t bandwidth);
504506
void rename_queues(internal::priority_class pc, sstring new_name);

src/core/reactor.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,6 +1118,10 @@ reactor::~reactor() {
11181118
}
11191119
}
11201120

1121+
std::string_view reactor::get_backend_name() const {
1122+
return _backend->get_backend_name();
1123+
}
1124+
11211125
reactor::sched_stats
11221126
reactor::get_sched_stats() const {
11231127
sched_stats ret;

src/core/reactor_backend.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,10 @@ reactor_backend_aio::reactor_backend_aio(reactor& r)
530530
SEASTAR_ASSERT(e == 0);
531531
}
532532

533+
std::string_view reactor_backend_aio::get_backend_name() const {
534+
return "linux-aio";
535+
}
536+
533537
bool reactor_backend_aio::reap_kernel_completions() {
534538
bool did_work = await_events(0, nullptr);
535539
did_work |= _storage_context.reap_completions();
@@ -783,6 +787,10 @@ reactor_backend_epoll::task_quota_timer_thread_fn() {
783787

784788
reactor_backend_epoll::~reactor_backend_epoll() = default;
785789

790+
std::string_view reactor_backend_epoll::get_backend_name() const {
791+
return "epoll";
792+
}
793+
786794
void reactor_backend_epoll::start_tick() {
787795
_task_quota_timer_thread = std::thread(&reactor_backend_epoll::task_quota_timer_thread_fn, this);
788796

@@ -1445,6 +1453,9 @@ class reactor_backend_uring final : public reactor_backend {
14451453
~reactor_backend_uring() {
14461454
::io_uring_queue_exit(&_uring);
14471455
}
1456+
virtual std::string_view get_backend_name() const override {
1457+
return "io_uring";
1458+
}
14481459
virtual bool reap_kernel_completions() override {
14491460
return do_process_kernel_completions();
14501461
}

src/core/reactor_backend.hh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ public:
171171
class reactor_backend {
172172
public:
173173
virtual ~reactor_backend() {};
174+
virtual std::string_view get_backend_name() const = 0;
174175
// The methods below are used to communicate with the kernel.
175176
// reap_kernel_completions() will complete any previous async
176177
// work that is ready to consume.
@@ -252,6 +253,7 @@ public:
252253
explicit reactor_backend_epoll(reactor& r);
253254
virtual ~reactor_backend_epoll() override;
254255

256+
virtual std::string_view get_backend_name() const override;
255257
virtual bool reap_kernel_completions() override;
256258
virtual bool kernel_submit_work() override;
257259
virtual bool kernel_events_can_sleep() const override;
@@ -302,6 +304,7 @@ class reactor_backend_aio : public reactor_backend {
302304
public:
303305
explicit reactor_backend_aio(reactor& r);
304306

307+
virtual std::string_view get_backend_name() const override;
305308
virtual bool reap_kernel_completions() override;
306309
virtual bool kernel_submit_work() override;
307310
virtual bool kernel_events_can_sleep() const override;

0 commit comments

Comments
 (0)