From patchwork Wed Oct 25 09:35:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 117085 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp659270qgn; Wed, 25 Oct 2017 03:07:18 -0700 (PDT) X-Google-Smtp-Source: ABhQp+SRFWDhCLutNngQNINqQT3oJphSVAkDpUBcS6MLbYDlkZndwBskhFt0vI3uunN5L7qbHyHS X-Received: by 10.129.183.27 with SMTP id v27mr10587642ywh.401.1508926038470; Wed, 25 Oct 2017 03:07:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508926038; cv=none; d=google.com; s=arc-20160816; b=iq7qvZM1NVVYX1lHnJ+z3PAcSZFm603ianUZewHhX3OHD6QjFMCe/81YwVNJTP9K6I doTXmrQVXgB3sOQretVGOzcjcKQP/0i3ZJol8HWIgMX1BSRKXL931+fWnXyvwhfKXB6n rOivMBX6OsZUwNcLTjTozKINuekVKvsyzluDh3yLs0Ko7JNAW7Y8oA4IGH5SGPOlGK0M 3jP0MQPJNp6hZSub1s+oDaVZqSy2wgUo1ahX8Rh8niWHHbAwiZOsU/MxJafjKBrzLB/W gd7DrAaWA3+eQOTGL8WbIfx1Sd2sCdEGN9SMArxrbK9UJm3tOYaEdObIxs3VaNINFOXm Tezw== 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=In/pGIAw2hk4DDErJ2G+S3AWGZp1/t//RuXrWlks277VLwrL5wXBTAJF3qD1v7T2DP EzfaJ07iC5f5ejhPHq3VzdsOfhE9Hait0nfltTuXurHTRxyBnh+hln8a0Y0TNUT7ykLu BQbVeYu4S+qVM4+4WryiMnfkj7OfE5uVUWJFq05zSXSJsC+h+Ah58X979tsiBa3oS4rc jD/UHzGrR5hf+0l7prmv38/hQ4JJbhfYqOnJxxkId1NcLYg+QqnkrjRhWKZ8EgCko2wx OGDMk4Ko692vZe1NoUOfzPocPNuOUjL58rd50hiREI1oM4Dae719S0BSNvc8sdQ7Mt1A gtVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=gGCxJw+V; 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 v22si383957ybd.779.2017.10.25.03.07.18 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 25 Oct 2017 03:07:18 -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=gGCxJw+V; 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]:47442 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7Iak-0001T6-0z for patch@linaro.org; Wed, 25 Oct 2017 06:07:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45893) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7I6p-00008z-BA for qemu-devel@nongnu.org; Wed, 25 Oct 2017 05:36:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e7I6o-0008Um-DO for qemu-devel@nongnu.org; Wed, 25 Oct 2017 05:36:23 -0400 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:46392) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e7I6o-0008UA-6Z for qemu-devel@nongnu.org; Wed, 25 Oct 2017 05:36:22 -0400 Received: by mail-wm0-x241.google.com with SMTP id m72so633548wmc.1 for ; Wed, 25 Oct 2017 02:36:22 -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=gGCxJw+VRuZAXdPQVlrKuiJiqid3QVnBY+YPBDZAbOsICFroGNZe00U3CxllPVLKWe bjdb6yGsclthMTQ78DGKNqK98kmiPxAZtnuIVuWLIYVlYwOYbZOckCTs1STXfe7tNLZN DrJhZw6vvfj1T3v102i6eFp25x+7L9KjteBXk= 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=lVv36JGBCQACwO8X2Kwo8P+T7j0i/XpCI8NzWHQ9zAsu/6f3KIGo+S/JNRMIyu1yx3 r31Phkb4aS/HaA6ZA2I06l3Quv4dt2kLXXLnHMMPXqUT8T7KZ8LnIXTiBad7c7Bfeodm t/To04H0mNWHG4LnPf8S2fExyhq6qnUL12qWreqsir+yY6+kcX6KOL5uNNwEeV/cji84 kZvKCvQuMr2u6KCXddX02PY3narArjalUSa/JEsgwXvNef9B1O7Ybywg3ALD+v2WjPxh AeFykwBMqA6h6Z60DoKuP3qmKE267Xuf/NDpYWFJcTqj7rESklJzrGXQRB+aFKpI4798 Hs3A== X-Gm-Message-State: AMCzsaW9YxQiWgMKOWCGGPI86XzZvnZ0Z00qefWvWHI/RFcex0FitGfr eFw4emVSqtKOJyWGXe3YiOdSk8V8v6U= X-Received: by 10.28.232.75 with SMTP id f72mr1093566wmh.90.1508924180892; Wed, 25 Oct 2017 02:36:20 -0700 (PDT) Received: from cloudburst.twiddle.net ([62.168.35.107]) by smtp.gmail.com with ESMTPSA id v23sm2751025wmh.8.2017.10.25.02.36.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Oct 2017 02:36:20 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 25 Oct 2017 11:35:18 +0200 Message-Id: <20171025093535.10175-35-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171025093535.10175-1-richard.henderson@linaro.org> References: <20171025093535.10175-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::241 Subject: [Qemu-devel] [PULL 34/51] 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: peter.maydell@linaro.org, "Emilio G. Cota" 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;