From nobody Wed Nov 5 12:45:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15343406246279.741050850002352; Wed, 15 Aug 2018 06:43:44 -0700 (PDT) Received: from localhost ([::1]:49707 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fpw5P-0006TI-JR for importer@patchew.org; Wed, 15 Aug 2018 09:43:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60612) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fpw0z-0002yf-7z for qemu-devel@nongnu.org; Wed, 15 Aug 2018 09:39:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fpw0y-0003fd-7k for qemu-devel@nongnu.org; Wed, 15 Aug 2018 09:39:08 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:53130 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fpw0x-0003f9-Rx for qemu-devel@nongnu.org; Wed, 15 Aug 2018 09:39:08 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 751677D84D for ; Wed, 15 Aug 2018 13:39:07 +0000 (UTC) Received: from xz-mi.redhat.com (ovpn-12-105.pek2.redhat.com [10.72.12.105]) by smtp.corp.redhat.com (Postfix) with ESMTP id BC97F178B9; Wed, 15 Aug 2018 13:39:03 +0000 (UTC) From: Peter Xu To: qemu-devel@nongnu.org Date: Wed, 15 Aug 2018 21:37:47 +0800 Message-Id: <20180815133747.25032-14-peterx@redhat.com> In-Reply-To: <20180815133747.25032-1-peterx@redhat.com> References: <20180815133747.25032-1-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 15 Aug 2018 13:39:07 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 15 Aug 2018 13:39:07 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'peterx@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v6 13/13] monitor: reduce different code path for oob X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Dr . David Alan Gilbert" , peterx@redhat.com, Markus Armbruster , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Markus suggests that we should reduce special code paths for out-of-band if possible, so that QMP logic can be simplified. Apply this rule to two places where use_io_thread is used but not completely necessary. Signed-off-by: Peter Xu --- monitor.c | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/monitor.c b/monitor.c index b24a934437..7494885890 100644 --- a/monitor.c +++ b/monitor.c @@ -552,23 +552,15 @@ static void qmp_send_response(Monitor *mon, QDict *rs= p) =20 static void qmp_queue_response(Monitor *mon, QDict *rsp) { - if (mon->use_io_thread) { - /* - * Push a reference to the response queue. The I/O thread - * drains that queue and emits. - */ - qemu_mutex_lock(&mon->qmp.qmp_lock); - g_queue_push_tail(mon->qmp.qmp_responses, qobject_ref(rsp)); - trace_monitor_qmp_response_queue(mon, mon->qmp.qmp_responses->leng= th); - qemu_mutex_unlock(&mon->qmp.qmp_lock); - qemu_bh_schedule(qmp_respond_bh); - } else { - /* - * Not using monitor I/O thread, i.e. we are in the main thread. - * Emit right away. - */ - qmp_send_response(mon, rsp); - } + /* + * Push a reference to the response queue. The I/O thread drains + * that queue and emits. + */ + qemu_mutex_lock(&mon->qmp.qmp_lock); + g_queue_push_tail(mon->qmp.qmp_responses, qobject_ref(rsp)); + trace_monitor_qmp_response_queue(mon, mon->qmp.qmp_responses->length); + qemu_mutex_unlock(&mon->qmp.qmp_lock); + qemu_bh_schedule(qmp_respond_bh); } =20 struct QMPResponse { @@ -4433,12 +4425,9 @@ void monitor_resume(Monitor *mon) if (atomic_dec_fetch(&mon->suspend_cnt) =3D=3D 0) { if (monitor_is_qmp(mon)) { /* - * For QMP monitors that are running in the I/O thread, - * let's kick the thread in case it's sleeping. + * Let's kick the thread in case it's sleeping. */ - if (mon->use_io_thread) { - aio_notify(iothread_get_aio_context(mon_iothread)); - } + aio_notify(iothread_get_aio_context(mon_iothread)); } else { assert(mon->rs); readline_show_prompt(mon->rs); --=20 2.17.1