yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

ae23c9
From 6d0923cbc54fc8eb983f433ca34a09e2a9982035 Mon Sep 17 00:00:00 2001
ae23c9
From: Kevin Wolf <kwolf@redhat.com>
ae23c9
Date: Wed, 10 Oct 2018 20:21:57 +0100
ae23c9
Subject: [PATCH 31/49] aio-wait: Increase num_waiters even in home thread
ae23c9
ae23c9
RH-Author: Kevin Wolf <kwolf@redhat.com>
ae23c9
Message-id: <20181010202213.7372-19-kwolf@redhat.com>
ae23c9
Patchwork-id: 82609
ae23c9
O-Subject: [RHEL-8 qemu-kvm PATCH 28/44] aio-wait: Increase num_waiters even in home thread
ae23c9
Bugzilla: 1637976
ae23c9
RH-Acked-by: Max Reitz <mreitz@redhat.com>
ae23c9
RH-Acked-by: John Snow <jsnow@redhat.com>
ae23c9
RH-Acked-by: Thomas Huth <thuth@redhat.com>
ae23c9
ae23c9
Even if AIO_WAIT_WHILE() is called in the home context of the
ae23c9
AioContext, we still want to allow the condition to change depending on
ae23c9
other threads as long as they kick the AioWait. Specfically block jobs
ae23c9
can be running in an I/O thread and should then be able to kick a drain
ae23c9
in the main loop context.
ae23c9
ae23c9
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ae23c9
Reviewed-by: Fam Zheng <famz@redhat.com>
ae23c9
(cherry picked from commit 486574483aba988c83b20e7d3f1ccd50c4c333d8)
ae23c9
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ae23c9
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
ae23c9
---
ae23c9
 include/block/aio-wait.h | 6 +++---
ae23c9
 1 file changed, 3 insertions(+), 3 deletions(-)
ae23c9
ae23c9
diff --git a/include/block/aio-wait.h b/include/block/aio-wait.h
ae23c9
index c85a62f..600fad1 100644
ae23c9
--- a/include/block/aio-wait.h
ae23c9
+++ b/include/block/aio-wait.h
ae23c9
@@ -76,6 +76,8 @@ typedef struct {
ae23c9
     bool waited_ = false;                                          \
ae23c9
     AioWait *wait_ = (wait);                                       \
ae23c9
     AioContext *ctx_ = (ctx);                                      \
ae23c9
+    /* Increment wait_->num_waiters before evaluating cond. */     \
ae23c9
+    atomic_inc(&wait_->num_waiters);                               \
ae23c9
     if (ctx_ && in_aio_context_home_thread(ctx_)) {                \
ae23c9
         while ((cond)) {                                           \
ae23c9
             aio_poll(ctx_, true);                                  \
ae23c9
@@ -84,8 +86,6 @@ typedef struct {
ae23c9
     } else {                                                       \
ae23c9
         assert(qemu_get_current_aio_context() ==                   \
ae23c9
                qemu_get_aio_context());                            \
ae23c9
-        /* Increment wait_->num_waiters before evaluating cond. */ \
ae23c9
-        atomic_inc(&wait_->num_waiters);                           \
ae23c9
         while ((cond)) {                                           \
ae23c9
             if (ctx_) {                                            \
ae23c9
                 aio_context_release(ctx_);                         \
ae23c9
@@ -96,8 +96,8 @@ typedef struct {
ae23c9
             }                                                      \
ae23c9
             waited_ = true;                                        \
ae23c9
         }                                                          \
ae23c9
-        atomic_dec(&wait_->num_waiters);                           \
ae23c9
     }                                                              \
ae23c9
+    atomic_dec(&wait_->num_waiters);                               \
ae23c9
     waited_; })
ae23c9
 
ae23c9
 /**
ae23c9
-- 
ae23c9
1.8.3.1
ae23c9