25
#include "qemu/rcu.h"
26
#include "qemu/main-loop.h"
27
28
-
29
-#ifdef CONFIG_POSIX
30
-/* Benchmark results from 2016 on NVMe SSD drives show max polling times around
31
- * 16-32 microseconds yield IOPS improvements for both iodepth=1 and iodepth=32
32
- * workloads.
33
- */
34
-#define IOTHREAD_POLL_MAX_NS_DEFAULT 32768ULL
35
-#else
36
-#define IOTHREAD_POLL_MAX_NS_DEFAULT 0ULL
37
-#endif
38
-
28
static void *iothread_run(void *opaque)
29
{
30
IOThread *iothread = opaque;
92
IOThread *iothread = IOTHREAD(obj);
93
94
iothread->poll_max_ns = IOTHREAD_POLL_MAX_NS_DEFAULT;
95
+ iothread->poll_grow = IOTHREAD_POLL_GROW_DEFAULT;
96
+ iothread->poll_shrink = IOTHREAD_POLL_SHRINK_DEFAULT;
97
+ iothread->poll_weight = IOTHREAD_POLL_WEIGHT_DEFAULT;
98
+
99
iothread->thread_id = -1;
100
qemu_sem_init(&iothread->init_done_sem, 0);
101
/* By default, we don't run gcontext */
157
iothread->poll_max_ns,
158
iothread->poll_grow,
159
iothread->poll_shrink,
160
+ iothread->poll_weight,
161
errp);
162
if (*errp) {
163
return;
227
static IOThreadParamInfo poll_shrink_info = {
228
"poll-shrink", offsetof(IOThread, poll_shrink),
229
};
230
+static IOThreadParamInfo poll_weight_info = {
231
+ "poll-weight", offsetof(IOThread, poll_weight),
232
+};
233
234
static void iothread_get_param(Object *obj, Visitor *v,
235
const char *name, IOThreadParamInfo *info, Error **errp)
251
return false;
252
}
253
257
- if (value < 0) {
254
+ if (info->offset == offsetof(IOThread, poll_weight)) {
255
+ if (value < 0 || value > 63) {
256
+ error_setg(errp, "%s value must be in range [0, 63]",
257
+ info->name);
258
+ return false;
259
+ }
260
+ } else if (value < 0) {
261
error_setg(errp, "%s value must be in range [0, %" PRId64 "]",
262
info->name, INT64_MAX);
263
return false;
264
}
265
263
- *field = value;
266
+ if (value == 0) {
267
+ if (info->offset == offsetof(IOThread, poll_grow)) {
268
+ *field = IOTHREAD_POLL_GROW_DEFAULT;
269
+ } else if (info->offset == offsetof(IOThread, poll_shrink)) {
270
+ *field = IOTHREAD_POLL_SHRINK_DEFAULT;
271
+ } else if (info->offset == offsetof(IOThread, poll_weight)) {
272
+ *field = IOTHREAD_POLL_WEIGHT_DEFAULT;
273
+ } else {
274
+ *field = value;
275
+ }
276
+ } else {
277
+ *field = value;
278
+ }
279
280
return true;
281
}
303
iothread->poll_max_ns,
304
iothread->poll_grow,
305
iothread->poll_shrink,
306
+ iothread->poll_weight,
307
errp);
308
}
309
}
327
iothread_get_poll_param,
328
iothread_set_poll_param,
329
NULL, &poll_shrink_info);
330
+ object_class_property_add(klass, "poll-weight", "int",
331
+ iothread_get_poll_param,
332
+ iothread_set_poll_param,
333
+ NULL, &poll_weight_info);
334
}
335
336
static const TypeInfo iothread_info = {
376
info->poll_max_ns = iothread->poll_max_ns;
377
info->poll_grow = iothread->poll_grow;
378
info->poll_shrink = iothread->poll_shrink;
379
+ info->poll_weight = iothread->poll_weight;
380
info->aio_max_batch = iothread->parent_obj.aio_max_batch;
381
382
QAPI_LIST_APPEND(*tail, info);