From patchwork Thu Feb 18 09:46:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 384376 Delivered-To: patch@linaro.org Received: by 2002:a02:c80e:0:0:0:0:0 with SMTP id p14csp3539152jao; Thu, 18 Feb 2021 02:02:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJw5Z4FMSuO17K7Sev2ZntCdnM6Z2mDkGoHzV37oXbZK5UO0r2oNvP9SHNej6LeQcdse/gHd X-Received: by 2002:a25:3783:: with SMTP id e125mr5193296yba.169.1613642570064; Thu, 18 Feb 2021 02:02:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613642570; cv=none; d=google.com; s=arc-20160816; b=mZDdukax0vcHSw+gS6K7X74i+Qk1F0ELWN32NuTZS+3ahK+qg42XYSDjzsoiMfy4GH +jmTDcUAdu7xX5dOW3M0iCxhOfIzlQU/cNyET8EjfR29sGt7ZgIK9UimcNZce7PTirC4 s5evnxpiLKHPMLFScnq/9gvwdEYG0530Uy9sMfrJ1e0cFV28BFRy5BUg1zTGLDVRS4vI 4PD71U5zp0e1X9s2ED6kYuMqUy9sLW+S7M1Q7BYpXj0zk3Ehoe/ilDafWfioAeW/U13g qIp12V9NKf2NhNGnIlh/erl/tOkxVSOTWA6c8nkLehpGJEtI8Llx4P6fFv3PQzkZWvI9 0Xhw== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=zs3ZCon26CJzrjGkyi/ru0q40eBX9PJP1e1LsnAKqPY=; b=ofSXXVnai+rxwXZGBGjcS9pNXr4o3WvVM834iS3rcKKIPDJnR1PdWDaUvFsKcrdLm1 ozbiXbRuSrFRjJ6RZ71nm8tIB0xpSlSTl4Q6ww8Xp83XJiNYlyM/0HPMP5QNn3ZCDi88 tulmW2w/H+phDsIWFQV00FYreQZDwrDbjKKWGvCQDxg80Q8wDXFf3MJGIbHFZNqjkew5 qN1gU8rXgzrMABwH9IoeVC9vK9/v0JE9PNeT7DhvMyUHUPu1Q5pxAeNdRA5VE/EDmdJ2 HADQOlNbR1PVvyAa98+FiOY5L9Jfwgi8WnQ/jJIsmIEesAZ4l2/elWgacHacj1SnMOXG I3jA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=r14qM+vL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 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. [209.51.188.17]) by mx.google.com with ESMTPS id j78si5018715ybj.388.2021.02.18.02.02.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Feb 2021 02:02:50 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=r14qM+vL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 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]:44878 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lCg93-00084A-IW for patch@linaro.org; Thu, 18 Feb 2021 05:02:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53450) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lCfuM-00079D-4X for qemu-devel@nongnu.org; Thu, 18 Feb 2021 04:47:38 -0500 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]:35067) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lCfuJ-0007J5-Ot for qemu-devel@nongnu.org; Thu, 18 Feb 2021 04:47:37 -0500 Received: by mail-wr1-x430.google.com with SMTP id l12so2208367wry.2 for ; Thu, 18 Feb 2021 01:47:32 -0800 (PST) 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=zs3ZCon26CJzrjGkyi/ru0q40eBX9PJP1e1LsnAKqPY=; b=r14qM+vLAYuvyO2iiw4GSnpu0KGmCXjsKVYF6yEtaXbGD1/F+gXklOxWWSLiLwUQGu Sq7lrsW7UasnFgcTTRGTSgLbqhHzVRZT1YcCX3NvZVsIiXZwf1CC3hJvCJrXSNYCyqDs byXNCqOkcZQBkEJJNWk8a+vPxC6ZcE3Wy/SLyJXD5zn3c3BvjJSOLwrBluBIkWXFWclE D6+vuTSmhxqNG+H+Sr8zA68sINaLyF/TZvAPVM01G9f3ow1Y6pOefBw6UBgZ74CD4vCy bSKhV4Jk1cl9Vb9Kv0TPFF0wQhJPcoD3TRUIltFKXt4K7lTdeNVxuAw9KqXrPelyVLaQ +o+w== 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=zs3ZCon26CJzrjGkyi/ru0q40eBX9PJP1e1LsnAKqPY=; b=qYSY6YNfMJ+XykbHmRntQCNQ7vfs6hP8tbPs6dZfktsqyu7hOH/NvAEU85NUw93KM7 n2pz+NELTXuXRwdRxWi4AuTNZSTg6rG079WTKVcixQmbvd3VVFd6L9YAGkjUKB5/0Gen +tW5xvuiSSxZCTirbdZhigXOjioyqByBZ1XKlEYjHIRJ6fLodcixfVjcTak4Swt+WLtk h4HLcjhRROJa1MZyj1S5niaB//fC6uRIShQVQ99WNBu2hhtWVUtAw3flWYQja6jTV5Mb 8wBLe/NM5GF1omPd0tKXE+yTuwOYRUtVfd1Pa1fCufS0WfmLLVgnEqOqGG96XnOQI0Me HGNg== X-Gm-Message-State: AOAM530VwMXeWcwW1c1IRQb1rb8zjZxWNg/i8/g7WTfo808SkLQ9WuYR DJY+9TyuoPMOzYHNUxJCxP7VAA== X-Received: by 2002:a5d:4d0b:: with SMTP id z11mr3487950wrt.359.1613641652124; Thu, 18 Feb 2021 01:47:32 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id b15sm7645938wrr.47.2021.02.18.01.47.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Feb 2021 01:47:23 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 807BF1FF9F; Thu, 18 Feb 2021 09:47:08 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 16/23] accel/tcg: actually cache our partial icount TB Date: Thu, 18 Feb 2021 09:46:59 +0000 Message-Id: <20210218094706.23038-17-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210218094706.23038-1-alex.bennee@linaro.org> References: <20210218094706.23038-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x430.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= , qemu-devel@nongnu.org, Paolo Bonzini Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" When we exit a block under icount with instructions left to execute we might need a shorter than normal block to take us to the next deterministic event. Instead of creating a throwaway block on demand we use the existing compile flags mechanism to ensure we fetch (or compile and fetch) a block with exactly the number of instructions we need. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Message-Id: <20210213130325.14781-17-alex.bennee@linaro.org> -- 2.20.1 diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index f2819eec7d..d24c1bdb74 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -730,16 +730,17 @@ static inline void cpu_loop_exec_tb(CPUState *cpu, TranslationBlock *tb, /* Ensure global icount has gone forward */ icount_update(cpu); /* Refill decrementer and continue execution. */ - insns_left = MIN(0xffff, cpu->icount_budget); + insns_left = MIN(CF_COUNT_MASK, cpu->icount_budget); cpu_neg(cpu)->icount_decr.u16.low = insns_left; cpu->icount_extra = cpu->icount_budget - insns_left; - if (!cpu->icount_extra && insns_left < tb->icount) { - /* Execute any remaining instructions, then let the main loop - * handle the next event. - */ - if (insns_left > 0) { - cpu_exec_nocache(cpu, insns_left, tb, false); - } + + /* + * If the next tb has more instructions than we have left to + * execute we need to ensure we find/generate a TB with exactly + * insns_left instructions in it. + */ + if (!cpu->icount_extra && insns_left > 0 && insns_left < tb->icount) { + cpu->cflags_next_tb = (tb->cflags & ~CF_COUNT_MASK) | insns_left; } #endif }