From patchwork Sun Oct 21 14:21:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Clement Deschamps X-Patchwork-Id: 987316 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=greensocs.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=greensocs.com header.i=@greensocs.com header.b="jvKl3h4R"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=greensocs.com header.i=@greensocs.com header.b="uRep4AQ7"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=greensocs.com header.i=@greensocs.com header.b="uRep4AQ7"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42dMRc5ZVLz9sCm for ; Mon, 22 Oct 2018 01:27:08 +1100 (AEDT) Received: from localhost ([::1]:59100 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEEh8-0000O4-D6 for incoming@patchwork.ozlabs.org; Sun, 21 Oct 2018 10:27:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33563) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEEfD-0007cG-21 for qemu-devel@nongnu.org; Sun, 21 Oct 2018 10:25:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gEEbr-0000t9-5I for qemu-devel@nongnu.org; Sun, 21 Oct 2018 10:21:44 -0400 Received: from greensocs.com ([193.104.36.180]:38143) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEEbq-0000rv-QV for qemu-devel@nongnu.org; Sun, 21 Oct 2018 10:21:39 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 9D5B05C025D; Sun, 21 Oct 2018 16:21:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1540131688; bh=uPJ6AAU87ij0vj0TKMLyflLaQ9cGpa7XNqe+rNchcRQ=; h=From:To:Cc:Subject:Date; b=jvKl3h4REf412ujS90Ot5aUcP3fB/t4bB4gHp5Hs6i5f5ftSbB3vRV/RkiO5K16CB 9KVpGAY//Ag+RrcR6cr2NytfdAZGl1YvRWvLlOHG0utDcG3vPkjarW93BBHXq8/6HD sTIJc8r7MTowSKPtHjCt0sjE4JuXsC1YQJZkTHV8= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=uRep4AQ7; dkim=pass (1024-bit key) header.d=greensocs.com header.b=uRep4AQ7 Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id i-4kprfcx2Jw; Sun, 21 Oct 2018 16:21:27 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id E29B85C0267; Sun, 21 Oct 2018 16:21:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1540131687; bh=uPJ6AAU87ij0vj0TKMLyflLaQ9cGpa7XNqe+rNchcRQ=; h=From:To:Cc:Subject:Date; b=uRep4AQ70FTo+ocX3EnWlW2aTOkxlqyR/FLNztXbVbNnv8Mu6IAsz/jAho4Rl5H3l roDSJrWR3D8S7lOpH20ndPz+ngA91IrpAjcgu5gOZxwMnN6yIoW3Ygc+zLkOqtbKiK DZPD8xjbhIHs8OcQw08OROR3pdVBQHSye2RqsMYk= Received: from localhost.localdomain (lfbn-1-8164-133.w90-112.abo.wanadoo.fr [90.112.73.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: clement.deschamps@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id 9C50E5C025D; Sun, 21 Oct 2018 16:21:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1540131687; bh=uPJ6AAU87ij0vj0TKMLyflLaQ9cGpa7XNqe+rNchcRQ=; h=From:To:Cc:Subject:Date; b=uRep4AQ70FTo+ocX3EnWlW2aTOkxlqyR/FLNztXbVbNnv8Mu6IAsz/jAho4Rl5H3l roDSJrWR3D8S7lOpH20ndPz+ngA91IrpAjcgu5gOZxwMnN6yIoW3Ygc+zLkOqtbKiK DZPD8xjbhIHs8OcQw08OROR3pdVBQHSye2RqsMYk= From: Clement Deschamps To: qemu-devel@nongnu.org Date: Sun, 21 Oct 2018 16:21:03 +0200 Message-Id: <20181021142103.19014-1-clement.deschamps@greensocs.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH] icount: fix deadlock when all cpus are sleeping 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: pbonzini@redhat.com, Clement Deschamps , artem.k.pisarenko@gmail.com, Pavel.Dovgaluk@ispras.ru Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" When all cpus are sleeping (e.g in WFI), to avoid a deadlock in the main_loop, wake it up in order to start the warp timer. Signed-off-by: Clement Deschamps --- cpus.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cpus.c b/cpus.c index bb2a511483..798d43623a 100644 --- a/cpus.c +++ b/cpus.c @@ -1554,6 +1554,14 @@ static void *qemu_tcg_rr_cpu_thread_fn(void *arg) atomic_mb_set(&cpu->exit_request, 0); } + if (use_icount && all_cpu_threads_idle()) { + /* + * When all cpus are sleeping (e.g in WFI), to avoid a deadlock + * in the main_loop, wake it up in order to start the warp timer. + */ + qemu_notify_event(); + } + qemu_tcg_rr_wait_io_event(cpu ? cpu : first_cpu); deal_with_unplugged_cpus(); }