From: Peter Chubb <peter.chubb@nicta.com.au>
To: qemu-devel@nongnu.org
Cc: bernard.blackham@nicta.com.au, philipo@ok-labs.com
Subject: [Qemu-devel] [PATCH] Remove line buffering from log file
Date: Thu, 29 Sep 2011 12:43:55 +1000 [thread overview]
Message-ID: <w4wrcsysno.wl%peter@chubb.wattle.id.au> (raw)
This patch was originally written by Bernard Blackham, and modified by
Peter Chubb.
From 0d755af2f5bef22432da71f2fe0a9dce7d2882cd Mon Sep 17 00:00:00 2001
From: Bernard Blackham <bernard.blackham@nicta.com.au>
Date: Fri, 24 Jul 2009 13:38:03 +1000
Subject: Disable line-based log buffering.
There's no real reason for line-based buffering in log file output.
If block buffering with a decent sized buffer is used, it can speed
qemu up for -d all or -d exec significantly.
The only thing you lose is that the last up to 4k of log output may be lost if
qemu crashes.
Signed-off-by: Peter Chubb <peter.chubb@nicta.com.au>
Signed-off-by: Hans Jang <hsjang@ok-labs.com>
Signed-off-by: Bernard Blackham <bernard.blackham@nicta.com.au>
---
exec.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
Index: qemu-working/exec.c
===================================================================
--- qemu-working.orig/exec.c 2011-09-29 09:03:35.866233828 +1000
+++ qemu-working/exec.c 2011-09-29 12:40:56.668973550 +1000
@@ -1594,29 +1594,28 @@ void cpu_single_step(CPUState *env, int
/* enable or disable low levels log */
void cpu_set_log(int log_flags)
{
loglevel = log_flags;
if (loglevel && !logfile) {
logfile = fopen(logfilename, log_append ? "a" : "w");
if (!logfile) {
perror(logfilename);
_exit(1);
}
+
+/* Don't use line-based buffering: it hurts -d exec */
#if !defined(CONFIG_SOFTMMU)
/* must avoid mmap() usage of glibc by setting a buffer "by hand" */
{
static char logfile_buf[4096];
- setvbuf(logfile, logfile_buf, _IOLBF, sizeof(logfile_buf));
+ setvbuf(logfile, logfile_buf, _IOFBF, sizeof(logfile_buf));
}
-#elif !defined(_WIN32)
- /* Win32 doesn't support line-buffering and requires size >= 2 */
- setvbuf(logfile, NULL, _IOLBF, 0);
#endif
log_append = 1;
}
if (!loglevel && logfile) {
fclose(logfile);
logfile = NULL;
}
}
void cpu_set_log_filename(const char *filename)
--
Dr Peter Chubb http://www.gelato.unsw.edu.au peterc AT gelato.unsw.edu.au
http://www.ertos.nicta.com.au ERTOS within National ICT Australia
next reply other threads:[~2011-09-29 2:44 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-29 2:43 Peter Chubb [this message]
2011-09-29 4:47 ` [Qemu-devel] [PATCH] Remove line buffering from log file Stefan Weil
2011-09-29 5:03 ` Peter Chubb
2011-09-29 7:57 ` Peter Maydell
2011-09-29 20:11 ` Blue Swirl
2011-09-29 21:26 ` Stefan Weil
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=w4wrcsysno.wl%peter@chubb.wattle.id.au \
--to=peter.chubb@nicta.com.au \
--cc=bernard.blackham@nicta.com.au \
--cc=philipo@ok-labs.com \
--cc=qemu-devel@nongnu.org \
/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).