From dd948d15f0720495f751257ffe996c8a98c42934 Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Tue, 19 Dec 2017 21:47:14 +0200 Subject: [PATCH] reactor: switch the syscall worker thread from signals to eventfd Instead of using a signal to wake the reactor thread, use the eventfd which we're already using for smp wakeups. --- include/seastar/core/reactor.hh | 4 ++-- src/core/reactor.cc | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/seastar/core/reactor.hh b/include/seastar/core/reactor.hh index f1459e4c358..f177a0845e3 100644 --- a/include/seastar/core/reactor.hh +++ b/include/seastar/core/reactor.hh @@ -399,15 +399,15 @@ private: }; class thread_pool { + reactor* _reactor; uint64_t _aio_threaded_fallbacks = 0; #ifndef HAVE_OSV syscall_work_queue inter_thread_wq; posix_thread _worker_thread; std::atomic _stopped = { false }; std::atomic _main_thread_idle = { false }; - pthread_t _notify; public: - explicit thread_pool(sstring thread_name); + explicit thread_pool(reactor* r, sstring thread_name); ~thread_pool(); template future submit(Func func) { diff --git a/src/core/reactor.cc b/src/core/reactor.cc index bf15690287c..e5ac1ffda95 100644 --- a/src/core/reactor.cc +++ b/src/core/reactor.cc @@ -555,7 +555,7 @@ reactor::reactor(unsigned id) , _io_context(0) , _reuseport(posix_reuseport_detect()) , _task_quota_timer_thread(&reactor::task_quota_timer_thread_fn, this) - , _thread_pool(seastar::format("syscall-{}", id)) { + , _thread_pool(this, seastar::format("syscall-{}", id)) { _task_queues.push_back(std::make_unique(0, "main", 1000)); _task_queues.push_back(std::make_unique(1, "atexit", 1000)); _at_destroy_tasks = _task_queues.back().get(); @@ -3787,8 +3787,7 @@ void smp_message_queue::start(unsigned cpuid) { /* not yet implemented for OSv. TODO: do the notification like we do class smp. */ #ifndef HAVE_OSV -thread_pool::thread_pool(sstring name) : _worker_thread([this, name] { work(name); }), _notify(pthread_self()) { - engine()._signals.handle_signal(SIGUSR1, [this] { inter_thread_wq.complete(); }); +thread_pool::thread_pool(reactor* r, sstring name) : _reactor(r), _worker_thread([this, name] { work(name); }) { } void thread_pool::work(sstring name) { @@ -3815,7 +3814,8 @@ void thread_pool::work(sstring name) { inter_thread_wq._completed.push(wi); } if (_main_thread_idle.load(std::memory_order_seq_cst)) { - pthread_kill(_notify, SIGUSR1); + uint64_t one = 1; + ::write(_reactor->_notify_eventfd.get(), &one, 8); } } }