All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] qmp: don't hold ctx lock while querying blockstats
@ 2020-07-10  8:54 ` Zhenyu Ye
  0 siblings, 0 replies; 6+ messages in thread
From: Zhenyu Ye @ 2020-07-10  8:54 UTC (permalink / raw)
  To: qemu-devel
  Cc: yezhenyu2, armbru, kwolf, mreitz, qemu-block, qemu-trivial,
	xiexiangyou

Because the QMP command runs in the main thread, and changes
to the aio context of iothread will only be executed in the
main thread (they will not be in parallel), so there is no
need a lock protection while querying blockstats.

If we hold the lock here, while the I/O pressure is high in
vm and the I/O returns slowly, the main thread will be stuck
until the lock is released, which will affect the vcpu operation
and finall cause the vm to be stuck.

Signed-off-by: Zhenyu Ye <yezhenyu2@huawei.com>
---
 block/qapi.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/block/qapi.c b/block/qapi.c
index afd9f3b4a7..fa56bc145d 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -609,11 +609,8 @@ BlockStatsList *qmp_query_blockstats(bool has_query_nodes,
     if (has_query_nodes && query_nodes) {
         for (bs = bdrv_next_node(NULL); bs; bs = bdrv_next_node(bs)) {
             BlockStatsList *info = g_malloc0(sizeof(*info));
-            AioContext *ctx = bdrv_get_aio_context(bs);
 
-            aio_context_acquire(ctx);
             info->value = bdrv_query_bds_stats(bs, false);
-            aio_context_release(ctx);
 
             *p_next = info;
             p_next = &info->next;
@@ -621,7 +618,6 @@ BlockStatsList *qmp_query_blockstats(bool has_query_nodes,
     } else {
         for (blk = blk_all_next(NULL); blk; blk = blk_all_next(blk)) {
             BlockStatsList *info;
-            AioContext *ctx = blk_get_aio_context(blk);
             BlockStats *s;
             char *qdev;
 
@@ -629,7 +625,6 @@ BlockStatsList *qmp_query_blockstats(bool has_query_nodes,
                 continue;
             }
 
-            aio_context_acquire(ctx);
             s = bdrv_query_bds_stats(blk_bs(blk), true);
             s->has_device = true;
             s->device = g_strdup(blk_name(blk));
@@ -643,7 +638,6 @@ BlockStatsList *qmp_query_blockstats(bool has_query_nodes,
             }
 
             bdrv_query_blk_stats(s->stats, blk);
-            aio_context_release(ctx);
 
             info = g_malloc0(sizeof(*info));
             info->value = s;
-- 
2.19.1




^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-07-10 13:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-07-10  8:54 [PATCH v1] qmp: don't hold ctx lock while querying blockstats Zhenyu Ye
2020-07-10  8:54 ` Zhenyu Ye
2020-07-10  9:27 ` no-reply
2020-07-10  9:27   ` no-reply
2020-07-10  9:40 ` Kevin Wolf
2020-07-10  9:40   ` Kevin Wolf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.