From: Anders Melchiorsen <mail@flac.kalibalik.dk>
To: qemu-devel@nongnu.org
Cc: Anders Melchiorsen <mail@flac.kalibalik.dk>
Subject: [Qemu-devel] [PATCH] Use SIGIO in Linux host
Date: Sun, 20 Apr 2008 11:20:29 +0200 [thread overview]
Message-ID: <12086832311259-git-send-email-mail@flac.kalibalik.dk> (raw)
In-Reply-To: <12086832303963-git-send-email-mail@flac.kalibalik.dk>
Network packets coming over TAP have a latency that is
dictated by the periodic timer. That can hurt performance.
This patch activates signals for fds that are being used
with select(), giving predictable latency.
Signed-off-by: Anders Melchiorsen <mail@flac.kalibalik.dk>
diff --git a/vl.c b/vl.c
index ad4f6ef..eb2a75e 100644
--- a/vl.c
+++ b/vl.c
@@ -1149,6 +1149,25 @@ static int timer_load(QEMUFile *f, void *opaque, int version_id)
return 0;
}
+#if defined(__linux__)
+static void host_io_handler(int host_signum)
+{
+ CPUState *env = next_cpu;
+
+ if (env) {
+ /* stop the currently executing cpu because io occured */
+ cpu_interrupt(env, CPU_INTERRUPT_EXIT);
+#ifdef USE_KQEMU
+ if (env->kqemu_enabled) {
+ kqemu_cpu_interrupt(env);
+ }
+#endif
+ }
+
+ event_pending = 1;
+}
+#endif
+
#ifdef _WIN32
void CALLBACK host_alarm_handler(UINT uTimerID, UINT uMsg,
DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2)
@@ -1241,6 +1260,19 @@ static uint64_t qemu_next_deadline(void)
#define RTC_FREQ 1024
+static void enable_sigio(int fd)
+{
+ struct sigaction act;
+
+ sigfillset(&act.sa_mask);
+ act.sa_flags = 0;
+ act.sa_handler = host_io_handler;
+
+ sigaction(SIGIO, &act, NULL);
+ fcntl(fd, F_SETFL, O_ASYNC|O_NONBLOCK);
+ fcntl(fd, F_SETOWN, getpid());
+}
+
static void enable_sigalrm(int fd)
{
struct sigaction act;
@@ -5530,6 +5562,10 @@ int qemu_set_fd_handler2(int fd,
return -1;
ioh->next = first_io_handler;
first_io_handler = ioh;
+#if defined(__linux__)
+ enable_sigio(fd);
+#endif
+
found:
ioh->fd = fd;
ioh->fd_read_poll = fd_read_poll;
--
1.5.2.5
next prev parent reply other threads:[~2008-04-20 9:20 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-20 9:20 [Qemu-devel] Linux SIGIO handling changes Anders Melchiorsen
2008-04-20 9:20 ` [Qemu-devel] [PATCH] Use SIGALRM even for timers delivered over a fd Anders Melchiorsen
2008-04-20 9:20 ` Anders Melchiorsen [this message]
2008-04-20 22:04 ` [Qemu-devel] Linux SIGIO handling changes Anthony Liguori
2008-04-21 13:37 ` Avi Kivity
2008-04-21 15:43 ` Anthony Liguori
2008-04-21 16:13 ` Paul Brook
2008-04-21 18:48 ` Anthony Liguori
2008-04-22 8:02 ` Avi Kivity
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=12086832311259-git-send-email-mail@flac.kalibalik.dk \
--to=mail@flac.kalibalik.dk \
--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).