[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 07/14] iothread: add polling parameters
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL 07/14] iothread: add polling parameters |
Date: |
Wed, 4 Jan 2017 13:34:07 +0000 |
Poll mode can be configured with -object iothread,poll-max-ns=NUM.
Polling is disabled with a value of 0 nanoseconds.
Signed-off-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Paolo Bonzini <address@hidden>
Message-id: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
include/sysemu/iothread.h | 3 +++
iothread.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 53 insertions(+)
diff --git a/include/sysemu/iothread.h b/include/sysemu/iothread.h
index 68ac2de..314e163 100644
--- a/include/sysemu/iothread.h
+++ b/include/sysemu/iothread.h
@@ -28,6 +28,9 @@ typedef struct {
QemuCond init_done_cond; /* is thread initialization done? */
bool stopping;
int thread_id;
+
+ /* AioContext poll parameters */
+ int64_t poll_max_ns;
} IOThread;
#define IOTHREAD(obj) \
diff --git a/iothread.c b/iothread.c
index bd70344..8dfd10d 100644
--- a/iothread.c
+++ b/iothread.c
@@ -98,6 +98,15 @@ static void iothread_complete(UserCreatable *obj, Error
**errp)
return;
}
+ aio_context_set_poll_params(iothread->ctx, iothread->poll_max_ns,
+ &local_error);
+ if (local_error) {
+ error_propagate(errp, local_error);
+ aio_context_unref(iothread->ctx);
+ iothread->ctx = NULL;
+ return;
+ }
+
qemu_mutex_init(&iothread->init_done_lock);
qemu_cond_init(&iothread->init_done_cond);
@@ -120,10 +129,51 @@ static void iothread_complete(UserCreatable *obj, Error
**errp)
qemu_mutex_unlock(&iothread->init_done_lock);
}
+static void iothread_get_poll_max_ns(Object *obj, Visitor *v,
+ const char *name, void *opaque, Error **errp)
+{
+ IOThread *iothread = IOTHREAD(obj);
+
+ visit_type_int64(v, name, &iothread->poll_max_ns, errp);
+}
+
+static void iothread_set_poll_max_ns(Object *obj, Visitor *v,
+ const char *name, void *opaque, Error **errp)
+{
+ IOThread *iothread = IOTHREAD(obj);
+ Error *local_err = NULL;
+ int64_t value;
+
+ visit_type_int64(v, name, &value, &local_err);
+ if (local_err) {
+ goto out;
+ }
+
+ if (value < 0) {
+ error_setg(&local_err, "poll_max_ns value must be in range "
+ "[0, %"PRId64"]", INT64_MAX);
+ goto out;
+ }
+
+ iothread->poll_max_ns = value;
+
+ if (iothread->ctx) {
+ aio_context_set_poll_params(iothread->ctx, value, &local_err);
+ }
+
+out:
+ error_propagate(errp, local_err);
+}
+
static void iothread_class_init(ObjectClass *klass, void *class_data)
{
UserCreatableClass *ucc = USER_CREATABLE_CLASS(klass);
ucc->complete = iothread_complete;
+
+ object_class_property_add(klass, "poll-max-ns", "int",
+ iothread_get_poll_max_ns,
+ iothread_set_poll_max_ns,
+ NULL, NULL, &error_abort);
}
static const TypeInfo iothread_info = {
--
2.9.3
- [Qemu-devel] [PULL 00/14] Block patches, Stefan Hajnoczi, 2017/01/04
- [Qemu-devel] [PULL 02/14] aio: add flag to skip fds to aio_dispatch(), Stefan Hajnoczi, 2017/01/04
- [Qemu-devel] [PULL 01/14] HACKING: document #include order, Stefan Hajnoczi, 2017/01/04
- [Qemu-devel] [PULL 04/14] aio: add polling mode to AioContext, Stefan Hajnoczi, 2017/01/04
- [Qemu-devel] [PULL 06/14] linux-aio: poll ring for completions, Stefan Hajnoczi, 2017/01/04
- [Qemu-devel] [PULL 07/14] iothread: add polling parameters,
Stefan Hajnoczi <=
- [Qemu-devel] [PULL 05/14] virtio: poll virtqueues for new buffers, Stefan Hajnoczi, 2017/01/04
- [Qemu-devel] [PULL 03/14] aio: add AioPollFn and io_poll() interface, Stefan Hajnoczi, 2017/01/04
- [Qemu-devel] [PULL 08/14] virtio-blk: suppress virtqueue kick during processing, Stefan Hajnoczi, 2017/01/04
- [Qemu-devel] [PULL 09/14] virtio-scsi: suppress virtqueue kick during processing, Stefan Hajnoczi, 2017/01/04
- [Qemu-devel] [PULL 10/14] virtio: turn vq->notification into a nested counter, Stefan Hajnoczi, 2017/01/04
- [Qemu-devel] [PULL 12/14] virtio: disable virtqueue notifications during polling, Stefan Hajnoczi, 2017/01/04
- [Qemu-devel] [PULL 11/14] aio: add .io_poll_begin/end() callbacks, Stefan Hajnoczi, 2017/01/04
- [Qemu-devel] [PULL 13/14] aio: self-tune polling time, Stefan Hajnoczi, 2017/01/04
- [Qemu-devel] [PULL 14/14] iothread: add poll-grow and poll-shrink parameters, Stefan Hajnoczi, 2017/01/04
- Re: [Qemu-devel] [PULL 00/14] Block patches, Peter Maydell, 2017/01/05