From: Liu Ping Fan <qemulist@gmail.com>
To: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Anthony Liguori <anthony@codemonkey.ws>,
Jan Kiszka <jan.kiszka@siemens.com>
Subject: [Qemu-devel] [PATCH 5/5] hpet: run on dedicate thread
Date: Thu, 12 Sep 2013 13:24:53 +0800 [thread overview]
Message-ID: <1378963493-559-6-git-send-email-pingfank@linux.vnet.ibm.com> (raw)
In-Reply-To: <1378963493-559-1-git-send-email-pingfank@linux.vnet.ibm.com>
migration is not supported yet.
Signed-off-by: Liu Ping Fan <pingfank@linux.vnet.ibm.com>
---
hw/timer/hpet.c | 31 ++++++++++++++++++++++++++++++-
1 file changed, 30 insertions(+), 1 deletion(-)
diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c
index ae54b87..8e32e36 100644
--- a/hw/timer/hpet.c
+++ b/hw/timer/hpet.c
@@ -91,6 +91,10 @@ typedef struct HPETState {
uint32_t intcap;
HPETTimer timer[HPET_MAX_TIMERS];
bool dedicate_mode;
+ AioContext *ctx;
+ bool created;
+ bool stop;
+ QemuThread t;
/* Memory-mapped, software visible registers */
uint64_t capability; /* capabilities */
@@ -702,6 +706,16 @@ static const MemoryRegionOps hpet_ram_ops = {
.endianness = DEVICE_NATIVE_ENDIAN,
};
+static void *hpet_work_thread(void *opaque)
+{
+ HPETState *hpet = opaque;
+
+ while (!hpet->stop) {
+ aio_poll(hpet->ctx, true);
+ }
+ return NULL;
+}
+
static void hpet_reset(DeviceState *d)
{
HPETState *s = HPET(d);
@@ -732,6 +746,11 @@ static void hpet_reset(DeviceState *d)
/* to document that the RTC lowers its output on reset as well */
s->rtc_irq_level = 0;
+ if (!s->created) {
+ s->created = true;
+ qemu_thread_create(&s->t, hpet_work_thread, s, QEMU_THREAD_JOINABLE);
+ }
+
}
static void hpet_handle_legacy_irq(void *opaque, int n, int level)
@@ -788,10 +807,20 @@ static void hpet_realize(DeviceState *dev, Error **errp)
} else if (s->num_timers > HPET_MAX_TIMERS) {
s->num_timers = HPET_MAX_TIMERS;
}
+ s->dedicate_mode = kvm_irqfds_enabled() ? true : false;
+ if (s->dedicate_mode) {
+ s->ctx = aio_context_new();
+ }
for (i = 0; i < HPET_MAX_TIMERS; i++) {
timer = &s->timer[i];
- timer->qemu_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, hpet_timer, timer);
timer->tn = i;
+ if (s->dedicate_mode) {
+ timer->qemu_timer = aio_timer_new(s->ctx, QEMU_CLOCK_VIRTUAL,
+ SCALE_NS, hpet_timer, timer);
+ } else {
+ timer->qemu_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL,
+ hpet_timer, timer);
+ }
timer->state = s;
}
--
1.8.1.4
prev parent reply other threads:[~2013-09-12 5:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-12 5:24 [Qemu-devel] [RFC 0/5] run hpet on a dedicated thread Liu Ping Fan
2013-09-12 5:24 ` [Qemu-devel] [PATCH 1/5] irq: introduce route method in IRQState to get gsi Liu Ping Fan
2013-09-12 5:24 ` [Qemu-devel] [PATCH 2/5] irq: implement route method of ioapic Liu Ping Fan
2013-09-12 5:24 ` [Qemu-devel] [PATCH 3/5] irqfd: equip irqfd with polarity Liu Ping Fan
2013-09-12 5:24 ` [Qemu-devel] [PATCH 4/5] hpet: deliver irq by irqfd when in dedicated thread mode Liu Ping Fan
2013-09-12 5:24 ` Liu Ping Fan [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=1378963493-559-6-git-send-email-pingfank@linux.vnet.ibm.com \
--to=qemulist@gmail.com \
--cc=anthony@codemonkey.ws \
--cc=jan.kiszka@siemens.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.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).