From nobody Sat Feb 7 05:26:35 2026 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; dkim=fail; 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1543261365960394.77265028770864; Mon, 26 Nov 2018 11:42:45 -0800 (PST) Received: from localhost ([::1]:38439 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRMmE-0000fS-5i for importer@patchew.org; Mon, 26 Nov 2018 14:42:38 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45126) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRMkN-000818-8O for qemu-devel@nongnu.org; Mon, 26 Nov 2018 14:40:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRMkL-0004FD-K1 for qemu-devel@nongnu.org; Mon, 26 Nov 2018 14:40:43 -0500 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]:45941) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gRMkL-0004DB-DS for qemu-devel@nongnu.org; Mon, 26 Nov 2018 14:40:41 -0500 Received: by mail-wr1-x42a.google.com with SMTP id v6so20216851wrr.12 for ; Mon, 26 Nov 2018 11:40:41 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id s139sm2412468wmd.3.2018.11.26.11.40.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Nov 2018 11:40:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=lTUDU3hDqZC0diMBxV7Afo1Jwu0U8lVdulWZCPgxIAk=; b=K/iFkrCCLNrMXvswuh2GQdKPrgY4WJqfq1O/PtF1jomHW4XXXjPoy1cPZsp45Q5ek8 e8iL/Cnc2exBmCXCSiqRlS57RzPayrJlyYKoU5DlaFzc5b9Mq//liFVMbnubh26uiHtO jRXpThq7N3O/MrLa7tSq2vcYvbpm5C81iIVIbl7Vpo5kxO4OEYB1yPaQ71jTZBh0++6d 4pqi/fKRu0mBKGfnUL4Yln5dt4nKBZ/uN7ppmbJ5KkrA8oLgctAFOJujL3LoI/mMTZee +mmiid6iA1Ft8cdtP3I/sI65V5pxFU7CYMnZGcfncnpXXttH4siyYcuXxrM4RFhRimoi rOKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=lTUDU3hDqZC0diMBxV7Afo1Jwu0U8lVdulWZCPgxIAk=; b=NhAFAlURfwNLmrM5ieF+3GUWazFT5ywWvGgBGZNLBqBSVRD5FL8FghsKqiNH/Po5ID LOzHSFXnd6lnoJvDbgB+tQ6pcZ+vAIhDW8mpbClALRW4YNMW64val04FHyqhYZGQQQUX OW0IVQjcLyRvMLcboHFpq6qOmdmUpFmDWJvtyqXrmM5W3mwjBCzxYZdBUWNFZJ7ohDEM QFhVBHgU2+5a2R5fL51IRcMA4bw5WgiGWkzZZdwQnU7VT/1suRmhd5mVhvGDC/07fHSN fBe8NgFSHTcKmlj8H4Xk2NzpV0CooRbz9gNGAyfNbq1l13QgXgr10XBNsVv7++0UcMem 6ZRA== X-Gm-Message-State: AA+aEWbE/6asBbPyuQey48s+ema3CmWa4t4Ts9Kigkl6irVuLnE1fZ43 lCzcjGBVKjesMyxpE9aY0TlXjWiJ X-Google-Smtp-Source: AFSGD/XuxxArElc5IkgAEEw1P+rUHqXvuDuJuF+OWwQLp7Y+0DzGZqEWEnCJfQ2EaOLFu2HqV+9xGQ== X-Received: by 2002:adf:a357:: with SMTP id d23mr25851615wrb.195.1543261239926; Mon, 26 Nov 2018 11:40:39 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 26 Nov 2018 20:40:22 +0100 Message-Id: <1543261235-2834-3-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1543261235-2834-1-git-send-email-pbonzini@redhat.com> References: <1543261235-2834-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42a Subject: [Qemu-devel] [PULL 02/15] cpus: run work items for all vCPUs if single-threaded 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This avoids the following I/O thread deadlock: 1) the I/O thread calls run_on_cpu for CPU 3 from a timer. single_tcg_halt= _cond is signaled 2) CPU 1 is running and exits. It finds no work item and enters CPU 2 3) because the I/O thread is stuck in run_on_cpu, the round-robin kick timer never triggers, and CPU 3 never runs the work item 4) run_on_cpu never completes Reviewed-by: Emilio G. Cota Signed-off-by: Paolo Bonzini --- cpus.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cpus.c b/cpus.c index a2b33cc..0ddeeef 100644 --- a/cpus.c +++ b/cpus.c @@ -1220,16 +1220,20 @@ static void qemu_wait_io_event_common(CPUState *cpu) process_queued_cpu_work(cpu); } =20 -static void qemu_tcg_rr_wait_io_event(CPUState *cpu) +static void qemu_tcg_rr_wait_io_event(void) { + CPUState *cpu; + while (all_cpu_threads_idle()) { stop_tcg_kick_timer(); - qemu_cond_wait(cpu->halt_cond, &qemu_global_mutex); + qemu_cond_wait(first_cpu->halt_cond, &qemu_global_mutex); } =20 start_tcg_kick_timer(); =20 - qemu_wait_io_event_common(cpu); + CPU_FOREACH(cpu) { + qemu_wait_io_event_common(cpu); + } } =20 static void qemu_wait_io_event(CPUState *cpu) @@ -1562,7 +1566,7 @@ static void *qemu_tcg_rr_cpu_thread_fn(void *arg) qemu_notify_event(); } =20 - qemu_tcg_rr_wait_io_event(cpu ? cpu : first_cpu); + qemu_tcg_rr_wait_io_event(); deal_with_unplugged_cpus(); } =20 --=20 1.8.3.1