Block patches
The following changes since commit 013a18edbbc59cdad019100c7d03c0494642b74c:
Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-2020051=
4' into staging (2020-05-14 16:17:55 +0100)
are available in the Git repository at:
https://github.com/stefanha/qemu.git tags/block-pull-request
for you to fetch changes up to ba607ca8bff4d2c2062902f8355657c865ac7c29:
aio-posix: disable fdmon-io_uring when GSource is used (2020-05-18 18:16:00=
+0100)
----------------------------------------------------------------
Pull request
----------------------------------------------------------------
Philippe Mathieu-Daud=C3=A9 (6):
tests/fuzz/Makefile: Do not link code using unavailable devices
Makefile: List fuzz targets in 'make help' tests/fuzz: Add missing space in test description tests/fuzz: Remove unuseful/unused typedefs tests/fuzz: Extract pciconfig_fuzz_qos() method tests/fuzz: Extract ioport_fuzz_qtest() method
Stefan Hajnoczi (2):
aio-posix: don't duplicate fd handler deletion in
fdmon_io_uring_destroy()
aio-posix: disable fdmon-io_uring when GSource is used
Makefile | 6 +++- tests/qtest/fuzz/Makefile.include | 6 ++-- include/block/aio.h | 3 ++ tests/qtest/fuzz/i440fx_fuzz.c | 47 ++++++++++++++++++++----------- util/aio-posix.c | 13 +++++++++ util/aio-win32.c | 4 +++ util/async.c | 1 + util/fdmon-io_uring.c | 13 +++++++-- 8 files changed, 69 insertions(+), 24 deletions(-)
--=20
2.25.3
[PULL 1/8] tests/fuzz/Makefile: Do not link code using unavailable devices
From: Philippe Mathieu-Daudé <[email protected]>
Some devices availability depends on CONFIG options. Use these options to only link tests when requested device is available.
Message-id: [email protected]
--- tests/qtest/fuzz/Makefile.include | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tests/qtest/fuzz/Makefile.include +3 -3
@@ -7,9 +7,9 @@ fuzz-obj-y += tests/qtest/fuzz/fork_fuzz.o fuzz-obj-y += tests/qtest/fuzz/qos_fuzz.o # Targets -fuzz-obj-y += tests/qtest/fuzz/i440fx_fuzz.o -fuzz-obj-y += tests/qtest/fuzz/virtio_net_fuzz.o -fuzz-obj-y += tests/qtest/fuzz/virtio_scsi_fuzz.o +fuzz-obj-$(CONFIG_PCI_I440FX) += tests/qtest/fuzz/i440fx_fuzz.o +fuzz-obj-$(CONFIG_VIRTIO_NET) += tests/qtest/fuzz/virtio_net_fuzz.o +fuzz-obj-$(CONFIG_SCSI) += tests/qtest/fuzz/virtio_scsi_fuzz.o FUZZ_CFLAGS += -I$(SRC_PATH)/tests -I$(SRC_PATH)/tests/qtest
Signature · 1 line
2.25.3
[PULL 2/8] Makefile: List fuzz targets in 'make help'
In reply to Stefan HajnocziFrom: Philippe Mathieu-Daudé <[email protected]>
List softmmu fuzz targets in 'make help' output:
$ make help ... Architecture specific targets: aarch64-softmmu/all - Build for aarch64-softmmu aarch64-softmmu/fuzz - Build fuzzer for aarch64-softmmu alpha-softmmu/all - Build for alpha-softmmu alpha-softmmu/fuzz - Build fuzzer for alpha-softmmu arm-softmmu/all - Build for arm-softmmu arm-softmmu/fuzz - Build fuzzer for arm-softmmu ...
Message-id: [email protected]
--- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
Makefile +5 -1
@@ -1252,7 +1252,11 @@ endif @$(if $(TARGET_DIRS), \ echo 'Architecture specific targets:'; \ $(foreach t, $(TARGET_DIRS), \ - $(call print-help-run,$(t)/all,Build for $(t));) \ + $(call print-help-run,$(t)/all,Build for $(t)); \ + $(if $(CONFIG_FUZZ), \ + $(if $(findstring softmmu,$(t)), \ + $(call print-help-run,$(t)/fuzz,Build fuzzer for $(t)); \ + ))) \ echo '') @$(if $(TOOLS), \ echo 'Tools targets:'; \
Signature · 1 line
2.25.3
[PULL 3/8] tests/fuzz: Add missing space in test description
In reply to Stefan HajnocziFrom: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
--- tests/qtest/fuzz/i440fx_fuzz.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tests/qtest/fuzz/i440fx_fuzz.c +3 -3
@@ -159,7 +159,7 @@ static void register_pci_fuzz_targets(void)/* Uses simple qtest commands and reboots to reset state */ fuzz_add_target (&(FuzzTarget ){ .name ="i440fx-qtest-reboot-fuzz" , - .description ="Fuzz the i440fx using raw qtest commands and" + .description ="Fuzz the i440fx using raw qtest commands and " "rebooting after each run" , .get_init_cmdline = i440fx_argv, .fuzz = i440fx_fuzz_qtest});
@@ -167,7 +167,7 @@ static void register_pci_fuzz_targets(void)/* Uses libqos and forks to prevent state leakage */ fuzz_add_qos_target(&(FuzzTarget){ .name = "i440fx-qos-fork-fuzz", - .description = "Fuzz the i440fx using raw qtest commands and" + .description = "Fuzz the i440fx using raw qtest commands and " "rebooting after each run", .pre_vm_init = &fork_init, .fuzz = i440fx_fuzz_qos_fork,},
@@ -182,7 +182,7 @@ static void register_pci_fuzz_targets(void)*/ fuzz_add_qos_target(&(FuzzTarget){ .name = "i440fx-qos-noreset-fuzz", - .description = "Fuzz the i440fx using raw qtest commands and" + .description = "Fuzz the i440fx using raw qtest commands and " "rebooting after each run", .fuzz = i440fx_fuzz_qos,}, "i440FX-pcihost",
Signature · 1 line
2.25.3
[PULL 5/8] tests/fuzz: Extract pciconfig_fuzz_qos() method
In reply to Stefan HajnocziFrom: Philippe Mathieu-Daudé <[email protected]>
Extract the generic pciconfig_fuzz_qos() method from i440fx_fuzz_qos(). This will help to write tests not specific to the i440FX controller.
Message-id: [email protected]
--- tests/qtest/fuzz/i440fx_fuzz.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-)
tests/qtest/fuzz/i440fx_fuzz.c +14 -6
@@ -84,7 +84,7 @@ static void i440fx_fuzz_qtest(QTestState *s,flush_events (s); } -static void i440fx_fuzz_qos (QTestState *s, +static void pciconfig_fuzz_qos (QTestState *s,QPCIBus *bus,const unsigned char *Data,size_t Size) {/* * Same as i440fx_fuzz_qtest, but using QOS. devfn is incorporated into the
@@ -97,11 +97,6 @@ static void i440fx_fuzz_qos(QTestState *s,uint32_t value; } a; -static QPCIBus *bus; -if (!bus) { - bus =qpci_new_pc (s, fuzz_qos_alloc); - } -while (Size >=sizeof (a)) {memcpy (&a, Data,sizeof (a));switch (a.opcode %ACTION_MAX ) {
@@ -130,6 +125,19 @@ static void i440fx_fuzz_qos(QTestState *s,flush_events (s); } +static void i440fx_fuzz_qos (QTestState *s, +const unsigned char *Data, +size_t Size) +{ +static QPCIBus *bus; + +if (!bus) { + bus =qpci_new_pc (s, fuzz_qos_alloc); + } + +pciconfig_fuzz_qos (s, bus, Data, Size); +} +static void i440fx_fuzz_qos_fork (QTestState *s,const unsigned char *Data,size_t Size) {if (fork () ==0 ) {
Signature · 1 line
2.25.3
[PULL 4/8] tests/fuzz: Remove unuseful/unused typedefs
In reply to Stefan HajnocziFrom: Philippe Mathieu-Daudé <[email protected]>
These typedefs are not used. Use a simple structure, remote the typedefs.
Message-id: [email protected]
--- tests/qtest/fuzz/i440fx_fuzz.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
tests/qtest/fuzz/i440fx_fuzz.c +4 -6
@@ -45,12 +45,11 @@ static void i440fx_fuzz_qtest(QTestState *s,* loop over the Data, breaking it up into actions. each action has an * opcode, address offset and value */ -typedef struct QTestFuzzAction { +struct {uint8_t opcode;uint8_t addr;uint32_t value; - }QTestFuzzAction ; -QTestFuzzAction a; + } a;while (Size >=sizeof (a)) {/* make a copy of the action so we can normalize the values in-place */
@@ -91,19 +90,18 @@ static void i440fx_fuzz_qos(QTestState *s,* Same as i440fx_fuzz_qtest, but using QOS. devfn is incorporated into the * value written over Port IO */ -typedef struct QOSFuzzAction { +struct {uint8_t opcode;uint8_t offset;int devfn;uint32_t value; - }QOSFuzzAction ; + } a;static QPCIBus *bus;if (!bus) { bus =qpci_new_pc (s, fuzz_qos_alloc); } -QOSFuzzAction a;while (Size >=sizeof (a)) {memcpy (&a, Data,sizeof (a));switch (a.opcode %ACTION_MAX ) {
Signature · 1 line
2.25.3
[PULL 6/8] tests/fuzz: Extract ioport_fuzz_qtest() method
In reply to Stefan HajnocziFrom: Philippe Mathieu-Daudé <[email protected]>
Extract generic ioport_fuzz_qtest() method from i440fx_fuzz_qtest(). This will help to write tests not specific to the i440FX controller.
Message-id: [email protected]
--- tests/qtest/fuzz/i440fx_fuzz.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
tests/qtest/fuzz/i440fx_fuzz.c +9 -2
@@ -39,7 +39,7 @@ enum action_id { ACTION_MAX }; -static void i440fx_fuzz_qtest (QTestState *s, +static void ioport_fuzz_qtest (QTestState *s,const unsigned char *Data,size_t Size) {/* * loop over the Data, breaking it up into actions. each action has an
@@ -84,10 +84,17 @@ static void i440fx_fuzz_qtest(QTestState *s,flush_events (s); } +static void i440fx_fuzz_qtest (QTestState *s, +const unsigned char *Data, +size_t Size) +{ +ioport_fuzz_qtest (s, Data, Size); +} +static void pciconfig_fuzz_qos (QTestState *s,QPCIBus *bus,const unsigned char *Data,size_t Size) {/* -* Same as i440fx_fuzz_qtest, but using QOS. devfn is incorporated into the +* Same as ioport_fuzz_qtest, but using QOS. devfn is incorporated into the * value written over Port IO */ struct {
Signature · 1 line
2.25.3
[PULL 7/8] aio-posix: don't duplicate fd handler deletion in fdmon_io_uring_destroy()
In reply to Stefan HajnocziThe io_uring file descriptor monitoring implementation has an internal list of fd handlers that are pending submission to io_uring. fdmon_io_uring_destroy() deletes all fd handlers on the list.
Don't delete fd handlers directly in fdmon_io_uring_destroy() for two reasons:
1. This duplicates the aio-posix.c AioHandler deletion code and could become outdated if the struct changes.
2. Only handlers with the FDMON_IO_URING_REMOVE flag set are safe to remove. If the flag is not set then something still has a pointer to the fd handler. Let aio-posix.c and its user worry about that. In practice this isn't an issue because fdmon_io_uring_destroy() is only called when shutting down so all users have removed their fd handlers, but the next patch will need this!
Message-id: [email protected]
--- util/aio-posix.c | 1 + util/fdmon-io_uring.c | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-)
util/aio-posix.c +1 -0
@@ -679,6 +679,7 @@ void aio_context_destroy(AioContext *ctx) {fdmon_io_uring_destroy (ctx);fdmon_epoll_disable (ctx); +aio_free_deleted_handlers (ctx); } void aio_context_set_poll_params(AioContext *ctx, int64_t max_ns,
util/fdmon-io_uring.c +10 -3
@@ -342,11 +342,18 @@ void fdmon_io_uring_destroy(AioContext *ctx)io_uring_queue_exit (&ctx->fdmon_io_uring); -/* No need to submit these anymore, just free them. */ +/* Move handlers due to be removed onto the deleted list */ while ((node =QSLIST_FIRST_RCU (&ctx->submit_list))) { +unsigned flags =atomic_fetch_and (&node->flags, + ~(FDMON_IO_URING_PENDING | +FDMON_IO_URING_ADD | +FDMON_IO_URING_REMOVE )); + +if (flags &FDMON_IO_URING_REMOVE ) { +QLIST_INSERT_HEAD_RCU (&ctx->deleted_aio_handlers, node, node_deleted); + } +QSLIST_REMOVE_HEAD_RCU (&ctx->submit_list, node_submitted); -QLIST_REMOVE (node, node); -g_free (node); } ctx->fdmon_ops = &fdmon_poll_ops;
Signature · 1 line
2.25.3
[PULL 8/8] aio-posix: disable fdmon-io_uring when GSource is used
In reply to Stefan HajnocziThe glib event loop does not call fdmon_io_uring_wait() so fd handlers waiting to be submitted build up in the list. There is no benefit is using io_uring when the glib GSource is being used, so disable it instead of implementing a more complex fix.
This fixes a memory leak where AioHandlers would build up and increasing amounts of CPU time were spent iterating them in aio_pending(). The symptom is that guests become slow when QEMU is built with io_uring support.
Message-id: [email protected]
--- include/block/aio.h | 3 +++ util/aio-posix.c | 12 ++++++++++++ util/aio-win32.c | 4 ++++ util/async.c | 1 + 4 files changed, 20 insertions(+)
include/block/aio.h +3 -0
@@ -701,6 +701,9 @@ void aio_context_setup(AioContext *ctx);*/ void aio_context_destroy (AioContext *ctx); +/* Used internally, do not call outside AioContext code */ +void aio_context_use_g_source (AioContext *ctx); +/** * aio_context_set_poll_params: * @ctx: the aio context
util/aio-posix.c +12 -0
@@ -682,6 +682,18 @@ void aio_context_destroy(AioContext *ctx)aio_free_deleted_handlers (ctx); } +void aio_context_use_g_source (AioContext *ctx) +{ +/* +* Disable io_uring when the glib main loop is used because it doesn't +* support mixed glib/aio_poll() usage. It relies on aio_poll() being +* called regularly so that changes to the monitored file descriptors are +* submitted, otherwise a list of pending fd handlers builds up. +*/ +fdmon_io_uring_destroy (ctx); +aio_free_deleted_handlers (ctx); +} +void aio_context_set_poll_params (AioContext *ctx,int64_t max_ns,int64_t grow,int64_t shrink,Error **errp) {
util/aio-win32.c +4 -0
@@ -414,6 +414,10 @@ void aio_context_destroy(AioContext *ctx) { } +void aio_context_use_g_source (AioContext *ctx) +{ +} +void aio_context_set_poll_params (AioContext *ctx,int64_t max_ns,int64_t grow,int64_t shrink,Error **errp) {
util/async.c +1 -0
@@ -362,6 +362,7 @@ static GSourceFuncs aio_source_funcs = {GSource *aio_get_g_source (AioContext *ctx) { +aio_context_use_g_source (ctx);g_source_ref (&ctx->source);return &ctx->source; }
Signature · 1 line
2.25.3
Peter Maydell
AppliedQuoted 10 lines · Stefan Hajnoczi
The following changes since commit
013a18edbbc59cdad019100c7d03c0494642b74c:Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-2020051=
4' into staging (2020-05-14 16:17:55 +0100)are available in the Git repository at:
https://github.com/stefanha/qemu.git tags/block-pull-request
Quoted 7 lines
for you to fetch changes up to
ba607ca8bff4d2c2062902f8355657c865ac7c29:aio-posix: disable fdmon-io_uring when GSource is used (2020-05-18 18:16:00=
+0100)----------------------------------------------------------------
Pull request
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/5.1
for any user-visible changes.
-- PMM