lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <8edd3fd7b40745b6bf96cbb6438fcc65@AcuMS.aculab.com>
Date:   Sat, 11 Dec 2021 17:10:13 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     'Arnaldo Carvalho de Melo' <acme@...nel.org>,
        Sohaib Mohamed <sohaib.amhmd@...il.com>
CC:     "irogers@...gle.com" <irogers@...gle.com>,
        Riccardo Mancini <rickyman7@...il.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>,
        Mark Rutland <mark.rutland@....com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Jiri Olsa <jolsa@...hat.com>,
        "Namhyung Kim" <namhyung@...nel.org>,
        Adrian Hunter <adrian.hunter@...el.com>,
        "Fabian Hemmer" <copy@...y.sh>,
        "linux-perf-users@...r.kernel.org" <linux-perf-users@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH v2] Unbuffered output when pipe/tee to a file

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)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ