1
The following changes since commit 4100a344eb3d50d88f9da85cae334afc47aee134:
1
The following changes since commit d145c0da22cde391d8c6672d33146ce306e8bf75:
2
2
3
Merge remote-tracking branch 'remotes/sstabellini/tags/xen-20170202' into staging (2017-02-03 12:31:40 +0000)
3
Merge tag 'pull-tcg-20230701' of https://gitlab.com/rth7680/qemu into staging (2023-07-01 08:55:37 +0200)
4
4
5
are available in the git repository at:
5
are available in the Git repository at:
6
6
7
git://github.com/stefanha/qemu.git tags/block-pull-request
7
https://gitlab.com/stefanha/qemu.git tags/block-pull-request
8
8
9
for you to fetch changes up to cdd7abfdba9287a289c404dfdcb02316f9ffee7d:
9
for you to fetch changes up to c21eae1ccc782440f320accb6f90c66cb8f45ee9:
10
10
11
iothread: enable AioContext polling by default (2017-02-03 14:23:38 +0000)
11
block/blkio: fix module_block.py parsing (2023-07-04 17:28:25 +0200)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
Pull request
15
16
Fix --enable-modules with the blkio block driver.
14
17
15
----------------------------------------------------------------
18
----------------------------------------------------------------
16
19
17
Stefan Hajnoczi (1):
20
Stefan Hajnoczi (1):
18
iothread: enable AioContext polling by default
21
block/blkio: fix module_block.py parsing
19
22
20
iothread.c | 14 ++++++++++++++
23
block/blkio.c | 108 ++++++++++++++++++++++++++------------------------
21
1 file changed, 14 insertions(+)
24
1 file changed, 56 insertions(+), 52 deletions(-)
22
25
23
--
26
--
24
2.9.3
27
2.40.1
25
26
diff view generated by jsdifflib
1
IOThread AioContexts are likely to consist only of event sources like
1
When QEMU is built with --enable-modules, the module_block.py script
2
virtqueue ioeventfds and LinuxAIO completion eventfds that are pollable
2
parses block/*.c to find block drivers that are built as modules. The
3
from userspace (without system calls).
3
script generates a table of block drivers called block_driver_modules[].
4
This table is used for block driver module loading.
4
5
5
We recently merged the AioContext polling feature but didn't enable it
6
The blkio.c driver uses macros to define its BlockDriver structs. This
6
by default yet. I have gone back over the performance data on the
7
was done to avoid code duplication but the module_block.py script is
7
mailing list and picked a default polling value that gave good results.
8
unable to parse the macro. The result is that libblkio-based block
9
drivers can be built as modules but will not be found at runtime.
8
10
9
Let's enable AioContext polling by default so users don't have another
11
One fix is to make the module_block.py script or build system fancier so
10
switch they need to set manually. If performance regressions are found
12
it can parse C macros (e.g. by parsing the preprocessed source code). I
11
we can still disable this for the QEMU 2.9 release.
13
chose not to do this because it raises the complexity of the build,
14
making future issues harder to debug.
12
15
13
Cc: Paolo Bonzini <pbonzini@redhat.com>
16
Keep things simple: use the macro to avoid duplicating BlockDriver
14
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
17
function pointers but define .format_name and .protocol_name manually
15
Cc: Karl Rister <krister@redhat.com>
18
for each BlockDriver. This way the module_block.py is able to parse the
19
code.
20
21
Also get rid of the block driver name macros (e.g. DRIVER_IO_URING)
22
because module_block.py cannot parse them either.
23
24
Fixes: fd66dbd424f5 ("blkio: add libblkio block driver")
25
Reported-by: Qing Wang <qinwang@redhat.com>
16
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
26
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
17
Message-id: 20170126170119.27876-1-stefanha@redhat.com
27
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
28
Message-id: 20230704123436.187761-1-stefanha@redhat.com
29
Cc: Stefano Garzarella <sgarzare@redhat.com>
18
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
30
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
19
---
31
---
20
iothread.c | 14 ++++++++++++++
32
block/blkio.c | 108 ++++++++++++++++++++++++++------------------------
21
1 file changed, 14 insertions(+)
33
1 file changed, 56 insertions(+), 52 deletions(-)
22
34
23
diff --git a/iothread.c b/iothread.c
35
diff --git a/block/blkio.c b/block/blkio.c
24
index XXXXXXX..XXXXXXX 100644
36
index XXXXXXX..XXXXXXX 100644
25
--- a/iothread.c
37
--- a/block/blkio.c
26
+++ b/iothread.c
38
+++ b/block/blkio.c
27
@@ -XXX,XX +XXX,XX @@ typedef ObjectClass IOThreadClass;
39
@@ -XXX,XX +XXX,XX @@
28
#define IOTHREAD_CLASS(klass) \
40
29
OBJECT_CLASS_CHECK(IOThreadClass, klass, TYPE_IOTHREAD)
41
#include "block/block-io.h"
30
42
31
+/* Benchmark results from 2016 on NVMe SSD drives show max polling times around
43
-/*
32
+ * 16-32 microseconds yield IOPS improvements for both iodepth=1 and iodepth=32
44
- * Keep the QEMU BlockDriver names identical to the libblkio driver names.
33
+ * workloads.
45
- * Using macros instead of typing out the string literals avoids typos.
46
- */
47
-#define DRIVER_IO_URING "io_uring"
48
-#define DRIVER_NVME_IO_URING "nvme-io_uring"
49
-#define DRIVER_VIRTIO_BLK_VFIO_PCI "virtio-blk-vfio-pci"
50
-#define DRIVER_VIRTIO_BLK_VHOST_USER "virtio-blk-vhost-user"
51
-#define DRIVER_VIRTIO_BLK_VHOST_VDPA "virtio-blk-vhost-vdpa"
52
-
53
/*
54
* Allocated bounce buffers are kept in a list sorted by buffer address.
55
*/
56
@@ -XXX,XX +XXX,XX @@ static int blkio_file_open(BlockDriverState *bs, QDict *options, int flags,
57
return ret;
58
}
59
60
- if (strcmp(blkio_driver, DRIVER_IO_URING) == 0) {
61
+ if (strcmp(blkio_driver, "io_uring") == 0) {
62
ret = blkio_io_uring_open(bs, options, flags, errp);
63
- } else if (strcmp(blkio_driver, DRIVER_NVME_IO_URING) == 0) {
64
+ } else if (strcmp(blkio_driver, "nvme-io_uring") == 0) {
65
ret = blkio_nvme_io_uring(bs, options, flags, errp);
66
- } else if (strcmp(blkio_driver, DRIVER_VIRTIO_BLK_VFIO_PCI) == 0) {
67
+ } else if (strcmp(blkio_driver, "virtio-blk-vfio-pci") == 0) {
68
ret = blkio_virtio_blk_common_open(bs, options, flags, errp);
69
- } else if (strcmp(blkio_driver, DRIVER_VIRTIO_BLK_VHOST_USER) == 0) {
70
+ } else if (strcmp(blkio_driver, "virtio-blk-vhost-user") == 0) {
71
ret = blkio_virtio_blk_common_open(bs, options, flags, errp);
72
- } else if (strcmp(blkio_driver, DRIVER_VIRTIO_BLK_VHOST_VDPA) == 0) {
73
+ } else if (strcmp(blkio_driver, "virtio-blk-vhost-vdpa") == 0) {
74
ret = blkio_virtio_blk_common_open(bs, options, flags, errp);
75
} else {
76
g_assert_not_reached();
77
@@ -XXX,XX +XXX,XX @@ static void blkio_refresh_limits(BlockDriverState *bs, Error **errp)
78
* - truncate
79
*/
80
81
-#define BLKIO_DRIVER(name, ...) \
82
- { \
83
- .format_name = name, \
84
- .protocol_name = name, \
85
- .instance_size = sizeof(BDRVBlkioState), \
86
- .bdrv_file_open = blkio_file_open, \
87
- .bdrv_close = blkio_close, \
88
- .bdrv_co_getlength = blkio_co_getlength, \
89
- .bdrv_co_truncate = blkio_truncate, \
90
- .bdrv_co_get_info = blkio_co_get_info, \
91
- .bdrv_attach_aio_context = blkio_attach_aio_context, \
92
- .bdrv_detach_aio_context = blkio_detach_aio_context, \
93
- .bdrv_co_pdiscard = blkio_co_pdiscard, \
94
- .bdrv_co_preadv = blkio_co_preadv, \
95
- .bdrv_co_pwritev = blkio_co_pwritev, \
96
- .bdrv_co_flush_to_disk = blkio_co_flush, \
97
- .bdrv_co_pwrite_zeroes = blkio_co_pwrite_zeroes, \
98
- .bdrv_refresh_limits = blkio_refresh_limits, \
99
- .bdrv_register_buf = blkio_register_buf, \
100
- .bdrv_unregister_buf = blkio_unregister_buf, \
101
- __VA_ARGS__ \
102
- }
103
+/*
104
+ * Do not include .format_name and .protocol_name because module_block.py
105
+ * does not parse macros in the source code.
34
+ */
106
+ */
35
+#define IOTHREAD_POLL_MAX_NS_DEFAULT 32768ULL
107
+#define BLKIO_DRIVER_COMMON \
108
+ .instance_size = sizeof(BDRVBlkioState), \
109
+ .bdrv_file_open = blkio_file_open, \
110
+ .bdrv_close = blkio_close, \
111
+ .bdrv_co_getlength = blkio_co_getlength, \
112
+ .bdrv_co_truncate = blkio_truncate, \
113
+ .bdrv_co_get_info = blkio_co_get_info, \
114
+ .bdrv_attach_aio_context = blkio_attach_aio_context, \
115
+ .bdrv_detach_aio_context = blkio_detach_aio_context, \
116
+ .bdrv_co_pdiscard = blkio_co_pdiscard, \
117
+ .bdrv_co_preadv = blkio_co_preadv, \
118
+ .bdrv_co_pwritev = blkio_co_pwritev, \
119
+ .bdrv_co_flush_to_disk = blkio_co_flush, \
120
+ .bdrv_co_pwrite_zeroes = blkio_co_pwrite_zeroes, \
121
+ .bdrv_refresh_limits = blkio_refresh_limits, \
122
+ .bdrv_register_buf = blkio_register_buf, \
123
+ .bdrv_unregister_buf = blkio_unregister_buf,
124
125
-static BlockDriver bdrv_io_uring = BLKIO_DRIVER(
126
- DRIVER_IO_URING,
127
+/*
128
+ * Use the same .format_name and .protocol_name as the libblkio driver name for
129
+ * consistency.
130
+ */
36
+
131
+
37
static __thread IOThread *my_iothread;
132
+static BlockDriver bdrv_io_uring = {
38
133
+ .format_name = "io_uring",
39
AioContext *qemu_get_current_aio_context(void)
134
+ .protocol_name = "io_uring",
40
@@ -XXX,XX +XXX,XX @@ static int iothread_stop(Object *object, void *opaque)
135
.bdrv_needs_filename = true,
41
return 0;
136
-);
42
}
137
+ BLKIO_DRIVER_COMMON
43
138
+};
44
+static void iothread_instance_init(Object *obj)
139
45
+{
140
-static BlockDriver bdrv_nvme_io_uring = BLKIO_DRIVER(
46
+ IOThread *iothread = IOTHREAD(obj);
141
- DRIVER_NVME_IO_URING,
47
+
142
-);
48
+ iothread->poll_max_ns = IOTHREAD_POLL_MAX_NS_DEFAULT;
143
+static BlockDriver bdrv_nvme_io_uring = {
49
+}
144
+ .format_name = "nvme-io_uring",
50
+
145
+ .protocol_name = "nvme-io_uring",
51
static void iothread_instance_finalize(Object *obj)
146
+ BLKIO_DRIVER_COMMON
147
+};
148
149
-static BlockDriver bdrv_virtio_blk_vfio_pci = BLKIO_DRIVER(
150
- DRIVER_VIRTIO_BLK_VFIO_PCI
151
-);
152
+static BlockDriver bdrv_virtio_blk_vfio_pci = {
153
+ .format_name = "virtio-blk-vfio-pci",
154
+ .protocol_name = "virtio-blk-vfio-pci",
155
+ BLKIO_DRIVER_COMMON
156
+};
157
158
-static BlockDriver bdrv_virtio_blk_vhost_user = BLKIO_DRIVER(
159
- DRIVER_VIRTIO_BLK_VHOST_USER
160
-);
161
+static BlockDriver bdrv_virtio_blk_vhost_user = {
162
+ .format_name = "virtio-blk-vhost-user",
163
+ .protocol_name = "virtio-blk-vhost-user",
164
+ BLKIO_DRIVER_COMMON
165
+};
166
167
-static BlockDriver bdrv_virtio_blk_vhost_vdpa = BLKIO_DRIVER(
168
- DRIVER_VIRTIO_BLK_VHOST_VDPA
169
-);
170
+static BlockDriver bdrv_virtio_blk_vhost_vdpa = {
171
+ .format_name = "virtio-blk-vhost-vdpa",
172
+ .protocol_name = "virtio-blk-vhost-vdpa",
173
+ BLKIO_DRIVER_COMMON
174
+};
175
176
static void bdrv_blkio_init(void)
52
{
177
{
53
IOThread *iothread = IOTHREAD(obj);
54
@@ -XXX,XX +XXX,XX @@ static const TypeInfo iothread_info = {
55
.parent = TYPE_OBJECT,
56
.class_init = iothread_class_init,
57
.instance_size = sizeof(IOThread),
58
+ .instance_init = iothread_instance_init,
59
.instance_finalize = iothread_instance_finalize,
60
.interfaces = (InterfaceInfo[]) {
61
{TYPE_USER_CREATABLE},
62
--
178
--
63
2.9.3
179
2.40.1
64
65
diff view generated by jsdifflib