From 43f02bb8a77337e2f56016529c9e46c8b8dc455a Mon Sep 17 00:00:00 2001 From: Matthew Smith Date: Tue, 17 Jul 2018 11:40:04 -0500 Subject: dpdk: set log write fd to non-blocking If a PMD writes too many log messages using rte_vlog(), the pipe for logging can fill and then rte_vlog() will block on fflush() while it waits for something to read from the other side of the pipe. That will never happen since the process node that would read the other side of the pipe runs in the same thread. Set the write fd to non-blocking before the call to rte_openlog_stream(). If the pipe is full, calls to write() or fflush() will fail but execution will continue. Change-Id: I0e5d710629633acda5617ff29897d6582c255d57 Signed-off-by: Matthew Smith --- src/plugins/dpdk/device/init.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/dpdk/device/init.c b/src/plugins/dpdk/device/init.c index ebb43d1a86f..a08ed6d908f 100644 --- a/src/plugins/dpdk/device/init.c +++ b/src/plugins/dpdk/device/init.c @@ -1356,14 +1356,22 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input) int log_fds[2] = { 0 }; if (pipe (log_fds) == 0) { - FILE *f = fdopen (log_fds[1], "a"); - if (f && rte_openlog_stream (f) == 0) + if (fcntl (log_fds[1], F_SETFL, O_NONBLOCK) == 0) { - clib_file_t t = { 0 }; - t.read_function = dpdk_log_read_ready; - t.file_descriptor = log_fds[0]; - t.description = format (0, "DPDK logging pipe"); - clib_file_add (&file_main, &t); + FILE *f = fdopen (log_fds[1], "a"); + if (f && rte_openlog_stream (f) == 0) + { + clib_file_t t = { 0 }; + t.read_function = dpdk_log_read_ready; + t.file_descriptor = log_fds[0]; + t.description = format (0, "DPDK logging pipe"); + clib_file_add (&file_main, &t); + } + } + else + { + close (log_fds[0]); + close (log_fds[1]); } } -- cgit 1.2.3-korg