From nobody Fri Dec 19 16:01:34 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1487786161482989.9100678911218; Wed, 22 Feb 2017 09:56:01 -0800 (PST) Received: from localhost ([::1]:54455 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgb8y-0004Tu-CA for importer@patchew.org; Wed, 22 Feb 2017 12:56:00 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38027) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgabr-0005n5-Fd for qemu-devel@nongnu.org; Wed, 22 Feb 2017 12:21:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cgabn-00032P-65 for qemu-devel@nongnu.org; Wed, 22 Feb 2017 12:21:47 -0500 Received: from mail-wm0-x234.google.com ([2a00:1450:400c:c09::234]:36226) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cgabn-000320-0Z for qemu-devel@nongnu.org; Wed, 22 Feb 2017 12:21:43 -0500 Received: by mail-wm0-x234.google.com with SMTP id v77so4740108wmv.1 for ; Wed, 22 Feb 2017 09:21:42 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id m80sm2821645wmi.34.2017.02.22.09.21.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Feb 2017 09:21:39 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 9A7593E0658; Wed, 22 Feb 2017 17:13:29 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LcRDmeWpJLXU4tM48xC0y1rBusgeTzyRM25octf/77g=; b=WykPyHA9cnWQxg3CH975h8b2Mzjsu8HCSZaCInn+oWmqJkCqWv/uODhTGGCNE6N9PI NIiikkqp1kzTXk66D+UV/usyO32ohnuy3QYl2o8g8J4kN+tkKQKCEJd3kwgW5Ee0rAwl 4EySC7F+UBqucrEtq6FVIaqH6pwyd3489nIyA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LcRDmeWpJLXU4tM48xC0y1rBusgeTzyRM25octf/77g=; b=S9OQn3GIqZOxF2Dvj8aMkqTpk2s3uRpdr+MO6UJaNpbXhySSyGel0J1Xu+VfqNhfOf pzHKzJh/jkCYyMSDvTK53As9yFEaWeohGem2d/lYnVo7G1hEH1/g7paaoBOPj8JAdA+D JDF1MSDyokyZDxkHsOjt6Kapeiu41eWbk20CBZr5pbPAfrK/I18z/sidDPfN8wMDbkBo 9DpSSUAN7eOtFFmnxFjMzQzWTFLoHdvBsuLCnm6+6qpdUjUnu0ZTjRTI1dVRju2RDcsW GLhCLdvZbjpgTvrsyXKqere4bVIvxbr+774Lrir8o0jbF0PP4cRXeCp6DttK5UVF0VT3 4o0w== X-Gm-Message-State: AMke39lFtF2sQKrSmEAM7G29SWpc4E2wSYpEB0JjHzmcMiidHyy+gtHq8AJnGIb4SUXQriDK X-Received: by 10.28.158.82 with SMTP id h79mr3502820wme.30.1487784101886; Wed, 22 Feb 2017 09:21:41 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: rth@twiddle.net, peter.maydell@linaro.org Date: Wed, 22 Feb 2017 17:13:24 +0000 Message-Id: <20170222171327.26624-22-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170222171327.26624-1-alex.bennee@linaro.org> References: <20170222171327.26624-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::234 Subject: [Qemu-devel] [PATCH v13 21/24] target-arm: don't generate WFE/YIELD calls for MTTCG 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: mttcg@listserver.greensocs.com, nikunj@linux.vnet.ibm.com, jan.kiszka@siemens.com, mark.burton@greensocs.com, a.rigo@virtualopensystems.com, qemu-devel@nongnu.org, cota@braap.org, "open list:ARM" , serge.fdrv@gmail.com, pbonzini@redhat.com, bobby.prani@gmail.com, =?UTF-8?q?Alex=20Benn=C3=A9e?= , bamvor.zhangjian@linaro.org, fred.konrad@greensocs.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 The WFE and YIELD instructions are really only hints and in TCG's case they were useful to move the scheduling on from one vCPU to the next. In the parallel context (MTTCG) this just causes an unnecessary cpu_exit and contention of the BQL. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson Reviewed-by: Peter Maydell --- target/arm/op_helper.c | 7 +++++++ target/arm/translate-a64.c | 8 ++++++-- target/arm/translate.c | 20 ++++++++++++++++---- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c index 5f3e3bdae2..d64c8670fa 100644 --- a/target/arm/op_helper.c +++ b/target/arm/op_helper.c @@ -436,6 +436,13 @@ void HELPER(yield)(CPUARMState *env) ARMCPU *cpu =3D arm_env_get_cpu(env); CPUState *cs =3D CPU(cpu); =20 + /* When running in MTTCG we don't generate jumps to the yield and + * WFE helpers as it won't affect the scheduling of other vCPUs. + * If we wanted to more completely model WFE/SEV so we don't busy + * spin unnecessarily we would need to do something more involved. + */ + g_assert(!parallel_cpus); + /* This is a non-trappable hint instruction that generally indicates * that the guest is currently busy-looping. Yield control back to the * top level loop so that a more deserving VCPU has a chance to run. diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index e61bbd6b3b..e15eae6d41 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -1328,10 +1328,14 @@ static void handle_hint(DisasContext *s, uint32_t i= nsn, s->is_jmp =3D DISAS_WFI; return; case 1: /* YIELD */ - s->is_jmp =3D DISAS_YIELD; + if (!parallel_cpus) { + s->is_jmp =3D DISAS_YIELD; + } return; case 2: /* WFE */ - s->is_jmp =3D DISAS_WFE; + if (!parallel_cpus) { + s->is_jmp =3D DISAS_WFE; + } return; case 4: /* SEV */ case 5: /* SEVL */ diff --git a/target/arm/translate.c b/target/arm/translate.c index 4436d8f3a2..abc1f77ee4 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -4404,20 +4404,32 @@ static void gen_exception_return(DisasContext *s, T= CGv_i32 pc) gen_rfe(s, pc, load_cpu_field(spsr)); } =20 +/* + * For WFI we will halt the vCPU until an IRQ. For WFE and YIELD we + * only call the helper when running single threaded TCG code to ensure + * the next round-robin scheduled vCPU gets a crack. In MTTCG mode we + * just skip this instruction. Currently the SEV/SEVL instructions + * which are *one* of many ways to wake the CPU from WFE are not + * implemented so we can't sleep like WFI does. + */ static void gen_nop_hint(DisasContext *s, int val) { switch (val) { case 1: /* yield */ - gen_set_pc_im(s, s->pc); - s->is_jmp =3D DISAS_YIELD; + if (!parallel_cpus) { + gen_set_pc_im(s, s->pc); + s->is_jmp =3D DISAS_YIELD; + } break; case 3: /* wfi */ gen_set_pc_im(s, s->pc); s->is_jmp =3D DISAS_WFI; break; case 2: /* wfe */ - gen_set_pc_im(s, s->pc); - s->is_jmp =3D DISAS_WFE; + if (!parallel_cpus) { + gen_set_pc_im(s, s->pc); + s->is_jmp =3D DISAS_WFE; + } break; case 4: /* sev */ case 5: /* sevl */ --=20 2.11.0