From patchwork Wed Dec 28 17:37:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 709383 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 ozlabs.org (Postfix) with ESMTPS id 3tpg1t01Z1z9sXx for ; Thu, 29 Dec 2016 04:38:24 +1100 (AEDT) Received: from localhost ([::1]:60294 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cMIBB-0007K8-2L for incoming@patchwork.ozlabs.org; Wed, 28 Dec 2016 12:38:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33357) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cMIAX-000730-Et for qemu-devel@nongnu.org; Wed, 28 Dec 2016 12:37:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cMIAU-0001at-8F for qemu-devel@nongnu.org; Wed, 28 Dec 2016 12:37:41 -0500 Received: from mout.kundenserver.de ([212.227.126.130]:52915) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cMIAT-0001ai-UW for qemu-devel@nongnu.org; Wed, 28 Dec 2016 12:37:38 -0500 Received: from Quad.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue001 [212.227.15.167]) with ESMTPSA (Nemesis) id 0LfsUN-1csGsG0vO7-00pbok; Wed, 28 Dec 2016 18:37:19 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Wed, 28 Dec 2016 18:37:16 +0100 Message-Id: <1482946636-3743-1-git-send-email-laurent@vivier.eu> X-Mailer: git-send-email 2.7.4 X-Provags-ID: V03:K0:FoCMeTPfdLeHcL8YJEbDRZATpXKzfoKubaAxYCGpRz56Xh3dRtL 0C+NhPYI7VPCkq9qOySSO3r6JkjdIzrBFFiAwTNDNuF6RbhrSkeodkIVtISXl3nbVYSqQNg Xc88R90B51W0b7BgtUfbBDNXfbTlveDOVmCnK9xj73QTGvdzLYd9JFtKDZEK0N6I/vrz6xE dzI5hKgfOhEDm/wKE8H8Q== X-UI-Out-Filterresults: notjunk:1; V01:K0:zvDDmDxZXgM=:7ZXsNC6D/T0VqHV+5CR/J2 NrIKw5Csg8F+DAYQ7aFpP87q6tPG3O+8tpM19Sj3b873c+L1k5bL3rAwwd1t7mdOeTkXy2x4F TY+jLkSrFNewWzibXLSo2+N0jN/fypZFgdWafBIea9ZvBQnz0H6WTBKZGlfv2EjRQUp5QH1d4 MedMjNL0KpXjX83LrNhgKjPDQqIjtGZEdqupb6M7HodVRM9G7QicwOoVK9huL7dUOTSlIf42r +O/Z+5zCsZGS93/+ZR4FPEuhl97B5xsPfLZ/RZ+31PZT7NYWwlwGZ7pGN6dZJUxGVrdwI4adM X3EjZn28kS++t/b63RBB8OvCum2ixq6BBlHIgpsfC761E7lvZzDf8cFlTDAHiUsktqiY9YE+l yQONz+GwOeA09T2aHk7JnfCM3Gm9PJy66ZmH72KI/gfZQDPX0zVlCWc/XmEtcW4RLK3dWfr1m Yi/W9BEG+awGubppEcaWX6iZugYG+esh2Hk5OnvEIhhzMh3pk/PNnmBcXh2OrGQ6IJw0liDOo +JjLYzI44xeKtyLzUiTEY5nTRrvE7+3mQ9Cq9KPwYlcnJ0E4yQFwYEuNBWJHGiDrVNp8B0ObM 3yPi/zdC3jNvl/FqYDUw8yr1X+AClaIKvgBzEhEQQGFndSFFzi4bfscgCR/4oSf+LkqBtt5EV rkl7QhdsYiBMIxFxLL2BpAQEj0zx7qs/mX9piWaDSxVoYag9G1vCr/dwe3NIQU6DrgFE= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.126.130 Subject: [Qemu-devel] [PATCH] linux-user: always start with parallel_cpus set to true 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 , "Emilio G . Cota" , John Paul Adrian Glaubitz , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" We always need real atomics, as we can have shared memory between processes. A good test case is the example from futex(2), futex_demo.c: the use case is mmap(...); fork(); Parent and Child: while(...) __sync_bool_compare_and_swap(...) ... futex(...) In this case we need real atomics in __sync_bool_compare_and_swap(), but as parallel_cpus is set to 0, we don't have. We also revert "b67cb68 linux-user: enable parallel code generation on clone" as parallel_cpus in unconditionally set now. Of course, this doesn't fix atomics that are emulated using cpu_loop_exit_atomic() as we can't stop virtual CPUs from another processes. Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 8 -------- translate-all.c | 4 ++++ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 7b77503..db697c0 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6164,14 +6164,6 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp, sigfillset(&sigmask); sigprocmask(SIG_BLOCK, &sigmask, &info.sigmask); - /* If this is our first additional thread, we need to ensure we - * generate code for parallel execution and flush old translations. - */ - if (!parallel_cpus) { - parallel_cpus = true; - tb_flush(cpu); - } - ret = pthread_create(&info.thread, &attr, clone_func, &info); /* TODO: Free new CPU state if thread creation failed. */ diff --git a/translate-all.c b/translate-all.c index 3dd9214..0b0bb09 100644 --- a/translate-all.c +++ b/translate-all.c @@ -142,7 +142,11 @@ static void *l1_map[V_L1_MAX_SIZE]; /* code generation context */ TCGContext tcg_ctx; +#ifdef CONFIG_USER_ONLY +bool parallel_cpus = true; +#else bool parallel_cpus; +#endif /* translation block context */ #ifdef CONFIG_USER_ONLY