1 | The following changes since commit aceeaa69d28e6f08a24395d0aa6915b687d0a681: | 1 | The following changes since commit d0ed6a69d399ae193959225cdeaa9382746c91cc: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/huth-gitlab/tags/pull-request-2019-12-17' into staging (2019-12-17 15:55:20 +0000) | 3 | Update version for v5.1.0 release (2020-08-11 17:07:03 +0100) |
4 | 4 | ||
5 | are available in the Git repository at: | 5 | are available in the Git repository at: |
6 | 6 | ||
7 | https://github.com/stefanha/qemu.git tags/block-pull-request | 7 | https://github.com/stefanha/qemu.git tags/block-pull-request |
8 | 8 | ||
9 | for you to fetch changes up to 725fe5d10dbd4259b1853b7d253cef83a3c0d22a: | 9 | for you to fetch changes up to 44277bf914471962c9e88e09c859aae65ae109c4: |
10 | 10 | ||
11 | virtio-blk: fix out-of-bounds access to bitmap in notify_guest_bh (2019-12-19 16:20:25 +0000) | 11 | aio-posix: keep aio_notify_me disabled during polling (2020-08-13 13:34:14 = |
12 | +0100) | ||
12 | 13 | ||
13 | ---------------------------------------------------------------- | 14 | ---------------------------------------------------------------- |
14 | Pull request | 15 | Pull request |
15 | 16 | ||
16 | ---------------------------------------------------------------- | 17 | ---------------------------------------------------------------- |
17 | 18 | ||
18 | Li Hangjing (1): | 19 | Stefan Hajnoczi (3): |
19 | virtio-blk: fix out-of-bounds access to bitmap in notify_guest_bh | 20 | async: rename event_notifier_dummy_cb/poll() |
21 | async: always set ctx->notified in aio_notify() | ||
22 | aio-posix: keep aio_notify_me disabled during polling | ||
20 | 23 | ||
21 | Stefan Hajnoczi (2): | 24 | util/aio-posix.c | 47 +++++++++++++++++++++++++---------------------- |
22 | virtio-blk: deprecate SCSI passthrough | 25 | util/async.c | 36 +++++++++++++++++++++++------------- |
23 | docs: fix rst syntax errors in unbuilt docs | 26 | 2 files changed, 48 insertions(+), 35 deletions(-) |
24 | 27 | ||
25 | docs/arm-cpu-features.rst | 6 +++--- | 28 | --=20 |
26 | docs/virtio-net-failover.rst | 4 ++-- | 29 | 2.26.2 |
27 | docs/virtio-pmem.rst | 19 ++++++++++--------- | ||
28 | hw/block/dataplane/virtio-blk.c | 2 +- | ||
29 | qemu-deprecated.texi | 11 +++++++++++ | ||
30 | 5 files changed, 27 insertions(+), 15 deletions(-) | ||
31 | 30 | ||
32 | -- | ||
33 | 2.23.0 | ||
34 | |||
35 | -- | ||
36 | libvir-list mailing list | ||
37 | libvir-list@redhat.com | ||
38 | https://www.redhat.com/mailman/listinfo/libvir-list | ||
39 | diff view generated by jsdifflib |
1 | From: Li Hangjing <lihangjing@baidu.com> | 1 | The event_notifier_*() prefix can be confused with the EventNotifier |
---|---|---|---|
2 | APIs that are also called event_notifier_*(). | ||
2 | 3 | ||
3 | When the number of a virtio-blk device's virtqueues is larger than | 4 | Rename the functions to aio_context_notifier_*() to make it clear that |
4 | BITS_PER_LONG, the out-of-bounds access to bitmap[ ] will occur. | 5 | they relate to the AioContext::notifier field. |
5 | 6 | ||
6 | Fixes: e21737ab15 ("virtio-blk: multiqueue batch notify") | 7 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
7 | Cc: qemu-stable@nongnu.org | 8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
8 | Cc: Stefan Hajnoczi <stefanha@redhat.com> | 9 | Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> |
9 | Signed-off-by: Li Hangjing <lihangjing@baidu.com> | 10 | Message-id: 20200806131802.569478-2-stefanha@redhat.com |
10 | Reviewed-by: Xie Yongji <xieyongji@baidu.com> | ||
11 | Reviewed-by: Chai Wen <chaiwen@baidu.com> | ||
12 | Message-id: 20191216023050.48620-1-lihangjing@baidu.com | ||
13 | Message-Id: <20191216023050.48620-1-lihangjing@baidu.com> | ||
14 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 11 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
15 | --- | 12 | --- |
16 | hw/block/dataplane/virtio-blk.c | 2 +- | 13 | util/async.c | 8 ++++---- |
17 | 1 file changed, 1 insertion(+), 1 deletion(-) | 14 | 1 file changed, 4 insertions(+), 4 deletions(-) |
18 | 15 | ||
19 | diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c | 16 | diff --git a/util/async.c b/util/async.c |
20 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/hw/block/dataplane/virtio-blk.c | 18 | --- a/util/async.c |
22 | +++ b/hw/block/dataplane/virtio-blk.c | 19 | +++ b/util/async.c |
23 | @@ -XXX,XX +XXX,XX @@ static void notify_guest_bh(void *opaque) | 20 | @@ -XXX,XX +XXX,XX @@ static void aio_timerlist_notify(void *opaque, QEMUClockType type) |
24 | memset(s->batch_notify_vqs, 0, sizeof(bitmap)); | 21 | aio_notify(opaque); |
25 | 22 | } | |
26 | for (j = 0; j < nvqs; j += BITS_PER_LONG) { | 23 | |
27 | - unsigned long bits = bitmap[j]; | 24 | -static void event_notifier_dummy_cb(EventNotifier *e) |
28 | + unsigned long bits = bitmap[j / BITS_PER_LONG]; | 25 | +static void aio_context_notifier_dummy_cb(EventNotifier *e) |
29 | 26 | { | |
30 | while (bits != 0) { | 27 | } |
31 | unsigned i = j + ctzl(bits); | 28 | |
29 | /* Returns true if aio_notify() was called (e.g. a BH was scheduled) */ | ||
30 | -static bool event_notifier_poll(void *opaque) | ||
31 | +static bool aio_context_notifier_poll(void *opaque) | ||
32 | { | ||
33 | EventNotifier *e = opaque; | ||
34 | AioContext *ctx = container_of(e, AioContext, notifier); | ||
35 | @@ -XXX,XX +XXX,XX @@ AioContext *aio_context_new(Error **errp) | ||
36 | |||
37 | aio_set_event_notifier(ctx, &ctx->notifier, | ||
38 | false, | ||
39 | - event_notifier_dummy_cb, | ||
40 | - event_notifier_poll); | ||
41 | + aio_context_notifier_dummy_cb, | ||
42 | + aio_context_notifier_poll); | ||
43 | #ifdef CONFIG_LINUX_AIO | ||
44 | ctx->linux_aio = NULL; | ||
45 | #endif | ||
32 | -- | 46 | -- |
33 | 2.23.0 | 47 | 2.26.2 |
34 | 48 | ||
35 | -- | ||
36 | libvir-list mailing list | ||
37 | libvir-list@redhat.com | ||
38 | https://www.redhat.com/mailman/listinfo/libvir-list | ||
39 | diff view generated by jsdifflib |
1 | The .rst files outside docs/{devel,interop,specs} aren't built yet and | 1 | aio_notify() does not set ctx->notified when called with |
---|---|---|---|
2 | therefore a few syntax errors have slipped through. Fix them. | 2 | ctx->aio_notify_me disabled. Therefore aio_notify_me needs to be enabled |
3 | during polling. | ||
4 | |||
5 | This is suboptimal since expensive event_notifier_set(&ctx->notifier) | ||
6 | and event_notifier_test_and_clear(&ctx->notifier) calls are required | ||
7 | when ctx->aio_notify_me is enabled. | ||
8 | |||
9 | Change aio_notify() so that aio->notified is always set, regardless of | ||
10 | ctx->aio_notify_me. This will make polling cheaper since | ||
11 | ctx->aio_notify_me can remain disabled. Move the | ||
12 | event_notifier_test_and_clear() to the fd handler function (which is now | ||
13 | no longer an empty function so "dummy" has been dropped from its name). | ||
14 | |||
15 | The next patch takes advantage of this by optimizing polling in | ||
16 | util/aio-posix.c. | ||
3 | 17 | ||
4 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 18 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
5 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> | 19 | Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> |
6 | Message-Id: <20191111094411.427174-1-stefanha@redhat.com> | 20 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
21 | Message-id: 20200806131802.569478-3-stefanha@redhat.com | ||
22 | |||
23 | [Paolo Bonzini pointed out that the smp_wmb() in aio_notify_accept() | ||
24 | should be smp_wb() but the comment should be smp_wmb() instead of | ||
25 | smp_wb(). Fixed. | ||
26 | --Stefan] | ||
27 | |||
7 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 28 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
8 | --- | 29 | --- |
9 | docs/arm-cpu-features.rst | 6 +++--- | 30 | util/async.c | 32 +++++++++++++++++++++----------- |
10 | docs/virtio-net-failover.rst | 4 ++-- | 31 | 1 file changed, 21 insertions(+), 11 deletions(-) |
11 | docs/virtio-pmem.rst | 19 ++++++++++--------- | ||
12 | 3 files changed, 15 insertions(+), 14 deletions(-) | ||
13 | 32 | ||
14 | diff --git a/docs/arm-cpu-features.rst b/docs/arm-cpu-features.rst | 33 | diff --git a/util/async.c b/util/async.c |
15 | index XXXXXXX..XXXXXXX 100644 | 34 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/docs/arm-cpu-features.rst | 35 | --- a/util/async.c |
17 | +++ b/docs/arm-cpu-features.rst | 36 | +++ b/util/async.c |
18 | @@ -XXX,XX +XXX,XX @@ CPU type is possible with the `query-cpu-model-expansion` QMP command. | 37 | @@ -XXX,XX +XXX,XX @@ LuringState *aio_get_linux_io_uring(AioContext *ctx) |
19 | Below are some examples where `scripts/qmp/qmp-shell` (see the top comment | 38 | |
20 | block in the script for usage) is used to issue the QMP commands. | 39 | void aio_notify(AioContext *ctx) |
21 | 40 | { | |
22 | -(1) Determine which CPU features are available for the `max` CPU type | 41 | - /* Write e.g. bh->scheduled before reading ctx->notify_me. Pairs |
23 | - (Note, we started QEMU with qemu-system-aarch64, so `max` is | 42 | + /* |
24 | - implementing the ARMv8-A reference manual in this case):: | 43 | + * Write e.g. bh->flags before writing ctx->notified. Pairs with smp_mb in |
25 | +1. Determine which CPU features are available for the `max` CPU type | 44 | + * aio_notify_accept. |
26 | + (Note, we started QEMU with qemu-system-aarch64, so `max` is | 45 | + */ |
27 | + implementing the ARMv8-A reference manual in this case):: | 46 | + smp_wmb(); |
28 | 47 | + atomic_set(&ctx->notified, true); | |
29 | (QEMU) query-cpu-model-expansion type=full model={"name":"max"} | ||
30 | { "return": { | ||
31 | diff --git a/docs/virtio-net-failover.rst b/docs/virtio-net-failover.rst | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/docs/virtio-net-failover.rst | ||
34 | +++ b/docs/virtio-net-failover.rst | ||
35 | @@ -XXX,XX +XXX,XX @@ | ||
36 | -======================== | ||
37 | +====================================== | ||
38 | QEMU virtio-net standby (net_failover) | ||
39 | -======================== | ||
40 | +====================================== | ||
41 | |||
42 | This document explains the setup and usage of virtio-net standby feature which | ||
43 | is used to create a net_failover pair of devices. | ||
44 | diff --git a/docs/virtio-pmem.rst b/docs/virtio-pmem.rst | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/docs/virtio-pmem.rst | ||
47 | +++ b/docs/virtio-pmem.rst | ||
48 | @@ -XXX,XX +XXX,XX @@ virtio pmem usage | ||
49 | ----------------- | ||
50 | |||
51 | A virtio pmem device backed by a memory-backend-file can be created on | ||
52 | - the QEMU command line as in the following example: | ||
53 | + the QEMU command line as in the following example:: | ||
54 | |||
55 | - -object memory-backend-file,id=mem1,share,mem-path=./virtio_pmem.img,size=4G | ||
56 | - -device virtio-pmem-pci,memdev=mem1,id=nv1 | ||
57 | + -object memory-backend-file,id=mem1,share,mem-path=./virtio_pmem.img,size=4G | ||
58 | + -device virtio-pmem-pci,memdev=mem1,id=nv1 | ||
59 | |||
60 | - where: | ||
61 | - - "object memory-backend-file,id=mem1,share,mem-path=<image>, size=<image size>" | ||
62 | - creates a backend file with the specified size. | ||
63 | + where: | ||
64 | |||
65 | - - "device virtio-pmem-pci,id=nvdimm1,memdev=mem1" creates a virtio pmem | ||
66 | - pci device whose storage is provided by above memory backend device. | ||
67 | + - "object memory-backend-file,id=mem1,share,mem-path=<image>, size=<image size>" | ||
68 | + creates a backend file with the specified size. | ||
69 | + | 48 | + |
70 | + - "device virtio-pmem-pci,id=nvdimm1,memdev=mem1" creates a virtio pmem | 49 | + /* |
71 | + pci device whose storage is provided by above memory backend device. | 50 | + * Write ctx->notified before reading ctx->notify_me. Pairs |
72 | 51 | * with smp_mb in aio_ctx_prepare or aio_poll. | |
73 | Multiple virtio pmem devices can be created if multiple pairs of "-object" | 52 | */ |
74 | and "-device" are provided. | 53 | smp_mb(); |
75 | @@ -XXX,XX +XXX,XX @@ memory backing has to be added via 'object_add'; afterwards, the virtio | 54 | if (atomic_read(&ctx->notify_me)) { |
76 | pmem device can be added via 'device_add'. | 55 | event_notifier_set(&ctx->notifier); |
77 | 56 | - atomic_mb_set(&ctx->notified, true); | |
78 | For example, the following commands add another 4GB virtio pmem device to | 57 | } |
79 | -the guest: | 58 | } |
80 | +the guest:: | 59 | |
81 | 60 | void aio_notify_accept(AioContext *ctx) | |
82 | (qemu) object_add memory-backend-file,id=mem2,share=on,mem-path=virtio_pmem2.img,size=4G | 61 | { |
83 | (qemu) device_add virtio-pmem-pci,id=virtio_pmem2,memdev=mem2 | 62 | - if (atomic_xchg(&ctx->notified, false) |
63 | -#ifdef WIN32 | ||
64 | - || true | ||
65 | -#endif | ||
66 | - ) { | ||
67 | - event_notifier_test_and_clear(&ctx->notifier); | ||
68 | - } | ||
69 | + atomic_set(&ctx->notified, false); | ||
70 | + | ||
71 | + /* | ||
72 | + * Write ctx->notified before reading e.g. bh->flags. Pairs with smp_wmb | ||
73 | + * in aio_notify. | ||
74 | + */ | ||
75 | + smp_mb(); | ||
76 | } | ||
77 | |||
78 | static void aio_timerlist_notify(void *opaque, QEMUClockType type) | ||
79 | @@ -XXX,XX +XXX,XX @@ static void aio_timerlist_notify(void *opaque, QEMUClockType type) | ||
80 | aio_notify(opaque); | ||
81 | } | ||
82 | |||
83 | -static void aio_context_notifier_dummy_cb(EventNotifier *e) | ||
84 | +static void aio_context_notifier_cb(EventNotifier *e) | ||
85 | { | ||
86 | + AioContext *ctx = container_of(e, AioContext, notifier); | ||
87 | + | ||
88 | + event_notifier_test_and_clear(&ctx->notifier); | ||
89 | } | ||
90 | |||
91 | /* Returns true if aio_notify() was called (e.g. a BH was scheduled) */ | ||
92 | @@ -XXX,XX +XXX,XX @@ AioContext *aio_context_new(Error **errp) | ||
93 | |||
94 | aio_set_event_notifier(ctx, &ctx->notifier, | ||
95 | false, | ||
96 | - aio_context_notifier_dummy_cb, | ||
97 | + aio_context_notifier_cb, | ||
98 | aio_context_notifier_poll); | ||
99 | #ifdef CONFIG_LINUX_AIO | ||
100 | ctx->linux_aio = NULL; | ||
84 | -- | 101 | -- |
85 | 2.23.0 | 102 | 2.26.2 |
86 | 103 | ||
87 | -- | ||
88 | libvir-list mailing list | ||
89 | libvir-list@redhat.com | ||
90 | https://www.redhat.com/mailman/listinfo/libvir-list | diff view generated by jsdifflib |
1 | The Linux virtio_blk.ko guest driver is removing legacy SCSI passthrough | 1 | Polling only monitors the ctx->notified field and does not need the |
---|---|---|---|
2 | support. Deprecate this feature in QEMU too. | 2 | ctx->notifier EventNotifier to be signalled. Keep ctx->aio_notify_me |
3 | disabled while polling to avoid unnecessary EventNotifier syscalls. | ||
4 | |||
5 | This optimization improves virtio-blk 4KB random read performance by | ||
6 | 18%. The following results are with an IOThread and the null-co block | ||
7 | driver: | ||
8 | |||
9 | Test IOPS Error | ||
10 | Before 244518.62 ± 1.20% | ||
11 | After 290706.11 ± 0.44% | ||
3 | 12 | ||
4 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 13 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
5 | Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> | 14 | Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> |
6 | Reviewed-by: Christoph Hellwig <hch@lst.de> | 15 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
7 | Reviewed-by: Thomas Huth <thuth@redhat.com> | 16 | Message-id: 20200806131802.569478-4-stefanha@redhat.com |
8 | Message-id: 20191213144626.1208237-1-stefanha@redhat.com | ||
9 | Message-Id: <20191213144626.1208237-1-stefanha@redhat.com> | ||
10 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 17 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
11 | --- | 18 | --- |
12 | qemu-deprecated.texi | 11 +++++++++++ | 19 | util/aio-posix.c | 47 +++++++++++++++++++++++++---------------------- |
13 | 1 file changed, 11 insertions(+) | 20 | 1 file changed, 25 insertions(+), 22 deletions(-) |
14 | 21 | ||
15 | diff --git a/qemu-deprecated.texi b/qemu-deprecated.texi | 22 | diff --git a/util/aio-posix.c b/util/aio-posix.c |
16 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/qemu-deprecated.texi | 24 | --- a/util/aio-posix.c |
18 | +++ b/qemu-deprecated.texi | 25 | +++ b/util/aio-posix.c |
19 | @@ -XXX,XX +XXX,XX @@ spec you can use the ``-cpu rv64gcsu,priv_spec=v1.9.1`` command line argument. | 26 | @@ -XXX,XX +XXX,XX @@ static bool remove_idle_poll_handlers(AioContext *ctx, int64_t now) |
20 | 27 | * | |
21 | @section Device options | 28 | * Polls for a given time. |
22 | 29 | * | |
23 | +@subsection Emulated device options | 30 | - * Note that ctx->notify_me must be non-zero so this function can detect |
31 | - * aio_notify(). | ||
32 | - * | ||
33 | * Note that the caller must have incremented ctx->list_lock. | ||
34 | * | ||
35 | * Returns: true if progress was made, false otherwise | ||
36 | @@ -XXX,XX +XXX,XX @@ static bool run_poll_handlers(AioContext *ctx, int64_t max_ns, int64_t *timeout) | ||
37 | bool progress; | ||
38 | int64_t start_time, elapsed_time; | ||
39 | |||
40 | - assert(ctx->notify_me); | ||
41 | assert(qemu_lockcnt_count(&ctx->list_lock) > 0); | ||
42 | |||
43 | trace_run_poll_handlers_begin(ctx, max_ns, *timeout); | ||
44 | @@ -XXX,XX +XXX,XX @@ static bool run_poll_handlers(AioContext *ctx, int64_t max_ns, int64_t *timeout) | ||
45 | * @timeout: timeout for blocking wait, computed by the caller and updated if | ||
46 | * polling succeeds. | ||
47 | * | ||
48 | - * ctx->notify_me must be non-zero so this function can detect aio_notify(). | ||
49 | - * | ||
50 | * Note that the caller must have incremented ctx->list_lock. | ||
51 | * | ||
52 | * Returns: true if progress was made, false otherwise | ||
53 | @@ -XXX,XX +XXX,XX @@ bool aio_poll(AioContext *ctx, bool blocking) | ||
54 | AioHandlerList ready_list = QLIST_HEAD_INITIALIZER(ready_list); | ||
55 | int ret = 0; | ||
56 | bool progress; | ||
57 | + bool use_notify_me; | ||
58 | int64_t timeout; | ||
59 | int64_t start = 0; | ||
60 | |||
61 | @@ -XXX,XX +XXX,XX @@ bool aio_poll(AioContext *ctx, bool blocking) | ||
62 | */ | ||
63 | assert(in_aio_context_home_thread(ctx)); | ||
64 | |||
65 | - /* aio_notify can avoid the expensive event_notifier_set if | ||
66 | + qemu_lockcnt_inc(&ctx->list_lock); | ||
24 | + | 67 | + |
25 | +@subsubsection -device virtio-blk,scsi=on|off (since 5.0.0) | 68 | + if (ctx->poll_max_ns) { |
69 | + start = qemu_clock_get_ns(QEMU_CLOCK_REALTIME); | ||
70 | + } | ||
26 | + | 71 | + |
27 | +The virtio-blk SCSI passthrough feature is a legacy VIRTIO feature. VIRTIO 1.0 | 72 | + timeout = blocking ? aio_compute_timeout(ctx) : 0; |
28 | +and later do not support it because the virtio-scsi device was introduced for | 73 | + progress = try_poll_mode(ctx, &timeout); |
29 | +full SCSI support. Use virtio-scsi instead when SCSI passthrough is required. | 74 | + assert(!(timeout && progress)); |
30 | + | 75 | + |
31 | +Note this also applies to ``-device virtio-blk-pci,scsi=on|off'', which is an | 76 | + /* |
32 | +alias. | 77 | + * aio_notify can avoid the expensive event_notifier_set if |
78 | * everything (file descriptors, bottom halves, timers) will | ||
79 | * be re-evaluated before the next blocking poll(). This is | ||
80 | * already true when aio_poll is called with blocking == false; | ||
81 | * if blocking == true, it is only true after poll() returns, | ||
82 | * so disable the optimization now. | ||
83 | */ | ||
84 | - if (blocking) { | ||
85 | + use_notify_me = timeout != 0; | ||
86 | + if (use_notify_me) { | ||
87 | atomic_set(&ctx->notify_me, atomic_read(&ctx->notify_me) + 2); | ||
88 | /* | ||
89 | - * Write ctx->notify_me before computing the timeout | ||
90 | - * (reading bottom half flags, etc.). Pairs with | ||
91 | + * Write ctx->notify_me before reading ctx->notified. Pairs with | ||
92 | * smp_mb in aio_notify(). | ||
93 | */ | ||
94 | smp_mb(); | ||
95 | - } | ||
96 | - | ||
97 | - qemu_lockcnt_inc(&ctx->list_lock); | ||
98 | |||
99 | - if (ctx->poll_max_ns) { | ||
100 | - start = qemu_clock_get_ns(QEMU_CLOCK_REALTIME); | ||
101 | + /* Don't block if aio_notify() was called */ | ||
102 | + if (atomic_read(&ctx->notified)) { | ||
103 | + timeout = 0; | ||
104 | + } | ||
105 | } | ||
106 | |||
107 | - timeout = blocking ? aio_compute_timeout(ctx) : 0; | ||
108 | - progress = try_poll_mode(ctx, &timeout); | ||
109 | - assert(!(timeout && progress)); | ||
110 | - | ||
111 | /* If polling is allowed, non-blocking aio_poll does not need the | ||
112 | * system call---a single round of run_poll_handlers_once suffices. | ||
113 | */ | ||
114 | @@ -XXX,XX +XXX,XX @@ bool aio_poll(AioContext *ctx, bool blocking) | ||
115 | ret = ctx->fdmon_ops->wait(ctx, &ready_list, timeout); | ||
116 | } | ||
117 | |||
118 | - if (blocking) { | ||
119 | + if (use_notify_me) { | ||
120 | /* Finish the poll before clearing the flag. */ | ||
121 | - atomic_store_release(&ctx->notify_me, atomic_read(&ctx->notify_me) - 2); | ||
122 | - aio_notify_accept(ctx); | ||
123 | + atomic_store_release(&ctx->notify_me, | ||
124 | + atomic_read(&ctx->notify_me) - 2); | ||
125 | } | ||
126 | |||
127 | + aio_notify_accept(ctx); | ||
33 | + | 128 | + |
34 | @subsection Block device options | 129 | /* Adjust polling time */ |
35 | 130 | if (ctx->poll_max_ns) { | |
36 | @subsubsection "backing": "" (since 2.12.0) | 131 | int64_t block_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - start; |
37 | -- | 132 | -- |
38 | 2.23.0 | 133 | 2.26.2 |
39 | 134 | ||
40 | -- | ||
41 | libvir-list mailing list | ||
42 | libvir-list@redhat.com | ||
43 | https://www.redhat.com/mailman/listinfo/libvir-list | ||
44 | diff view generated by jsdifflib |