Thread (6 messages) 6 messages, 4 authors, 2021-12-11

RE: [PATCH v2] Unbuffered output when pipe/tee to a file

From: David Laight <hidden>
Date: 2021-12-11 17:10:21
Also in: lkml

From: Arnaldo Carvalho de Melo
Sent: 09 December 2021 18:51
...
quoted
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 8cb5a1c3489e..d92ae4efd2e6 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -606,6 +606,9 @@ int cmd_test(int argc, const char **argv)
         if (ret < 0)
                 return ret;

+	/* Unbuffered output */
+	setvbuf(stdout, NULL, _IONBF, 0);
+
You only want _IOLBF (line buffered).

Otherwise you are likely to get a lot of write() system calls.
Even multiple ones from the same printf().

Although it can be better just to ensure there is a fflush(stdout)
inside the loop.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help