From patchwork Tue Feb 9 18:27:43 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: 379380 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp495440jah; Tue, 9 Feb 2021 10:44:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJyVmNHsd0bqppPaDtlwExlVSM211tzKQyr2MlTHBySVrXhlHcf2oEbTbHmusXvafSldm8DY X-Received: by 2002:a25:782:: with SMTP id 124mr32072621ybh.53.1612896253199; Tue, 09 Feb 2021 10:44:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612896253; cv=none; d=google.com; s=arc-20160816; b=Izmy3k4iIDh2C65fjfZYxygfp560TXEwJAAxyvQV4UNgZs8RLjqGpej+rdxlEjrUsv VapwVpO7cNDnMPynICphnalEErBT/PucgJ9Nixadrfb/Taee1M/aCH79m03wfiOTMpJj RxL0LRRGHVk3cs9wtPCdv/pdnMhKRb0kM8OoCp3xz46cLcKxtrWqZZe1Un3yS1aam/lR 2fNk7V/kh62iZbVm8GyhogIXeU8IFKjdMSyC5WnYUgbP3DpzJfGCIED4Z4tvd1o9hsiH StFjP3vuJPkAOmy5lDj7A2K23UqTVWFEKYdoLpLAN45DTULYJkl95i3XVKdgYrmpomHT 2scQ== 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=uLoHyoIh1M9yTgnlc4zbWUCZ8MEEKdj0MabvYTrqb/0=; b=QbrNwl5fDWHk+xuQT6zYKKpC+i9T1sGjztweMiD0vGQCFdbnMrZVqi+0dapTobQiTf h4Flp8AG4guWSv34oz6Cgp/GpZlCJuspaCOJuRScLL9nflHAk5aIwl6nH8W0u4fb57bA v3Y59MO3qKpbXiEIYfTWkxGTfJFvkebQvTrtdToLqTGDLIMBfkQeOXHlz2JX87dAXRdP qg8t8jWC6I63f/4JwLT93QMUEZUnt083UUo3lQZk3krpT7SzF4jnaDGNpaBNHaXyFmQF gxmguY+SKuzzI9hRMbQF5m925LNRvzgjoXUDIiCi7hhl2F+RTWziNuqyYhsS7gSrkHqs Zaeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="Hn67e/YG"; 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 j133si20205071ybb.145.2021.02.09.10.44.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Feb 2021 10:44:13 -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="Hn67e/YG"; 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]:35234 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9Xzg-0001Re-LH for patch@linaro.org; Tue, 09 Feb 2021 13:44:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43402) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9Xk8-0003CS-D9 for qemu-devel@nongnu.org; Tue, 09 Feb 2021 13:28:08 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:53488) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l9Xk6-0007r3-R8 for qemu-devel@nongnu.org; Tue, 09 Feb 2021 13:28:08 -0500 Received: by mail-wm1-x333.google.com with SMTP id j11so4158095wmi.3 for ; Tue, 09 Feb 2021 10:28:06 -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=uLoHyoIh1M9yTgnlc4zbWUCZ8MEEKdj0MabvYTrqb/0=; b=Hn67e/YGVD27SZi5AWZq2SgTKq0p4yhaYsrRFTKCYYTNcVO4eWjaZytEqxzTGgOCFN Cd3QBqxUB/Re8BP5XTSRqdBU2OUeayPOY+UVFxbo260NujHPxPaPJyEt6bBsjsSM2qgF EP7GOdB+gYgUoT5uL5PzF18oA+dmMh+kn9UTjrPkf8ax8IJzTnlteaV2ZVEIscVRSE1h vBNP4MjZctY1W8A6u064wufX++kyf8127Wwk+tkD/TXNLOnrbJqQGcuSRWH1qfW4fEwA 8PQQvCZVtJ6HYJHdAbgdt/EkvEPGO6vYvHTXRmltITBRCrKYDcqdBWbcA8FHeVgCre/Q icVw== 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=uLoHyoIh1M9yTgnlc4zbWUCZ8MEEKdj0MabvYTrqb/0=; b=coXSW84/UcL9lPkCxNCF1yZh/IOzflRxZHueDfaGgbc80snwuQRkujEySojd8W53U7 MA6bib5U9IUq3G4J+gD9ZmZFIGC4WJp6qZjqqxtjp/mHJjTu5WYDQvV671DycnLUfiuE RaEWsQM8y2/5TgbdafBzGnerYO/n11zxyYRPVbirPBWfU0hzQ9beL8nZ26wDBlnZUxGD yPAm6vMdXYeo2Vw4pwfCMwX7YbsBpEpHe5NXUwFuZVTJ74jyGtbcWPt0tiZJ8NwJPVz4 ZPuFeroQkYenyckJiZtZ4yGTs9zNxEyttQ3NLW2ZOdfvMTF/B5JnebOeu4w+LekDuL6j oOcg== X-Gm-Message-State: AOAM533z2XkAF1OsBHlX/9MuBQwu+qfRtX3WElAMUUAoFcG06GuWbT6A 0lD3yv5BePzO1rwwb/zuXgOexA== X-Received: by 2002:a7b:c3ce:: with SMTP id t14mr4727349wmj.175.1612895285458; Tue, 09 Feb 2021 10:28:05 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id c18sm9554487wmk.0.2021.02.09.10.27.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Feb 2021 10:27:57 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id DAA841FF93; Tue, 9 Feb 2021 18:27:50 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 07/12] accel/tcg: actually cache our partial icount TB Date: Tue, 9 Feb 2021 18:27:43 +0000 Message-Id: <20210209182749.31323-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210209182749.31323-1-alex.bennee@linaro.org> References: <20210209182749.31323-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x333.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 , robhenry@microsoft.com, aaron@os.amperecomputing.com, cota@braap.org, Paolo Bonzini , kuhn.chenqun@huawei.com, =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= 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 --- accel/tcg/cpu-exec.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) -- 2.20.1 diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index d9ef69121c..7f477af891 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -730,16 +730,18 @@ 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) { + g_assert(insns_left < CF_COUNT_MASK); + cpu->cflags_next_tb = (tb->cflags & ~CF_COUNT_MASK) | insns_left; } #endif }