1 | The following changes since commit 6cb4f6db4f4367faa33da85b15f75bbbd2bed2a6: | 1 | The following changes since commit ef9f8fcbec6276414921dcd042575129a6331a2d: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/cleber/tags/python-next-pull-request' into staging (2019-03-07 16:16:02 +0000) | 3 | Merge remote-tracking branch 'remotes/stefanberger/tags/pull-tpm-2020-03-04-2' into staging (2020-03-05 19:39:47 +0000) |
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://github.com/stefanha/qemu.git tags/block-pull-request |
8 | 8 | ||
9 | for you to fetch changes up to 6ca206204fa773c8626d59caf2a5676d6cc35f52: | 9 | for you to fetch changes up to 1f40ace7b5634f93801c8474b9eb77fe2e00289c: |
10 | 10 | ||
11 | iothread: document about why we need explicit aio_poll() (2019-03-08 10:20:57 +0000) | 11 | tests: Fix a bug with count variables (2020-03-06 10:35:15 +0000) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | Pull request | 14 | Pull request |
15 | 15 | ||
16 | These patches would have gone through Thomas Huth but he is away on leave. | ||
17 | |||
16 | ---------------------------------------------------------------- | 18 | ---------------------------------------------------------------- |
17 | 19 | ||
18 | Anastasiia Rusakova (1): | 20 | Alexander Bulekov (2): |
19 | hw/block/virtio-blk: Clean req->dev repetitions | 21 | fuzz: fix style/typos in linker-script comments |
22 | qtest: fix fuzzer-related 80-char limit violations | ||
20 | 23 | ||
21 | Peter Xu (5): | 24 | Tianjia Zhang (1): |
22 | iothread: replace init_done_cond with a semaphore | 25 | tests: Fix a bug with count variables |
23 | iothread: create the gcontext unconditionally | ||
24 | iothread: create main loop unconditionally | ||
25 | iothread: push gcontext earlier in the thread_fn | ||
26 | iothread: document about why we need explicit aio_poll() | ||
27 | 26 | ||
28 | Stefan Hajnoczi (1): | 27 | qtest.c | 3 ++- |
29 | MAINTAINERS: add missing support status fields | 28 | tests/qtest/fuzz/fork_fuzz.ld | 16 ++++++++++------ |
30 | 29 | tests/qtest/fuzz/qos_fuzz.c | 5 ++++- | |
31 | MAINTAINERS | 3 ++ | 30 | tests/test-rcu-list.c | 2 +- |
32 | include/sysemu/iothread.h | 5 +-- | 31 | 4 files changed, 17 insertions(+), 9 deletions(-) |
33 | hw/block/virtio-blk.c | 16 ++++--- | ||
34 | iothread.c | 90 +++++++++++++++++++-------------------- | ||
35 | 4 files changed, 57 insertions(+), 57 deletions(-) | ||
36 | 32 | ||
37 | -- | 33 | -- |
38 | 2.20.1 | 34 | 2.24.1 |
39 | 35 | ||
40 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | This patch adds the "S:" line for areas of the codebase that currently | ||
2 | lack a support status field. | ||
3 | 1 | ||
4 | Note that there are a few more areas that are more abstract and do not | ||
5 | correspond to a specific set of files. They have not been modified. | ||
6 | |||
7 | Cc: Alex Bennée <alex.bennee@linaro.org> | ||
8 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
9 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
10 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
11 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
12 | Message-id: 20190301163518.20702-1-stefanha@redhat.com | ||
13 | Message-Id: <20190301163518.20702-1-stefanha@redhat.com> | ||
14 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
15 | --- | ||
16 | MAINTAINERS | 3 +++ | ||
17 | 1 file changed, 3 insertions(+) | ||
18 | |||
19 | diff --git a/MAINTAINERS b/MAINTAINERS | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/MAINTAINERS | ||
22 | +++ b/MAINTAINERS | ||
23 | @@ -XXX,XX +XXX,XX @@ F: include/hw/tricore/ | ||
24 | |||
25 | Multiarch Linux User Tests | ||
26 | M: Alex Bennée <alex.bennee@linaro.org> | ||
27 | +S: Maintained | ||
28 | F: tests/tcg/multiarch/ | ||
29 | |||
30 | Guest CPU Cores (KVM): | ||
31 | @@ -XXX,XX +XXX,XX @@ F: qemu.sasl | ||
32 | Coroutines | ||
33 | M: Stefan Hajnoczi <stefanha@redhat.com> | ||
34 | M: Kevin Wolf <kwolf@redhat.com> | ||
35 | +S: Maintained | ||
36 | F: util/*coroutine* | ||
37 | F: include/qemu/coroutine* | ||
38 | F: tests/test-coroutine.c | ||
39 | @@ -XXX,XX +XXX,XX @@ F: .gitlab-ci.yml | ||
40 | Guest Test Compilation Support | ||
41 | M: Alex Bennée <alex.bennee@linaro.org> | ||
42 | R: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
43 | +S: Maintained | ||
44 | F: tests/tcg/Makefile | ||
45 | F: tests/tcg/Makefile.include | ||
46 | L: qemu-devel@nongnu.org | ||
47 | -- | ||
48 | 2.20.1 | ||
49 | |||
50 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Anastasiia Rusakova <arusakova917@gmail.com> | ||
2 | 1 | ||
3 | Some functions sometimes uses req->dev even though a local variable | ||
4 | VirtIOBlock* s = req->dev has already been defined. | ||
5 | Updated places to use s everywhere in the file. | ||
6 | |||
7 | Signed-off-by: Anastasiia Rusakova <arusakova917@gmail.com> | ||
8 | Message-id: 20190307161925.4158-1-rusakova.nastasia@icloud.com | ||
9 | Message-Id: <20190307161925.4158-1-rusakova.nastasia@icloud.com> | ||
10 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
11 | --- | ||
12 | hw/block/virtio-blk.c | 16 +++++++++------- | ||
13 | 1 file changed, 9 insertions(+), 7 deletions(-) | ||
14 | |||
15 | diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/block/virtio-blk.c | ||
18 | +++ b/hw/block/virtio-blk.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static void virtio_blk_rw_complete(void *opaque, int ret) | ||
20 | } | ||
21 | |||
22 | if (ret) { | ||
23 | - int p = virtio_ldl_p(VIRTIO_DEVICE(req->dev), &req->out.type); | ||
24 | + int p = virtio_ldl_p(VIRTIO_DEVICE(s), &req->out.type); | ||
25 | bool is_read = !(p & VIRTIO_BLK_T_OUT); | ||
26 | /* Note that memory may be dirtied on read failure. If the | ||
27 | * virtio request is not completed here, as is the case for | ||
28 | @@ -XXX,XX +XXX,XX @@ static void virtio_blk_rw_complete(void *opaque, int ret) | ||
29 | } | ||
30 | |||
31 | virtio_blk_req_complete(req, VIRTIO_BLK_S_OK); | ||
32 | - block_acct_done(blk_get_stats(req->dev->blk), &req->acct); | ||
33 | + block_acct_done(blk_get_stats(s->blk), &req->acct); | ||
34 | virtio_blk_free_request(req); | ||
35 | } | ||
36 | aio_context_release(blk_get_aio_context(s->conf.conf.blk)); | ||
37 | @@ -XXX,XX +XXX,XX @@ static int virtio_blk_handle_scsi_req(VirtIOBlockReq *req) | ||
38 | { | ||
39 | int status = VIRTIO_BLK_S_OK; | ||
40 | struct virtio_scsi_inhdr *scsi = NULL; | ||
41 | - VirtIODevice *vdev = VIRTIO_DEVICE(req->dev); | ||
42 | - VirtQueueElement *elem = &req->elem; | ||
43 | VirtIOBlock *blk = req->dev; | ||
44 | + VirtIODevice *vdev = VIRTIO_DEVICE(blk); | ||
45 | + VirtQueueElement *elem = &req->elem; | ||
46 | |||
47 | #ifdef __linux__ | ||
48 | int i; | ||
49 | @@ -XXX,XX +XXX,XX @@ static void virtio_blk_submit_multireq(BlockBackend *blk, MultiReqBuffer *mrb) | ||
50 | |||
51 | static void virtio_blk_handle_flush(VirtIOBlockReq *req, MultiReqBuffer *mrb) | ||
52 | { | ||
53 | - block_acct_start(blk_get_stats(req->dev->blk), &req->acct, 0, | ||
54 | + VirtIOBlock *s = req->dev; | ||
55 | + | ||
56 | + block_acct_start(blk_get_stats(s->blk), &req->acct, 0, | ||
57 | BLOCK_ACCT_FLUSH); | ||
58 | |||
59 | /* | ||
60 | * Make sure all outstanding writes are posted to the backing device. | ||
61 | */ | ||
62 | if (mrb->is_write && mrb->num_reqs > 0) { | ||
63 | - virtio_blk_submit_multireq(req->dev->blk, mrb); | ||
64 | + virtio_blk_submit_multireq(s->blk, mrb); | ||
65 | } | ||
66 | - blk_aio_flush(req->dev->blk, virtio_blk_flush_complete, req); | ||
67 | + blk_aio_flush(s->blk, virtio_blk_flush_complete, req); | ||
68 | } | ||
69 | |||
70 | static bool virtio_blk_sect_range_ok(VirtIOBlock *dev, | ||
71 | -- | ||
72 | 2.20.1 | ||
73 | |||
74 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Peter Xu <peterx@redhat.com> | ||
2 | 1 | ||
3 | Only sending an init-done message using lock+cond seems an overkill to | ||
4 | me. Replacing it with a simpler semaphore. | ||
5 | |||
6 | Meanwhile, init the semaphore unconditionally, then we can destroy it | ||
7 | unconditionally too in finalize which seems cleaner. | ||
8 | |||
9 | Signed-off-by: Peter Xu <peterx@redhat.com> | ||
10 | Message-id: 20190306115532.23025-2-peterx@redhat.com | ||
11 | Message-Id: <20190306115532.23025-2-peterx@redhat.com> | ||
12 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
13 | --- | ||
14 | include/sysemu/iothread.h | 3 +-- | ||
15 | iothread.c | 17 ++++------------- | ||
16 | 2 files changed, 5 insertions(+), 15 deletions(-) | ||
17 | |||
18 | diff --git a/include/sysemu/iothread.h b/include/sysemu/iothread.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/include/sysemu/iothread.h | ||
21 | +++ b/include/sysemu/iothread.h | ||
22 | @@ -XXX,XX +XXX,XX @@ typedef struct { | ||
23 | GMainContext *worker_context; | ||
24 | GMainLoop *main_loop; | ||
25 | GOnce once; | ||
26 | - QemuMutex init_done_lock; | ||
27 | - QemuCond init_done_cond; /* is thread initialization done? */ | ||
28 | + QemuSemaphore init_done_sem; /* is thread init done? */ | ||
29 | bool stopping; /* has iothread_stop() been called? */ | ||
30 | bool running; /* should iothread_run() continue? */ | ||
31 | int thread_id; | ||
32 | diff --git a/iothread.c b/iothread.c | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/iothread.c | ||
35 | +++ b/iothread.c | ||
36 | @@ -XXX,XX +XXX,XX @@ static void *iothread_run(void *opaque) | ||
37 | rcu_register_thread(); | ||
38 | |||
39 | my_iothread = iothread; | ||
40 | - qemu_mutex_lock(&iothread->init_done_lock); | ||
41 | iothread->thread_id = qemu_get_thread_id(); | ||
42 | - qemu_cond_signal(&iothread->init_done_cond); | ||
43 | - qemu_mutex_unlock(&iothread->init_done_lock); | ||
44 | + qemu_sem_post(&iothread->init_done_sem); | ||
45 | |||
46 | while (iothread->running) { | ||
47 | aio_poll(iothread->ctx, true); | ||
48 | @@ -XXX,XX +XXX,XX @@ static void iothread_instance_init(Object *obj) | ||
49 | |||
50 | iothread->poll_max_ns = IOTHREAD_POLL_MAX_NS_DEFAULT; | ||
51 | iothread->thread_id = -1; | ||
52 | + qemu_sem_init(&iothread->init_done_sem, 0); | ||
53 | } | ||
54 | |||
55 | static void iothread_instance_finalize(Object *obj) | ||
56 | @@ -XXX,XX +XXX,XX @@ static void iothread_instance_finalize(Object *obj) | ||
57 | |||
58 | iothread_stop(iothread); | ||
59 | |||
60 | - if (iothread->thread_id != -1) { | ||
61 | - qemu_cond_destroy(&iothread->init_done_cond); | ||
62 | - qemu_mutex_destroy(&iothread->init_done_lock); | ||
63 | - } | ||
64 | /* | ||
65 | * Before glib2 2.33.10, there is a glib2 bug that GSource context | ||
66 | * pointer may not be cleared even if the context has already been | ||
67 | @@ -XXX,XX +XXX,XX @@ static void iothread_instance_finalize(Object *obj) | ||
68 | g_main_context_unref(iothread->worker_context); | ||
69 | iothread->worker_context = NULL; | ||
70 | } | ||
71 | + qemu_sem_destroy(&iothread->init_done_sem); | ||
72 | } | ||
73 | |||
74 | static void iothread_complete(UserCreatable *obj, Error **errp) | ||
75 | @@ -XXX,XX +XXX,XX @@ static void iothread_complete(UserCreatable *obj, Error **errp) | ||
76 | return; | ||
77 | } | ||
78 | |||
79 | - qemu_mutex_init(&iothread->init_done_lock); | ||
80 | - qemu_cond_init(&iothread->init_done_cond); | ||
81 | iothread->once = (GOnce) G_ONCE_INIT; | ||
82 | |||
83 | /* This assumes we are called from a thread with useful CPU affinity for us | ||
84 | @@ -XXX,XX +XXX,XX @@ static void iothread_complete(UserCreatable *obj, Error **errp) | ||
85 | g_free(name); | ||
86 | |||
87 | /* Wait for initialization to complete */ | ||
88 | - qemu_mutex_lock(&iothread->init_done_lock); | ||
89 | while (iothread->thread_id == -1) { | ||
90 | - qemu_cond_wait(&iothread->init_done_cond, | ||
91 | - &iothread->init_done_lock); | ||
92 | + qemu_sem_wait(&iothread->init_done_sem); | ||
93 | } | ||
94 | - qemu_mutex_unlock(&iothread->init_done_lock); | ||
95 | } | ||
96 | |||
97 | typedef struct { | ||
98 | -- | ||
99 | 2.20.1 | ||
100 | |||
101 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Peter Xu <peterx@redhat.com> | ||
2 | 1 | ||
3 | In existing code we create the gcontext dynamically at the first | ||
4 | access of the gcontext from caller. That can bring some complexity | ||
5 | and potential races during using iothread. Since the context itself | ||
6 | is not that big a resource, and we won't have millions of iothread, | ||
7 | let's simply create the gcontext unconditionally. | ||
8 | |||
9 | This will also be a preparation work further to move the thread | ||
10 | context push operation earlier than before (now it's only pushed right | ||
11 | before we want to start running the gmainloop). | ||
12 | |||
13 | Removing the g_once since it's not necessary, while introducing a new | ||
14 | run_gcontext boolean to show whether we want to run the gcontext. | ||
15 | |||
16 | Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> | ||
17 | Signed-off-by: Peter Xu <peterx@redhat.com> | ||
18 | Message-id: 20190306115532.23025-3-peterx@redhat.com | ||
19 | Message-Id: <20190306115532.23025-3-peterx@redhat.com> | ||
20 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
21 | --- | ||
22 | include/sysemu/iothread.h | 2 +- | ||
23 | iothread.c | 43 +++++++++++++++++++-------------------- | ||
24 | 2 files changed, 22 insertions(+), 23 deletions(-) | ||
25 | |||
26 | diff --git a/include/sysemu/iothread.h b/include/sysemu/iothread.h | ||
27 | index XXXXXXX..XXXXXXX 100644 | ||
28 | --- a/include/sysemu/iothread.h | ||
29 | +++ b/include/sysemu/iothread.h | ||
30 | @@ -XXX,XX +XXX,XX @@ typedef struct { | ||
31 | |||
32 | QemuThread thread; | ||
33 | AioContext *ctx; | ||
34 | + bool run_gcontext; /* whether we should run gcontext */ | ||
35 | GMainContext *worker_context; | ||
36 | GMainLoop *main_loop; | ||
37 | - GOnce once; | ||
38 | QemuSemaphore init_done_sem; /* is thread init done? */ | ||
39 | bool stopping; /* has iothread_stop() been called? */ | ||
40 | bool running; /* should iothread_run() continue? */ | ||
41 | diff --git a/iothread.c b/iothread.c | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/iothread.c | ||
44 | +++ b/iothread.c | ||
45 | @@ -XXX,XX +XXX,XX @@ static void *iothread_run(void *opaque) | ||
46 | * We must check the running state again in case it was | ||
47 | * changed in previous aio_poll() | ||
48 | */ | ||
49 | - if (iothread->running && atomic_read(&iothread->worker_context)) { | ||
50 | + if (iothread->running && atomic_read(&iothread->run_gcontext)) { | ||
51 | GMainLoop *loop; | ||
52 | |||
53 | g_main_context_push_thread_default(iothread->worker_context); | ||
54 | @@ -XXX,XX +XXX,XX @@ static void iothread_instance_init(Object *obj) | ||
55 | iothread->poll_max_ns = IOTHREAD_POLL_MAX_NS_DEFAULT; | ||
56 | iothread->thread_id = -1; | ||
57 | qemu_sem_init(&iothread->init_done_sem, 0); | ||
58 | + /* By default, we don't run gcontext */ | ||
59 | + atomic_set(&iothread->run_gcontext, 0); | ||
60 | } | ||
61 | |||
62 | static void iothread_instance_finalize(Object *obj) | ||
63 | @@ -XXX,XX +XXX,XX @@ static void iothread_instance_finalize(Object *obj) | ||
64 | qemu_sem_destroy(&iothread->init_done_sem); | ||
65 | } | ||
66 | |||
67 | +static void iothread_init_gcontext(IOThread *iothread) | ||
68 | +{ | ||
69 | + GSource *source; | ||
70 | + | ||
71 | + iothread->worker_context = g_main_context_new(); | ||
72 | + source = aio_get_g_source(iothread_get_aio_context(iothread)); | ||
73 | + g_source_attach(source, iothread->worker_context); | ||
74 | + g_source_unref(source); | ||
75 | +} | ||
76 | + | ||
77 | static void iothread_complete(UserCreatable *obj, Error **errp) | ||
78 | { | ||
79 | Error *local_error = NULL; | ||
80 | @@ -XXX,XX +XXX,XX @@ static void iothread_complete(UserCreatable *obj, Error **errp) | ||
81 | return; | ||
82 | } | ||
83 | |||
84 | + /* | ||
85 | + * Init one GMainContext for the iothread unconditionally, even if | ||
86 | + * it's not used | ||
87 | + */ | ||
88 | + iothread_init_gcontext(iothread); | ||
89 | + | ||
90 | aio_context_set_poll_params(iothread->ctx, | ||
91 | iothread->poll_max_ns, | ||
92 | iothread->poll_grow, | ||
93 | @@ -XXX,XX +XXX,XX @@ static void iothread_complete(UserCreatable *obj, Error **errp) | ||
94 | return; | ||
95 | } | ||
96 | |||
97 | - iothread->once = (GOnce) G_ONCE_INIT; | ||
98 | - | ||
99 | /* This assumes we are called from a thread with useful CPU affinity for us | ||
100 | * to inherit. | ||
101 | */ | ||
102 | @@ -XXX,XX +XXX,XX @@ IOThreadInfoList *qmp_query_iothreads(Error **errp) | ||
103 | return head; | ||
104 | } | ||
105 | |||
106 | -static gpointer iothread_g_main_context_init(gpointer opaque) | ||
107 | -{ | ||
108 | - AioContext *ctx; | ||
109 | - IOThread *iothread = opaque; | ||
110 | - GSource *source; | ||
111 | - | ||
112 | - iothread->worker_context = g_main_context_new(); | ||
113 | - | ||
114 | - ctx = iothread_get_aio_context(iothread); | ||
115 | - source = aio_get_g_source(ctx); | ||
116 | - g_source_attach(source, iothread->worker_context); | ||
117 | - g_source_unref(source); | ||
118 | - | ||
119 | - aio_notify(iothread->ctx); | ||
120 | - return NULL; | ||
121 | -} | ||
122 | - | ||
123 | GMainContext *iothread_get_g_main_context(IOThread *iothread) | ||
124 | { | ||
125 | - g_once(&iothread->once, iothread_g_main_context_init, iothread); | ||
126 | - | ||
127 | + atomic_set(&iothread->run_gcontext, 1); | ||
128 | + aio_notify(iothread->ctx); | ||
129 | return iothread->worker_context; | ||
130 | } | ||
131 | |||
132 | -- | ||
133 | 2.20.1 | ||
134 | |||
135 | diff view generated by jsdifflib |
1 | From: Peter Xu <peterx@redhat.com> | 1 | From: Alexander Bulekov <alxndr@bu.edu> |
---|---|---|---|
2 | 2 | ||
3 | After consulting Paolo I know why we'd better keep the explicit | 3 | Signed-off-by: Alexander Bulekov <alxndr@bu.edu> |
4 | aio_poll() in iothread_run(). Document it directly into the code so | 4 | Reviewed-by: Eric Blake <eblake@redhat.com> |
5 | that future readers will know the answer from day one. | 5 | Reviewed-by: Darren Kenny <darren.kenny@oracle.com> |
6 | 6 | Message-id: 20200227031439.31386-2-alxndr@bu.edu | |
7 | Signed-off-by: Peter Xu <peterx@redhat.com> | ||
8 | Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> | ||
9 | Message-id: 20190306115532.23025-6-peterx@redhat.com | ||
10 | Message-Id: <20190306115532.23025-6-peterx@redhat.com> | ||
11 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 7 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
12 | --- | 8 | --- |
13 | iothread.c | 9 +++++++++ | 9 | tests/qtest/fuzz/fork_fuzz.ld | 16 ++++++++++------ |
14 | 1 file changed, 9 insertions(+) | 10 | 1 file changed, 10 insertions(+), 6 deletions(-) |
15 | 11 | ||
16 | diff --git a/iothread.c b/iothread.c | 12 | diff --git a/tests/qtest/fuzz/fork_fuzz.ld b/tests/qtest/fuzz/fork_fuzz.ld |
17 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/iothread.c | 14 | --- a/tests/qtest/fuzz/fork_fuzz.ld |
19 | +++ b/iothread.c | 15 | +++ b/tests/qtest/fuzz/fork_fuzz.ld |
20 | @@ -XXX,XX +XXX,XX @@ static void *iothread_run(void *opaque) | 16 | @@ -XXX,XX +XXX,XX @@ |
21 | qemu_sem_post(&iothread->init_done_sem); | 17 | -/* We adjust linker script modification to place all of the stuff that needs to |
22 | 18 | - * persist across fuzzing runs into a contiguous seciton of memory. Then, it is | |
23 | while (iothread->running) { | 19 | +/* |
24 | + /* | 20 | + * We adjust linker script modification to place all of the stuff that needs to |
25 | + * Note: from functional-wise the g_main_loop_run() below can | 21 | + * persist across fuzzing runs into a contiguous section of memory. Then, it is |
26 | + * already cover the aio_poll() events, but we can't run the | 22 | * easy to re-map the counter-related memory as shared. |
27 | + * main loop unconditionally because explicit aio_poll() here | 23 | -*/ |
28 | + * is faster than g_main_loop_run() when we do not need the | 24 | + */ |
29 | + * gcontext at all (e.g., pure block layer iothreads). In | 25 | |
30 | + * other words, when we want to run the gcontext with the | 26 | SECTIONS |
31 | + * iothread we need to pay some performance for functionality. | 27 | { |
32 | + */ | 28 | @@ -XXX,XX +XXX,XX @@ SECTIONS |
33 | aio_poll(iothread->ctx, true); | 29 | } |
34 | 30 | .data.fuzz_ordered : | |
35 | /* | 31 | { |
32 | - /* Coverage counters. They're not necessary for fuzzing, but are useful | ||
33 | + /* | ||
34 | + * Coverage counters. They're not necessary for fuzzing, but are useful | ||
35 | * for analyzing the fuzzing performance | ||
36 | */ | ||
37 | __start___llvm_prf_cnts = .; | ||
38 | @@ -XXX,XX +XXX,XX @@ SECTIONS | ||
39 | __FUZZ_COUNTERS_END = .; | ||
40 | } | ||
41 | } | ||
42 | -/* Dont overwrite the SECTIONS in the default linker script. Instead insert the | ||
43 | - * above into the default script */ | ||
44 | +/* | ||
45 | + * Don't overwrite the SECTIONS in the default linker script. Instead insert the | ||
46 | + * above into the default script | ||
47 | + */ | ||
48 | INSERT AFTER .data; | ||
36 | -- | 49 | -- |
37 | 2.20.1 | 50 | 2.24.1 |
38 | 51 | ||
39 | diff view generated by jsdifflib |
1 | From: Peter Xu <peterx@redhat.com> | 1 | From: Alexander Bulekov <alxndr@bu.edu> |
---|---|---|---|
2 | 2 | ||
3 | We were pushing the context until right before running the gmainloop. | 3 | Signed-off-by: Alexander Bulekov <alxndr@bu.edu> |
4 | Now since we have everything unconditionally, we can move this | 4 | Reviewed-by: Eric Blake <eblake@redhat.com> |
5 | earlier. | 5 | Reviewed-by: Darren Kenny <darren.kenny@oracle.com> |
6 | 6 | Message-id: 20200227031439.31386-3-alxndr@bu.edu | |
7 | One benefit is that now it's done even before init_done_sem, so as | ||
8 | long as the iothread user calls iothread_create() and completes, we | ||
9 | know that the thread stack is ready. | ||
10 | |||
11 | Signed-off-by: Peter Xu <peterx@redhat.com> | ||
12 | Message-id: 20190306115532.23025-5-peterx@redhat.com | ||
13 | Message-Id: <20190306115532.23025-5-peterx@redhat.com> | ||
14 | |||
15 | [Tweaked comment wording as discussed with Peter Xu. | ||
16 | --Stefan] | ||
17 | |||
18 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 7 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
19 | --- | 8 | --- |
20 | iothread.c | 9 ++++++--- | 9 | qtest.c | 3 ++- |
21 | 1 file changed, 6 insertions(+), 3 deletions(-) | 10 | tests/qtest/fuzz/qos_fuzz.c | 5 ++++- |
11 | 2 files changed, 6 insertions(+), 2 deletions(-) | ||
22 | 12 | ||
23 | diff --git a/iothread.c b/iothread.c | 13 | diff --git a/qtest.c b/qtest.c |
24 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/iothread.c | 15 | --- a/qtest.c |
26 | +++ b/iothread.c | 16 | +++ b/qtest.c |
27 | @@ -XXX,XX +XXX,XX @@ static void *iothread_run(void *opaque) | 17 | @@ -XXX,XX +XXX,XX @@ void qtest_server_init(const char *qtest_chrdev, const char *qtest_log, Error ** |
28 | IOThread *iothread = opaque; | 18 | } |
29 | 19 | } | |
30 | rcu_register_thread(); | 20 | |
31 | - | 21 | -void qtest_server_set_send_handler(void (*send)(void*, const char*), void *opaque) |
22 | +void qtest_server_set_send_handler(void (*send)(void*, const char*), | ||
23 | + void *opaque) | ||
24 | { | ||
25 | qtest_server_send = send; | ||
26 | qtest_server_send_opaque = opaque; | ||
27 | diff --git a/tests/qtest/fuzz/qos_fuzz.c b/tests/qtest/fuzz/qos_fuzz.c | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/tests/qtest/fuzz/qos_fuzz.c | ||
30 | +++ b/tests/qtest/fuzz/qos_fuzz.c | ||
31 | @@ -XXX,XX +XXX,XX @@ static void walk_path(QOSGraphNode *orig_path, int len) | ||
32 | QOSGraphNode *path; | ||
33 | QOSGraphEdge *edge; | ||
34 | |||
35 | - /* etype set to QEDGE_CONSUMED_BY so that machine can add to the command line */ | ||
32 | + /* | 36 | + /* |
33 | + * g_main_context_push_thread_default() must be called before anything | 37 | + * etype set to QEDGE_CONSUMED_BY so that machine can add to the command |
34 | + * in this new thread uses glib. | 38 | + * line |
35 | + */ | 39 | + */ |
36 | + g_main_context_push_thread_default(iothread->worker_context); | 40 | QOSEdgeType etype = QEDGE_CONSUMED_BY; |
37 | my_iothread = iothread; | 41 | |
38 | iothread->thread_id = qemu_get_thread_id(); | 42 | /* twice QOS_PATH_MAX_ELEMENT_SIZE since each edge can have its arg */ |
39 | qemu_sem_post(&iothread->init_done_sem); | ||
40 | @@ -XXX,XX +XXX,XX @@ static void *iothread_run(void *opaque) | ||
41 | * changed in previous aio_poll() | ||
42 | */ | ||
43 | if (iothread->running && atomic_read(&iothread->run_gcontext)) { | ||
44 | - g_main_context_push_thread_default(iothread->worker_context); | ||
45 | g_main_loop_run(iothread->main_loop); | ||
46 | - g_main_context_pop_thread_default(iothread->worker_context); | ||
47 | } | ||
48 | } | ||
49 | |||
50 | + g_main_context_pop_thread_default(iothread->worker_context); | ||
51 | rcu_unregister_thread(); | ||
52 | return NULL; | ||
53 | } | ||
54 | -- | 43 | -- |
55 | 2.20.1 | 44 | 2.24.1 |
56 | 45 | ||
57 | diff view generated by jsdifflib |
1 | From: Peter Xu <peterx@redhat.com> | 1 | From: Tianjia Zhang <tianjia.zhang@linux.alibaba.com> |
---|---|---|---|
2 | 2 | ||
3 | Since we've have the gcontext always there, create the main loop | 3 | The counting code here should use the local variable n_nodes_local. |
4 | altogether. The iothread_run() is even cleaner. | 4 | Otherwise, the variable n_nodes is counting incorrectly, causing the |
5 | counting logic of the code to be wrong. | ||
5 | 6 | ||
6 | Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> | 7 | Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com> |
7 | Signed-off-by: Peter Xu <peterx@redhat.com> | ||
8 | Message-id: 20190306115532.23025-4-peterx@redhat.com | ||
9 | Message-Id: <20190306115532.23025-4-peterx@redhat.com> | ||
10 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 8 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
9 | Link: https://lore.kernel.org/r/20200207115433.118254-1-tianjia.zhang@linux.alibaba.com | ||
10 | Message-Id: <20200207115433.118254-1-tianjia.zhang@linux.alibaba.com> | ||
11 | --- | 11 | --- |
12 | iothread.c | 12 +++--------- | 12 | tests/test-rcu-list.c | 2 +- |
13 | 1 file changed, 3 insertions(+), 9 deletions(-) | 13 | 1 file changed, 1 insertion(+), 1 deletion(-) |
14 | 14 | ||
15 | diff --git a/iothread.c b/iothread.c | 15 | diff --git a/tests/test-rcu-list.c b/tests/test-rcu-list.c |
16 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/iothread.c | 17 | --- a/tests/test-rcu-list.c |
18 | +++ b/iothread.c | 18 | +++ b/tests/test-rcu-list.c |
19 | @@ -XXX,XX +XXX,XX @@ static void *iothread_run(void *opaque) | 19 | @@ -XXX,XX +XXX,XX @@ static void *rcu_q_updater(void *arg) |
20 | * changed in previous aio_poll() | 20 | j++; |
21 | */ | 21 | if (target_el == j) { |
22 | if (iothread->running && atomic_read(&iothread->run_gcontext)) { | 22 | struct list_element *new_el = g_new(struct list_element, 1); |
23 | - GMainLoop *loop; | 23 | - n_nodes += n_nodes_local; |
24 | - | 24 | + n_nodes_local++; |
25 | g_main_context_push_thread_default(iothread->worker_context); | 25 | TEST_LIST_INSERT_AFTER_RCU(el, new_el, entry); |
26 | - iothread->main_loop = | 26 | break; |
27 | - g_main_loop_new(iothread->worker_context, TRUE); | 27 | } |
28 | - loop = iothread->main_loop; | ||
29 | - | ||
30 | g_main_loop_run(iothread->main_loop); | ||
31 | - iothread->main_loop = NULL; | ||
32 | - g_main_loop_unref(loop); | ||
33 | - | ||
34 | g_main_context_pop_thread_default(iothread->worker_context); | ||
35 | } | ||
36 | } | ||
37 | @@ -XXX,XX +XXX,XX @@ static void iothread_instance_finalize(Object *obj) | ||
38 | if (iothread->worker_context) { | ||
39 | g_main_context_unref(iothread->worker_context); | ||
40 | iothread->worker_context = NULL; | ||
41 | + g_main_loop_unref(iothread->main_loop); | ||
42 | + iothread->main_loop = NULL; | ||
43 | } | ||
44 | qemu_sem_destroy(&iothread->init_done_sem); | ||
45 | } | ||
46 | @@ -XXX,XX +XXX,XX @@ static void iothread_init_gcontext(IOThread *iothread) | ||
47 | source = aio_get_g_source(iothread_get_aio_context(iothread)); | ||
48 | g_source_attach(source, iothread->worker_context); | ||
49 | g_source_unref(source); | ||
50 | + iothread->main_loop = g_main_loop_new(iothread->worker_context, TRUE); | ||
51 | } | ||
52 | |||
53 | static void iothread_complete(UserCreatable *obj, Error **errp) | ||
54 | -- | 28 | -- |
55 | 2.20.1 | 29 | 2.24.1 |
56 | 30 | ||
57 | diff view generated by jsdifflib |