From patchwork Fri Oct 20 23:20:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 116561 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp2231196qgn; Fri, 20 Oct 2017 16:37:51 -0700 (PDT) X-Received: by 10.55.99.148 with SMTP id x142mr9219645qkb.212.1508542671687; Fri, 20 Oct 2017 16:37:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508542671; cv=none; d=google.com; s=arc-20160816; b=owHGqR1a5e26KdEXMQ/SeqJzMy2Mk8BctAXO+VJsPVrVCOEMxHmRTScijgMw93yDn6 p0rRdJFJGTo9lEZ0Upw4yH4jxZSDQ8rDv9d3RWihRnojqGkz7BjJE9obngbfq/X/AxKT OZHS2YebbO0S+mKsP3So977GdIq2P4ZI1qHs+RCG4b6cZN8ddkHwNUEP9nBAA18CV4XA acg8q8Tvc+Bbj97u3z8RSL//tfPwf046kmsbT7GgiD0e1wTDjkbdQgYyl1YaSyOzdfIG K3WMoyCXTZNEpAST0h9SkO261YeQU/wnq/bSoCk63CNWJA2nILO1bHFdK1RkXJJYjQLv c1DA== 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=quec2i39SwLng17K2+7W2HoFNPnCHCbdtsr9AWRwbZ8=; b=RX9vqh7u2xKuqb6XwE8h5azOYLFGmCU6mL8jLao5WvgkBzJFAlY8izOsJjqxIRAVqd ntics7fDkDyHVvHCcLtGGWWHVU8YSXYUOnLAqeg09UWEaEuOoatNLXrUrhGxqbTWqv0n xs/Ddv5ILPYhPitaKPOyWmVjTlYkeIuy+IUbrQtOdpEjlCeCY/ZeXy1KapBRn061GxT9 QwZ6hExZUAWfmPaBePYf25tiG0ULQxhR+ZQd0+dZuG0pK5brxBWr/KwwyS6ja0ZqnV9V lTJff4+R7aOPCT1wFYtPn4NXf1YomqHLNpLKyQRxQ5l4t5zyIvT5G8KYXB3Vss4Xa/dE JdFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Cx5DfPht; 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 f190si1693139qke.433.2017.10.20.16.37.51 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 20 Oct 2017 16:37:51 -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=Cx5DfPht; 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]:56049 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5grN-0005Ad-HF for patch@linaro.org; Fri, 20 Oct 2017 19:37:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44652) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5gbR-0006R5-Ox for qemu-devel@nongnu.org; Fri, 20 Oct 2017 19:21:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e5gbN-0007rZ-Jw for qemu-devel@nongnu.org; Fri, 20 Oct 2017 19:21:21 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:56986) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e5gbN-0007qm-Dd for qemu-devel@nongnu.org; Fri, 20 Oct 2017 19:21:17 -0400 Received: by mail-pf0-x244.google.com with SMTP id b85so13056789pfj.13 for ; Fri, 20 Oct 2017 16:21:17 -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=quec2i39SwLng17K2+7W2HoFNPnCHCbdtsr9AWRwbZ8=; b=Cx5DfPhtpbJ/Avfjwdhpy9qtONt0cy79AmT0k/rd65pDqwnweHWQr11FO1wjNcdBed 6SjnYRxwGqjktogIjKQOVfu3SeDWnjSHLhy3k9h9MFnOTmIdxnRbzY+hwcHGIvCiHqKF F9MzR+2n3jnZiABJz91LDDdIYTdEfAn14NERE= 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=quec2i39SwLng17K2+7W2HoFNPnCHCbdtsr9AWRwbZ8=; b=VSxMR1tnA/eSpXY3L1mZA4rFJs7B5VNmm3PvDpDrLDcyScnyd0mU3IME75UL3qQPgM 8ushwDV9VVGQ15jPQlr7NQVHGeZy6E9k6KBhYKlFoMtQrPki2f6QeraXoEyVn2W4Tc+z 6T0CpnL9jahNiKx2qLHM3ezUIS3jPqS0pSHpCCSlJ6mX9J1tI8t85rOKdTzaEqnksows gxIMSjQDWxM8u8Jp34ESkX5WsfeMCtHx37gr98vjf9EAYTc8C85SzGX2TU1J+mqMt1S9 ipTEOTrVjd0TeoG4nFTXizFnyySWHu3N0wAc+9UpJC9GqC1saqw4PwBi6SHhwcGoubwN KJ4w== X-Gm-Message-State: AMCzsaVeWYLIhUVrmMa3soRHC14cQvhR9jQj4RcCFeMFPkeDwXjL9Xna 4LWUsOXX/wU1jGjpoIp1WcacpxHbNV8= X-Google-Smtp-Source: ABhQp+RKtiVGgAQG48Khvrg2i6D1TkR/0Fe9TZ37dabZEODC9cwWkq7Gx5Bplxdlu4ER5nIbKeze7Q== X-Received: by 10.84.140.3 with SMTP id 3mr5298449pls.247.1508541676227; Fri, 20 Oct 2017 16:21:16 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-165-104.tukw.qwest.net. [97.113.165.104]) by smtp.gmail.com with ESMTPSA id a17sm3532594pfk.173.2017.10.20.16.21.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 20 Oct 2017 16:21:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 20 Oct 2017 16:20:06 -0700 Message-Id: <20171020232023.15010-36-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171020232023.15010-1-richard.henderson@linaro.org> References: <20171020232023.15010-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::244 Subject: [Qemu-devel] [PATCH v7 35/52] 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: pbonzini@redhat.com, cota@braap.org, f4bug@amsat.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 Signed-off-by: Richard Henderson --- 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 1c64977849..849b54d0b0 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;