aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/lib')
-rw-r--r--src/core/lib/iomgr/ev_epoll1_linux.c3
-rw-r--r--src/core/lib/iomgr/ev_epoll_thread_pool_linux.c41
-rw-r--r--src/core/lib/iomgr/ev_epoll_thread_pool_linux.h2
-rw-r--r--src/core/lib/iomgr/ev_epollex_linux.c2
-rw-r--r--src/core/lib/iomgr/ev_epollsig_linux.c3
5 files changed, 22 insertions, 29 deletions
diff --git a/src/core/lib/iomgr/ev_epoll1_linux.c b/src/core/lib/iomgr/ev_epoll1_linux.c
index d31eafc70b..ad69f808cd 100644
--- a/src/core/lib/iomgr/ev_epoll1_linux.c
+++ b/src/core/lib/iomgr/ev_epoll1_linux.c
@@ -948,6 +948,9 @@ static const grpc_event_engine_vtable vtable = {
/* It is possible that GLIBC has epoll but the underlying kernel doesn't.
* Create a dummy epoll_fd to make sure epoll support is available */
const grpc_event_engine_vtable *grpc_init_epoll1_linux(bool explicit_request) {
+ /* TODO(ctiller): temporary, until this stabilizes */
+ if (!explicit_request) return NULL;
+
if (!grpc_has_wakeup_fd()) {
return NULL;
}
diff --git a/src/core/lib/iomgr/ev_epoll_thread_pool_linux.c b/src/core/lib/iomgr/ev_epoll_thread_pool_linux.c
index 8679f9c85d..cf20fc3346 100644
--- a/src/core/lib/iomgr/ev_epoll_thread_pool_linux.c
+++ b/src/core/lib/iomgr/ev_epoll_thread_pool_linux.c
@@ -66,9 +66,8 @@
#include "src/core/lib/support/block_annotate.h"
/* TODO: sreek - Move this to init.c and initialize this like other tracers. */
-static int grpc_polling_trace = 0; /* Disabled by default */
#define GRPC_POLLING_TRACE(fmt, ...) \
- if (grpc_polling_trace) { \
+ if (GRPC_TRACER_ON(grpc_polling_trace)) { \
gpr_log(GPR_INFO, (fmt), __VA_ARGS__); \
}
@@ -77,13 +76,10 @@ static int grpc_polling_trace = 0; /* Disabled by default */
* alarm 'epoch'). This wakeup_fd gives us something to alert on when such a
* case occurs. */
-/* TODO: sreek: Right now, this wakes up all pollers. In future we should make
- * sure to wake up one polling thread (which can wake up other threads if
- * needed) */
-static grpc_wakeup_fd global_wakeup_fd;
-
struct epoll_set;
+#define GRPC_POLLSET_KICK_BROADCAST ((grpc_pollset_worker*)1)
+
/*******************************************************************************
* Fd Declarations
*/
@@ -362,7 +358,7 @@ static void epoll_set_add_wakeup_fd_locked(epoll_set *eps,
gpr_asprintf(&err_msg,
"epoll_ctl (epoll_fd: %d) add wakeup fd: %d failed with "
"error: %d (%s)",
- eps->epoll_fd, GRPC_WAKEUP_FD_GET_READ_FD(&global_wakeup_fd),
+ eps->epoll_fd, GRPC_WAKEUP_FD_GET_READ_FD(wakeup_fd),
errno, strerror(errno));
append_error(error, GRPC_OS_ERROR(errno, err_msg), err_desc);
gpr_free(err_msg);
@@ -423,7 +419,6 @@ static epoll_set *epoll_set_create(grpc_error **error) {
goto done;
}
- epoll_set_add_wakeup_fd_locked(eps, &global_wakeup_fd, error);
epoll_set_add_wakeup_fd_locked(eps, &eps->workqueue_wakeup_fd, error);
done:
@@ -703,11 +698,10 @@ static void pollset_worker_init(grpc_pollset_worker *worker) {
static grpc_error *pollset_global_init(void) {
gpr_tls_init(&g_current_thread_pollset);
gpr_tls_init(&g_current_thread_worker);
- return grpc_wakeup_fd_init(&global_wakeup_fd);
+ return GRPC_ERROR_NONE;
}
static void pollset_global_shutdown(void) {
- grpc_wakeup_fd_destroy(&global_wakeup_fd);
gpr_tls_destroy(&g_current_thread_pollset);
gpr_tls_destroy(&g_current_thread_worker);
}
@@ -802,10 +796,6 @@ static grpc_error *pollset_kick(grpc_pollset *p,
return error;
}
-static grpc_error *kick_poller(void) {
- return grpc_wakeup_fd_wakeup(&global_wakeup_fd);
-}
-
static void pollset_init(grpc_pollset *pollset, gpr_mu **mu) {
gpr_mu_init(&pollset->mu);
*mu = &pollset->mu;
@@ -870,7 +860,7 @@ static void pollset_shutdown(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
/* pollset_shutdown is guaranteed to be called before pollset_destroy. So other
* than destroying the mutexes, there is nothing special that needs to be done
* here */
-static void pollset_destroy(grpc_pollset *pollset) {
+static void pollset_destroy(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset) {
GPR_ASSERT(!pollset_has_workers(pollset));
gpr_mu_destroy(&pollset->mu);
}
@@ -944,11 +934,7 @@ static void do_epoll_wait(grpc_exec_ctx *exec_ctx, int epoll_fd, epoll_set *eps,
for (int i = 0; i < ep_rv; ++i) {
void *data_ptr = ep_ev[i].data.ptr;
- if (data_ptr == &global_wakeup_fd) {
- grpc_timer_consume_kick();
- append_error(error, grpc_wakeup_fd_consume_wakeup(&global_wakeup_fd),
- err_desc);
- } else if (data_ptr == &eps->workqueue_wakeup_fd) {
+ if (data_ptr == &eps->workqueue_wakeup_fd) {
append_error(error,
grpc_wakeup_fd_consume_wakeup(&eps->workqueue_wakeup_fd),
err_desc);
@@ -1152,8 +1138,6 @@ static const grpc_event_engine_vtable vtable = {
.pollset_set_add_fd = pollset_set_add_fd,
.pollset_set_del_fd = pollset_set_del_fd,
- .kick_poller = kick_poller,
-
.workqueue_ref = workqueue_ref,
.workqueue_unref = workqueue_unref,
.workqueue_scheduler = workqueue_scheduler,
@@ -1227,11 +1211,12 @@ static void shutdown_epoll_sets() {
for (size_t i = 0; i < g_num_eps; i++) {
EPS_UNREF(&exec_ctx, g_epoll_sets[i], "shutdown_epoll_sets");
}
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_exec_ctx_flush(&exec_ctx);
gpr_free(g_epoll_sets);
g_epoll_sets = NULL;
- pollset_destroy(&g_read_notifier);
+ pollset_destroy(&exec_ctx, &g_read_notifier);
+ grpc_exec_ctx_finish(&exec_ctx);
}
static void poller_thread_loop(void *arg) {
@@ -1306,7 +1291,9 @@ static bool is_epoll_available() {
return true;
}
-const grpc_event_engine_vtable *grpc_init_epoll_thread_pool_linux(void) {
+const grpc_event_engine_vtable *grpc_init_epoll_thread_pool_linux(bool requested_explicitly) {
+ if (!requested_explicitly) return NULL;
+
if (!grpc_has_wakeup_fd()) {
return NULL;
}
@@ -1341,6 +1328,6 @@ const grpc_event_engine_vtable *grpc_init_epoll_thread_pool_linux(void) {
#include "src/core/lib/iomgr/ev_posix.h"
/* If GRPC_LINUX_EPOLL is not defined, it means epoll is not available. Return
* NULL */
-const grpc_event_engine_vtable *grpc_init_epoll_linux(void) { return NULL; }
+const grpc_event_engine_vtable *grpc_init_epoll_linux(bool requested_explicitly) { return NULL; }
#endif /* defined(GRPC_POSIX_SOCKET) */
#endif /* !defined(GRPC_LINUX_EPOLL) */
diff --git a/src/core/lib/iomgr/ev_epoll_thread_pool_linux.h b/src/core/lib/iomgr/ev_epoll_thread_pool_linux.h
index f4959e3fee..b94dbe7d5d 100644
--- a/src/core/lib/iomgr/ev_epoll_thread_pool_linux.h
+++ b/src/core/lib/iomgr/ev_epoll_thread_pool_linux.h
@@ -37,6 +37,6 @@
#include "src/core/lib/iomgr/ev_posix.h"
#include "src/core/lib/iomgr/port.h"
-const grpc_event_engine_vtable *grpc_init_epoll_thread_pool_linux(void);
+const grpc_event_engine_vtable *grpc_init_epoll_thread_pool_linux(bool requested_explicitly);
#endif /* GRPC_CORE_LIB_IOMGR_EV_EPOLL_THREAD_POOL_LINUX_H */
diff --git a/src/core/lib/iomgr/ev_epollex_linux.c b/src/core/lib/iomgr/ev_epollex_linux.c
index cb6814e89e..7cb6085e25 100644
--- a/src/core/lib/iomgr/ev_epollex_linux.c
+++ b/src/core/lib/iomgr/ev_epollex_linux.c
@@ -1476,6 +1476,8 @@ static const grpc_event_engine_vtable vtable = {
const grpc_event_engine_vtable *grpc_init_epollex_linux(
bool explicitly_requested) {
+ if (!explicitly_requested) return NULL;
+
if (!grpc_has_wakeup_fd()) {
return NULL;
}
diff --git a/src/core/lib/iomgr/ev_epollsig_linux.c b/src/core/lib/iomgr/ev_epollsig_linux.c
index d9ba77c6f0..32096ed55f 100644
--- a/src/core/lib/iomgr/ev_epollsig_linux.c
+++ b/src/core/lib/iomgr/ev_epollsig_linux.c
@@ -1920,7 +1920,8 @@ const grpc_event_engine_vtable *grpc_init_epollsig_linux(
}
if (!is_grpc_wakeup_signal_initialized) {
- if (explicit_request) {
+ /* TODO(ctiller): when other epoll engines are ready, remove the true || to force this to be explitly chosen if needed */
+ if (true || explicit_request) {
grpc_use_signal(SIGRTMIN + 6);
} else {
return NULL;