From: David Laight <David.Laight@ACULAB.COM>
To: 'Arnaldo Carvalho de Melo' <acme@kernel.org>,
Sohaib Mohamed <sohaib.amhmd@gmail.com>
Cc: "irogers@google.com" <irogers@google.com>,
Riccardo Mancini <rickyman7@gmail.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@redhat.com>,
"Namhyung Kim" <namhyung@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
"Fabian Hemmer" <copy@copy.sh>,
"linux-perf-users@vger.kernel.org"
<linux-perf-users@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH v2] Unbuffered output when pipe/tee to a file
Date: Sat, 11 Dec 2021 17:10:13 +0000 [thread overview]
Message-ID: <8edd3fd7b40745b6bf96cbb6438fcc65@AcuMS.aculab.com> (raw)
In-Reply-To: <YbJQAp6/gz4kHdi8@kernel.org>
From: Arnaldo Carvalho de Melo
> Sent: 09 December 2021 18:51
...
> > 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)
prev parent reply other threads:[~2021-12-11 17:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-19 6:14 [PATCH v2] Unbuffered output when pipe/tee to a file Sohaib Mohamed
2021-11-28 15:34 ` Jiri Olsa
2021-12-09 18:51 ` Arnaldo Carvalho de Melo
2021-12-09 19:30 ` Jiri Olsa
2021-12-09 18:50 ` Arnaldo Carvalho de Melo
2021-12-11 17:10 ` David Laight [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8edd3fd7b40745b6bf96cbb6438fcc65@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=copy@copy.sh \
--cc=irogers@google.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=rickyman7@gmail.com \
--cc=sohaib.amhmd@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).