Remove epollex poller (#29160)
* start delete * remove build.gn... again * remove more * Automated change: Fix sanity tests * fixes Co-authored-by: ctiller <ctiller@users.noreply.github.com>pull/29195/head
parent
9f87a1dbb5
commit
766cd6b573
39 changed files with 1181 additions and 3468 deletions
File diff suppressed because it is too large
Load Diff
@ -1,30 +0,0 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2015 gRPC authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
*/ |
||||
|
||||
#ifndef GRPC_CORE_LIB_IOMGR_EV_EPOLLEX_LINUX_H |
||||
#define GRPC_CORE_LIB_IOMGR_EV_EPOLLEX_LINUX_H |
||||
|
||||
#include <grpc/support/port_platform.h> |
||||
|
||||
#include "src/core/lib/iomgr/ev_posix.h" |
||||
#include "src/core/lib/iomgr/port.h" |
||||
|
||||
const grpc_event_engine_vtable* grpc_init_epollex_linux( |
||||
bool explicitly_requested); |
||||
|
||||
#endif /* GRPC_CORE_LIB_IOMGR_EV_EPOLLEX_LINUX_H */ |
@ -1,119 +0,0 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2017 gRPC authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
*/ |
||||
|
||||
#include <grpc/support/port_platform.h> |
||||
|
||||
#include "src/core/lib/iomgr/is_epollexclusive_available.h" |
||||
|
||||
#include "src/core/lib/iomgr/port.h" |
||||
|
||||
#ifdef GRPC_LINUX_EPOLL_CREATE1 |
||||
|
||||
#include <errno.h> |
||||
#include <sys/epoll.h> |
||||
#include <sys/eventfd.h> |
||||
#include <unistd.h> |
||||
|
||||
#include <grpc/support/log.h> |
||||
|
||||
#include "src/core/lib/iomgr/sys_epoll_wrapper.h" |
||||
|
||||
/* This polling engine is only relevant on linux kernels supporting epoll() */ |
||||
bool grpc_is_epollexclusive_available(void) { |
||||
static bool logged_why_not = false; |
||||
|
||||
int fd = epoll_create1(EPOLL_CLOEXEC); |
||||
if (fd < 0) { |
||||
if (!logged_why_not) { |
||||
gpr_log(GPR_DEBUG, |
||||
"epoll_create1 failed with error: %d. Not using epollex polling " |
||||
"engine.", |
||||
fd); |
||||
logged_why_not = true; |
||||
} |
||||
return false; |
||||
} |
||||
int evfd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC); |
||||
if (evfd < 0) { |
||||
if (!logged_why_not) { |
||||
gpr_log(GPR_DEBUG, |
||||
"eventfd failed with error: %d. Not using epollex polling " |
||||
"engine.", |
||||
fd); |
||||
logged_why_not = true; |
||||
} |
||||
close(fd); |
||||
return false; |
||||
} |
||||
struct epoll_event ev; |
||||
/* choose events that should cause an error on
|
||||
EPOLLEXCLUSIVE enabled kernels - specifically the combination of |
||||
EPOLLONESHOT and EPOLLEXCLUSIVE */ |
||||
ev.events = |
||||
static_cast<uint32_t>(EPOLLET | EPOLLIN | EPOLLEXCLUSIVE | EPOLLONESHOT); |
||||
ev.data.ptr = nullptr; |
||||
if (epoll_ctl(fd, EPOLL_CTL_ADD, evfd, &ev) != 0) { |
||||
if (errno != EINVAL) { |
||||
if (!logged_why_not) { |
||||
gpr_log( |
||||
GPR_ERROR, |
||||
"epoll_ctl with EPOLLEXCLUSIVE | EPOLLONESHOT failed with error: " |
||||
"%d. Not using epollex polling engine.", |
||||
errno); |
||||
logged_why_not = true; |
||||
} |
||||
close(fd); |
||||
close(evfd); |
||||
return false; |
||||
} |
||||
} else { |
||||
if (!logged_why_not) { |
||||
gpr_log(GPR_DEBUG, |
||||
"epoll_ctl with EPOLLEXCLUSIVE | EPOLLONESHOT succeeded. This is " |
||||
"evidence of no EPOLLEXCLUSIVE support. Not using " |
||||
"epollex polling engine."); |
||||
logged_why_not = true; |
||||
} |
||||
close(fd); |
||||
close(evfd); |
||||
return false; |
||||
} |
||||
// Check that EPOLLEXCLUSIVE is supported at all.
|
||||
ev.events = static_cast<uint32_t>(EPOLLET | EPOLLIN | EPOLLEXCLUSIVE); |
||||
if (epoll_ctl(fd, EPOLL_CTL_ADD, evfd, &ev) != 0) { |
||||
if (!logged_why_not) { |
||||
gpr_log(GPR_DEBUG, |
||||
"epoll_ctl with EPOLLEXCLUSIVE failed with error: " |
||||
"%d. Not using epollex polling engine.", |
||||
errno); |
||||
logged_why_not = true; |
||||
} |
||||
close(fd); |
||||
close(evfd); |
||||
return false; |
||||
} |
||||
close(evfd); |
||||
close(fd); |
||||
return true; |
||||
} |
||||
|
||||
#else |
||||
|
||||
bool grpc_is_epollexclusive_available(void) { return false; } |
||||
|
||||
#endif |
@ -1,36 +0,0 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2015 gRPC authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
*/ |
||||
|
||||
#ifndef GRPC_CORE_LIB_IOMGR_IS_EPOLLEXCLUSIVE_AVAILABLE_H |
||||
#define GRPC_CORE_LIB_IOMGR_IS_EPOLLEXCLUSIVE_AVAILABLE_H |
||||
|
||||
#include <grpc/support/port_platform.h> |
||||
|
||||
#include <stdbool.h> |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
bool grpc_is_epollexclusive_available(void); |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
|
||||
#endif /* GRPC_CORE_LIB_IOMGR_IS_EPOLLEXCLUSIVE_AVAILABLE_H */ |
@ -1,30 +0,0 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2017 gRPC authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
*/ |
||||
|
||||
#ifndef GRPC_CORE_LIB_IOMGR_SYS_EPOLL_WRAPPER_H |
||||
#define GRPC_CORE_LIB_IOMGR_SYS_EPOLL_WRAPPER_H |
||||
|
||||
#include <grpc/support/port_platform.h> |
||||
|
||||
#include <sys/epoll.h> |
||||
|
||||
#ifndef EPOLLEXCLUSIVE |
||||
#define EPOLLEXCLUSIVE (1 << 28) |
||||
#endif |
||||
|
||||
#endif /* GRPC_CORE_LIB_IOMGR_SYS_EPOLL_WRAPPER_H */ |
@ -1,23 +0,0 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2017 gRPC authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
*/ |
||||
|
||||
#include "src/core/lib/iomgr/is_epollexclusive_available.h" |
||||
|
||||
int main(int argc, char **argv) { |
||||
return grpc_is_epollexclusive_available() ? 0 : 1; |
||||
} |
@ -1,115 +0,0 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2018 gRPC authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
*/ |
||||
#include "src/core/lib/iomgr/port.h" |
||||
|
||||
/* This test only relevant on linux systems where epoll() is available */ |
||||
#if defined(GRPC_LINUX_EPOLL_CREATE1) && defined(GRPC_LINUX_EVENTFD) |
||||
#include <string.h> |
||||
#include <sys/eventfd.h> |
||||
|
||||
#include <grpc/grpc.h> |
||||
|
||||
#include "src/core/lib/iomgr/ev_epollex_linux.h" |
||||
#include "test/core/util/test_config.h" |
||||
|
||||
static void pollset_destroy(void* ps, grpc_error_handle /*error*/) { |
||||
grpc_pollset_destroy(static_cast<grpc_pollset*>(ps)); |
||||
gpr_free(ps); |
||||
} |
||||
|
||||
// This test is added to cover the case found in bug:
|
||||
// https://github.com/grpc/grpc/issues/15760
|
||||
static void test_pollable_owner_fd() { |
||||
grpc_core::ExecCtx exec_ctx; |
||||
int ev_fd1; |
||||
int ev_fd2; |
||||
grpc_fd* grpc_fd1; |
||||
grpc_fd* grpc_fd2; |
||||
grpc_pollset* ps; |
||||
gpr_mu* mu; |
||||
|
||||
// == Create two grpc_fds ==
|
||||
// All we need is two file descriptors. Doesn't matter what type. We use
|
||||
// eventfd type here for the purpose of this test
|
||||
ev_fd1 = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC); |
||||
ev_fd2 = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC); |
||||
if (ev_fd1 < 0 || ev_fd2 < 0) { |
||||
gpr_log(GPR_ERROR, "Error in creating event fds for the test"); |
||||
return; |
||||
} |
||||
grpc_fd1 = grpc_fd_create(ev_fd1, "epollex-test-fd1", false); |
||||
grpc_fd2 = grpc_fd_create(ev_fd2, "epollex-test-fd2", false); |
||||
grpc_core::ExecCtx::Get()->Flush(); |
||||
|
||||
// == Create a pollset ==
|
||||
ps = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size())); |
||||
grpc_pollset_init(ps, &mu); |
||||
grpc_core::ExecCtx::Get()->Flush(); |
||||
|
||||
// == Add fd1 to pollset ==
|
||||
grpc_pollset_add_fd(ps, grpc_fd1); |
||||
grpc_core::ExecCtx::Get()->Flush(); |
||||
|
||||
// == Destroy fd1 ==
|
||||
grpc_fd_orphan(grpc_fd1, nullptr, nullptr, "test fd1 orphan"); |
||||
grpc_core::ExecCtx::Get()->Flush(); |
||||
|
||||
// = Add fd2 to pollset ==
|
||||
//
|
||||
// Before https://github.com/grpc/grpc/issues/15760, the following line caused
|
||||
// unexpected behavior (The previous grpc_pollset_add_fd(ps, grpc_fd1) created
|
||||
// an underlying structure in epollex that held a reference to grpc_fd1 which
|
||||
// was being accessed here even after grpc_fd_orphan(grpc_fd1) was called
|
||||
grpc_pollset_add_fd(ps, grpc_fd2); |
||||
grpc_core::ExecCtx::Get()->Flush(); |
||||
|
||||
// == Destroy fd2 ==
|
||||
grpc_fd_orphan(grpc_fd2, nullptr, nullptr, "test fd2 orphan"); |
||||
grpc_core::ExecCtx::Get()->Flush(); |
||||
|
||||
// == Destroy pollset
|
||||
grpc_closure ps_destroy_closure; |
||||
GRPC_CLOSURE_INIT(&ps_destroy_closure, pollset_destroy, ps, |
||||
grpc_schedule_on_exec_ctx); |
||||
grpc_pollset_shutdown(ps, &ps_destroy_closure); |
||||
grpc_core::ExecCtx::Get()->Flush(); |
||||
} |
||||
|
||||
int main(int argc, char** argv) { |
||||
const char* poll_strategy = nullptr; |
||||
grpc::testing::TestEnvironment env(argc, argv); |
||||
grpc_init(); |
||||
{ |
||||
grpc_core::ExecCtx exec_ctx; |
||||
poll_strategy = grpc_get_poll_strategy_name(); |
||||
if (poll_strategy != nullptr && strcmp(poll_strategy, "epollex") == 0) { |
||||
test_pollable_owner_fd(); |
||||
} else { |
||||
gpr_log(GPR_INFO, |
||||
"Skipping the test. The test is only relevant for 'epollex' " |
||||
"strategy. and the current strategy is: '%s'", |
||||
poll_strategy); |
||||
} |
||||
} |
||||
|
||||
grpc_shutdown(); |
||||
return 0; |
||||
} |
||||
#else /* defined(GRPC_LINUX_EPOLL_CREATE1) && defined(GRPC_LINUX_EVENTFD) */ |
||||
int main(int /*argc*/, char** /*argv*/) { return 0; } |
||||
#endif |
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue