From patchwork Fri Jul 10 08:54:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhenyu Ye X-Patchwork-Id: 11656053 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8132714B7 for ; Fri, 10 Jul 2020 08:55:05 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4278A207BC for ; Fri, 10 Jul 2020 08:55:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4278A207BC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:42570 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jtooC-0000Rm-IP for patchwork-qemu-devel@patchwork.kernel.org; Fri, 10 Jul 2020 04:55:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36886) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jtonb-0008Q1-Oq; Fri, 10 Jul 2020 04:54:27 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:3718 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jtonZ-0008B1-I4; Fri, 10 Jul 2020 04:54:27 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id A981EC9A05AA6EA97629; Fri, 10 Jul 2020 16:54:16 +0800 (CST) Received: from DESKTOP-KKJBAGG.china.huawei.com (10.174.186.75) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.487.0; Fri, 10 Jul 2020 16:54:06 +0800 From: Zhenyu Ye To: Subject: [PATCH v1] qmp: don't hold ctx lock while querying blockstats Date: Fri, 10 Jul 2020 16:54:00 +0800 Message-ID: <20200710085400.343-1-yezhenyu2@huawei.com> X-Mailer: git-send-email 2.22.0.windows.1 MIME-Version: 1.0 X-Originating-IP: [10.174.186.75] X-CFilter-Loop: Reflected Received-SPF: pass client-ip=45.249.212.190; envelope-from=yezhenyu2@huawei.com; helo=huawei.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/10 04:54:17 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-block@nongnu.org, yezhenyu2@huawei.com, qemu-trivial@nongnu.org, armbru@redhat.com, xiexiangyou@huawei.com, mreitz@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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 --- 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;