From patchwork Mon Oct 16 17:25:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115970 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3959695qgn; Mon, 16 Oct 2017 10:57:07 -0700 (PDT) X-Received: by 10.55.115.133 with SMTP id o127mr15040475qkc.351.1508176627411; Mon, 16 Oct 2017 10:57:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508176627; cv=none; d=google.com; s=arc-20160816; b=z4n5PHF+EzSkYCA6OMxYcyBYEq9k04qB7M4QxCYyeI13FArv6wbeLK9Cy4YzAb4qAS fWFjgag2qHmhrNBEK/wjZdRi/cHD1kSDKb1/3rh4qX8r1LedtmHhtYgJaThfG7Xay467 0kCYYTqvvOprU1k55/4khER+6u0P8s9ar4SCAPS9eUfDu2TuxwOJEuNVoTfj2pftQFYM o73e4W6m88UtP0L1WfeTtbsSVLRF/yEcNQAF3ZjmCpvMZKWRDsnL8CkgRVYfQb7jbnYD RamFjzmxfDENS8Yrlzle0NDb1ow7eY4pFDTgwOumBnvL4mEzY2NzeILgjo19hB5kSAZK DUAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=l2NW2eibSR6aGsXmh0Di9NTdRoHSvwrB4y9R4avxQdo=; b=ipla19abYagKhx70RIAUSjR9a1yWiHg/X/eH0OOEsxZ7YN8PGiDC5aqwyHP2Ctgudw fqQue6B8oRcKLLqcrljuw7J3r0JViC+tzN9brLjY48oN/GYwSEzt6A66bFN/VzWDT99Y yNbYYlS2IVZ5xb+H7XkCJt2UXxjPw6yWFxyo1NhvbBE+8AGnsXVJp+BBuiLJiCASTMoc 5P+8RG0YnU65OBXxYaFi1P0cKD7RLEWAehNCDjVRzsNcYBtqiMrw5Jz4ZN2Aj26ntPfy z+3deW1Vdy4AKhz1iwqa539h/AphTxZXLl0p5SL2RzYHCkclbqGHjkMWkZVNV68ro27R fa1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=A4E/Wz2o; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id i89si3583699qtd.221.2017.10.16.10.57.07 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:57:07 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=A4E/Wz2o; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34426 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49dR-0002sx-E5 for patch@linaro.org; Mon, 16 Oct 2017 13:57:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52618) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49AO-0002en-TI for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e49AN-0003ph-Rf for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:04 -0400 Received: from mail-pf0-x232.google.com ([2607:f8b0:400e:c00::232]:54267) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e49AN-0003p1-M7 for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:03 -0400 Received: by mail-pf0-x232.google.com with SMTP id t188so13794494pfd.10 for ; Mon, 16 Oct 2017 10:27:03 -0700 (PDT) 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; bh=l2NW2eibSR6aGsXmh0Di9NTdRoHSvwrB4y9R4avxQdo=; b=A4E/Wz2oIIVhlLqFDnBPy8OL20f0FkOC0ntYtTThSvay8mf9Aks7flFggTfoCv+V2e i4/ePeAVcFAZ+wPqkbN7hsonR53lgDKYIzrkAzBRss5QFShyiYLFzSyujbhXPKGcJcgP iCdaH679JSZ8yMyKSMxejUF1FJmNt1TB+KtsI= 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; bh=l2NW2eibSR6aGsXmh0Di9NTdRoHSvwrB4y9R4avxQdo=; b=Tns/dOSGgKZYi4LKnFO2gMSqU6GFY3RighGAmA8Ef2QJyEqAZo0DnY08lOcmk6hnJS Tt0Q8NGGsBLvhkDkBQOBaM+kjym/pd42WMgVqg8IuVP41FR5UkSurWsmogNOuRsxFBNI LpQWSSirKgFH9c3H1KShfaVW3OARIKjcaEKc2RLhOydCh4vmWVahzp4ergG7gaYoxUbj pKZK0XaCxQlzVIsvnF+CgG2zOUfIRi+iGVHYwvTn5K4yIkZ1/HQgAjTQMgj/Hr6/kZir YFQYu/SGwmkOknVizitkYeG2UjWll91rJ5tk4TYdrnKBL1yK7jwO1eFdWT/B0TLVL2S0 BoGQ== X-Gm-Message-State: AMCzsaWIFjUKL/4wMUjEUXVazQ9Q4QXjK85wpN3BbeBs6ryxvHXQOYwL LuIGVyGnM3TKsK7QKbGpWLcbN3hgx5s= X-Google-Smtp-Source: AOwi7QC8H7yzJz2anJ+Nicfo7PgmbdLViYpKwGLe3z11DCh6PcAOgE26BcK8hqK2k7Lyw4jiCCCnjQ== X-Received: by 10.99.95.203 with SMTP id t194mr6880123pgb.318.1508174822423; Mon, 16 Oct 2017 10:27:02 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.27.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:27:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:25:54 -0700 Message-Id: <20171016172609.23422-36-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::232 Subject: [Qemu-devel] [PATCH v6 35/50] cpu-exec: lookup/generate TB outside exclusive region during step_atomic 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: cota@braap.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Now that all code generation has been converted to check CF_PARALLEL, we can generate !CF_PARALLEL code without having yet set !parallel_cpus -- and therefore without having to be in the exclusive region during cpu_exec_step_atomic. While at it, merge cpu_exec_step into cpu_exec_step_atomic. Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota --- accel/tcg/cpu-exec.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) -- 2.13.6 diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index df410a8d6e..0eecbccebc 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -223,30 +223,40 @@ static void cpu_exec_nocache(CPUState *cpu, int max_cycles, } #endif -static void cpu_exec_step(CPUState *cpu) +void cpu_exec_step_atomic(CPUState *cpu) { CPUClass *cc = CPU_GET_CLASS(cpu); TranslationBlock *tb; target_ulong cs_base, pc; uint32_t flags; uint32_t cflags = 1 | CF_IGNORE_ICOUNT; + uint32_t cf_mask = cflags & CF_HASH_MASK; if (sigsetjmp(cpu->jmp_env, 0) == 0) { - tb = tb_lookup__cpu_state(cpu, &pc, &cs_base, &flags, - cflags & CF_HASH_MASK); + tb = tb_lookup__cpu_state(cpu, &pc, &cs_base, &flags, cf_mask); if (tb == NULL) { mmap_lock(); tb_lock(); - tb = tb_gen_code(cpu, pc, cs_base, flags, cflags); + tb = tb_htable_lookup(cpu, pc, cs_base, flags, cf_mask); + if (likely(tb == NULL)) { + tb = tb_gen_code(cpu, pc, cs_base, flags, cflags); + } tb_unlock(); mmap_unlock(); } + start_exclusive(); + + /* Since we got here, we know that parallel_cpus must be true. */ + parallel_cpus = false; cc->cpu_exec_enter(cpu); /* execute the generated code */ trace_exec_tb(tb, pc); cpu_tb_exec(cpu, tb); cc->cpu_exec_exit(cpu); + parallel_cpus = true; + + end_exclusive(); } else { /* We may have exited due to another problem here, so we need * to reset any tb_locks we may have taken but didn't release. @@ -260,18 +270,6 @@ static void cpu_exec_step(CPUState *cpu) } } -void cpu_exec_step_atomic(CPUState *cpu) -{ - start_exclusive(); - - /* Since we got here, we know that parallel_cpus must be true. */ - parallel_cpus = false; - cpu_exec_step(cpu); - parallel_cpus = true; - - end_exclusive(); -} - struct tb_desc { target_ulong pc; target_ulong cs_base;