[PATCH v5 4/6] eal: skip stdio on console logging
Stephen Hemminger
stephen at networkplumber.org
Wed Jun 28 19:58:25 CEST 2023
There is no need to use stdio when logging to console.
Using the write system call directly avoids unnecessary copy
to stdio output buffer.
Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
---
lib/eal/unix/eal_log.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/eal/unix/eal_log.c b/lib/eal/unix/eal_log.c
index 93cf04fae043..7921417b050a 100644
--- a/lib/eal/unix/eal_log.c
+++ b/lib/eal/unix/eal_log.c
@@ -6,6 +6,7 @@
#include <stdio.h>
#include <sys/types.h>
#include <syslog.h>
+#include <unistd.h>
#include <rte_log.h>
@@ -23,8 +24,7 @@ console_log_write(__rte_unused void *c, const char *buf, size_t size)
ssize_t ret;
/* write on stderr */
- ret = fwrite(buf, 1, size, stderr);
- fflush(stderr);
+ ret = write(STDERR_FILENO, buf, size);
/* Syslog error levels are from 0 to 7, so subtract 1 to convert */
syslog(rte_log_cur_msg_loglevel() - 1, "%.*s", (int)size, buf);
--
2.39.2
More information about the dev
mailing list