* [Qemu-devel] [PATCH] thread-pool: clean up thread_pool_completion_bh()
@ 2015-04-02 16:39 Stefan Hajnoczi
2015-04-02 17:12 ` Paolo Bonzini
2015-04-07 13:45 ` Stefan Hajnoczi
0 siblings, 2 replies; 3+ messages in thread
From: Stefan Hajnoczi @ 2015-04-02 16:39 UTC (permalink / raw)
To: qemu-devel; +Cc: Kevin Wolf, Paolo Bonzini, John Snow, Stefan Hajnoczi
This patch simplifies thread_pool_completion_bh().
The function first checks elem->state:
if (elem->state != THREAD_DONE) {
continue;
}
It then goes on to check elem->state == THREAD_DONE although we already
know this must be the case.
The QLIST_REMOVE() is duplicated down both branches of an if-else
statement so that can be lifted out as well.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
thread-pool.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/thread-pool.c b/thread-pool.c
index e2cac8e..ac909f4 100644
--- a/thread-pool.c
+++ b/thread-pool.c
@@ -170,12 +170,12 @@ restart:
if (elem->state != THREAD_DONE) {
continue;
}
- if (elem->state == THREAD_DONE) {
- trace_thread_pool_complete(pool, elem, elem->common.opaque,
- elem->ret);
- }
- if (elem->state == THREAD_DONE && elem->common.cb) {
- QLIST_REMOVE(elem, all);
+
+ trace_thread_pool_complete(pool, elem, elem->common.opaque,
+ elem->ret);
+ QLIST_REMOVE(elem, all);
+
+ if (elem->common.cb) {
/* Read state before ret. */
smp_rmb();
@@ -188,8 +188,6 @@ restart:
qemu_aio_unref(elem);
goto restart;
} else {
- /* remove the request */
- QLIST_REMOVE(elem, all);
qemu_aio_unref(elem);
}
}
--
2.1.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] thread-pool: clean up thread_pool_completion_bh()
2015-04-02 16:39 [Qemu-devel] [PATCH] thread-pool: clean up thread_pool_completion_bh() Stefan Hajnoczi
@ 2015-04-02 17:12 ` Paolo Bonzini
2015-04-07 13:45 ` Stefan Hajnoczi
1 sibling, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2015-04-02 17:12 UTC (permalink / raw)
To: Stefan Hajnoczi, qemu-devel; +Cc: Kevin Wolf, John Snow
On 02/04/2015 18:39, Stefan Hajnoczi wrote:
> This patch simplifies thread_pool_completion_bh().
>
> The function first checks elem->state:
>
> if (elem->state != THREAD_DONE) {
> continue;
> }
>
> It then goes on to check elem->state == THREAD_DONE although we already
> know this must be the case.
And not once, twice. :)
This was the outcome of removing THREAD_CANCELED.
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
> thread-pool.c | 14 ++++++--------
> 1 file changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/thread-pool.c b/thread-pool.c
> index e2cac8e..ac909f4 100644
> --- a/thread-pool.c
> +++ b/thread-pool.c
> @@ -170,12 +170,12 @@ restart:
> if (elem->state != THREAD_DONE) {
> continue;
> }
> - if (elem->state == THREAD_DONE) {
> - trace_thread_pool_complete(pool, elem, elem->common.opaque,
> - elem->ret);
> - }
> - if (elem->state == THREAD_DONE && elem->common.cb) {
> - QLIST_REMOVE(elem, all);
> +
> + trace_thread_pool_complete(pool, elem, elem->common.opaque,
> + elem->ret);
> + QLIST_REMOVE(elem, all);
> +
> + if (elem->common.cb) {
> /* Read state before ret. */
> smp_rmb();
>
> @@ -188,8 +188,6 @@ restart:
> qemu_aio_unref(elem);
> goto restart;
> } else {
> - /* remove the request */
> - QLIST_REMOVE(elem, all);
> qemu_aio_unref(elem);
> }
> }
>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] thread-pool: clean up thread_pool_completion_bh()
2015-04-02 16:39 [Qemu-devel] [PATCH] thread-pool: clean up thread_pool_completion_bh() Stefan Hajnoczi
2015-04-02 17:12 ` Paolo Bonzini
@ 2015-04-07 13:45 ` Stefan Hajnoczi
1 sibling, 0 replies; 3+ messages in thread
From: Stefan Hajnoczi @ 2015-04-07 13:45 UTC (permalink / raw)
To: qemu-devel; +Cc: Kevin Wolf, Paolo Bonzini, John Snow
[-- Attachment #1: Type: text/plain, Size: 728 bytes --]
On Thu, Apr 02, 2015 at 05:39:22PM +0100, Stefan Hajnoczi wrote:
> This patch simplifies thread_pool_completion_bh().
>
> The function first checks elem->state:
>
> if (elem->state != THREAD_DONE) {
> continue;
> }
>
> It then goes on to check elem->state == THREAD_DONE although we already
> know this must be the case.
>
> The QLIST_REMOVE() is duplicated down both branches of an if-else
> statement so that can be lifted out as well.
>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
> thread-pool.c | 14 ++++++--------
> 1 file changed, 6 insertions(+), 8 deletions(-)
Thanks, applied to my block-next tree:
https://github.com/stefanha/qemu/commits/block-next
Stefan
[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-04-07 13:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-02 16:39 [Qemu-devel] [PATCH] thread-pool: clean up thread_pool_completion_bh() Stefan Hajnoczi
2015-04-02 17:12 ` Paolo Bonzini
2015-04-07 13:45 ` Stefan Hajnoczi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).