From nobody Thu May 2 14:44:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1594371321; cv=none; d=zohomail.com; s=zohoarc; b=h9OP8nEiieXiHoUGcp6hW30+F+1BrmVHN5IZtZoOs6xA49h5TzwxChVnwE8kym2EP3k5H5hsNb0r5QnvDekMXkVJ74tO14lXuk6RzABB8zezoXSnXt92PF2MVNshogpG5Q5VJarpX9F5amFW2aUNHkqMVDVnrgXxEioGa3tlYcE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594371321; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=oLOdGeUxgGQuxpc4fV33WtPmGegLIDdQmbu9kJHqP54=; b=OuDvjxVJzteYECtenarch+JtZkKeHrcmd9ETRROZAZN6AaNR8QUe5PwRPYXDfjF6kJS5DRfHDaQtpLDWZS5Ty4UGDj26FyimDOzk9koViYZPjb/39yuwjL3KTOeR30XcjZ66IBPVP83ao8ypwBO3YiHLWaIaRmHaG4GOk1G+Pvk= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1594371321116236.42579008100688; Fri, 10 Jul 2020 01:55:21 -0700 (PDT) Received: from localhost ([::1]:42570 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jtooR-0000Rm-Re for importer@patchew.org; Fri, 10 Jul 2020 04:55:19 -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 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.174.186.75] X-CFilter-Loop: Reflected Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" 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_no= des, if (has_query_nodes && query_nodes) { for (bs =3D bdrv_next_node(NULL); bs; bs =3D bdrv_next_node(bs)) { BlockStatsList *info =3D g_malloc0(sizeof(*info)); - AioContext *ctx =3D bdrv_get_aio_context(bs); =20 - aio_context_acquire(ctx); info->value =3D bdrv_query_bds_stats(bs, false); - aio_context_release(ctx); =20 *p_next =3D info; p_next =3D &info->next; @@ -621,7 +618,6 @@ BlockStatsList *qmp_query_blockstats(bool has_query_nod= es, } else { for (blk =3D blk_all_next(NULL); blk; blk =3D blk_all_next(blk)) { BlockStatsList *info; - AioContext *ctx =3D blk_get_aio_context(blk); BlockStats *s; char *qdev; =20 @@ -629,7 +625,6 @@ BlockStatsList *qmp_query_blockstats(bool has_query_nod= es, continue; } =20 - aio_context_acquire(ctx); s =3D bdrv_query_bds_stats(blk_bs(blk), true); s->has_device =3D true; s->device =3D g_strdup(blk_name(blk)); @@ -643,7 +638,6 @@ BlockStatsList *qmp_query_blockstats(bool has_query_nod= es, } =20 bdrv_query_blk_stats(s->stats, blk); - aio_context_release(ctx); =20 info =3D g_malloc0(sizeof(*info)); info->value =3D s; --=20 2.19.1