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

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