From patchwork Tue Jun 7 16:31:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 9161979 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0E9FC60572 for ; Tue, 7 Jun 2016 16:31:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0124325819 for ; Tue, 7 Jun 2016 16:31:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EA0E1281F9; Tue, 7 Jun 2016 16:31:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2597027B13 for ; Tue, 7 Jun 2016 16:31:46 +0000 (UTC) Received: from localhost ([::1]:51520 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAJur-0007nv-9v for patchwork-qemu-devel@patchwork.kernel.org; Tue, 07 Jun 2016 12:31:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59701) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAJuO-0007jA-KI for qemu-devel@nongnu.org; Tue, 07 Jun 2016 12:31:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bAJuM-0006Xe-Fo for qemu-devel@nongnu.org; Tue, 07 Jun 2016 12:31:15 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:57601) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAJuM-0006UU-8k for qemu-devel@nongnu.org; Tue, 07 Jun 2016 12:31:14 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.84_2) (envelope-from ) id 1bAJuC-0000XQ-GE; Tue, 07 Jun 2016 17:31:04 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Tue, 7 Jun 2016 17:31:04 +0100 Message-Id: <1465317064-26781-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.9.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PATCH] linux-user: In fork_end(), remove correct CPUs from CPU list 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: Riku Voipio , Laurent Vivier , patches@linaro.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP In fork_end(), we must fix the list of current CPUs to match the fact that the child of the fork has only one thread. Unfortunately we were removing the wrong CPUs from the list, which meant that if the child subsequently did an exclusive operation it would deadlock in start_exclusive() waiting for a sibling CPU which didn't exist. In particular this could cause hangs doing git submodule init operations, as reported in https://bugs.launchpad.net/qemu/+bug/955379 comment #47. Signed-off-by: Peter Maydell --- linux-user/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/main.c b/linux-user/main.c index b6da0ba..150a356 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -130,7 +130,7 @@ void fork_end(int child) Discard information about the parent threads. */ CPU_FOREACH_SAFE(cpu, next_cpu) { if (cpu != thread_cpu) { - QTAILQ_REMOVE(&cpus, thread_cpu, node); + QTAILQ_REMOVE(&cpus, cpu, node); } } pending_cpus = 0;