Blame SOURCES/kvm-aio-wait-Increase-num_waiters-even-in-home-thread.patch

357786
From efb378ef6983c9f7cc7cdb2cc0540a52b05ff916 Mon Sep 17 00:00:00 2001
357786
From: Kevin Wolf <kwolf@redhat.com>
357786
Date: Fri, 14 Sep 2018 10:55:26 +0200
357786
Subject: [PATCH 35/49] aio-wait: Increase num_waiters even in home thread
357786
357786
RH-Author: Kevin Wolf <kwolf@redhat.com>
357786
Message-id: <20180914105540.18077-29-kwolf@redhat.com>
357786
Patchwork-id: 82179
357786
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH 28/42] aio-wait: Increase num_waiters even in home thread
357786
Bugzilla: 1601212
357786
RH-Acked-by: John Snow <jsnow@redhat.com>
357786
RH-Acked-by: Max Reitz <mreitz@redhat.com>
357786
RH-Acked-by: Fam Zheng <famz@redhat.com>
357786
357786
Even if AIO_WAIT_WHILE() is called in the home context of the
357786
AioContext, we still want to allow the condition to change depending on
357786
other threads as long as they kick the AioWait. Specfically block jobs
357786
can be running in an I/O thread and should then be able to kick a drain
357786
in the main loop context.
357786
357786
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
357786
Reviewed-by: Fam Zheng <famz@redhat.com>
357786
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
357786
---
357786
 include/block/aio-wait.h | 6 +++---
357786
 1 file changed, 3 insertions(+), 3 deletions(-)
357786
357786
diff --git a/include/block/aio-wait.h b/include/block/aio-wait.h
357786
index c85a62f..600fad1 100644
357786
--- a/include/block/aio-wait.h
357786
+++ b/include/block/aio-wait.h
357786
@@ -76,6 +76,8 @@ typedef struct {
357786
     bool waited_ = false;                                          \
357786
     AioWait *wait_ = (wait);                                       \
357786
     AioContext *ctx_ = (ctx);                                      \
357786
+    /* Increment wait_->num_waiters before evaluating cond. */     \
357786
+    atomic_inc(&wait_->num_waiters);                               \
357786
     if (ctx_ && in_aio_context_home_thread(ctx_)) {                \
357786
         while ((cond)) {                                           \
357786
             aio_poll(ctx_, true);                                  \
357786
@@ -84,8 +86,6 @@ typedef struct {
357786
     } else {                                                       \
357786
         assert(qemu_get_current_aio_context() ==                   \
357786
                qemu_get_aio_context());                            \
357786
-        /* Increment wait_->num_waiters before evaluating cond. */ \
357786
-        atomic_inc(&wait_->num_waiters);                           \
357786
         while ((cond)) {                                           \
357786
             if (ctx_) {                                            \
357786
                 aio_context_release(ctx_);                         \
357786
@@ -96,8 +96,8 @@ typedef struct {
357786
             }                                                      \
357786
             waited_ = true;                                        \
357786
         }                                                          \
357786
-        atomic_dec(&wait_->num_waiters);                           \
357786
     }                                                              \
357786
+    atomic_dec(&wait_->num_waiters);                               \
357786
     waited_; })
357786
 
357786
 /**
357786
-- 
357786
1.8.3.1
357786