From patchwork Mon Jul 26 21:47:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 485867 Delivered-To: patch@linaro.org Received: by 2002:a17:907:d92:0:0:0:0 with SMTP id go18csp4016096ejc; Mon, 26 Jul 2021 14:49:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzyQeKHBUlB+IjPdPCvngD/UH4FNGp1Fmau/ZufqGv+mPdwQPc32RMP/L+4dM38Hnia+0Yu X-Received: by 2002:a02:cc4e:: with SMTP id i14mr18409956jaq.125.1627336162094; Mon, 26 Jul 2021 14:49:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627336162; cv=none; d=google.com; s=arc-20160816; b=g8t8IanqnhOurrBHEjs2JQsRmc+oaNPpf+ZYk1CWssP8MwIJXFmTCN4IU3wY51mYIx tZZvsEVwMthGLjPS8ZdbSI1PiSKAEpsjgSM0CnX/kOSH3229HBNXkBMILYt6zGKLUlDI Qz4lhPrl5IAwBJgA7UHb5aKdsQ4T6pfc9Sbs818EK8tn4+9BwEdS70dW9PVR06w9BkYT k0Gc2oE9ShCrDSfBoteEZFISQMxypH7au9m+ybD93GkgII/v1JSdIHGKxwawL12QHfWZ HKOeLT9J7MBdYxr4cM3bAxyYHhpf4IjzM8QqVaXs95R/9wHWeeAXnVknEiB763RBN2hR +5LA== 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=dczMECoCZ2fE11SIUOsBRrLY8h7p8j2HpmwPdyA/v6o=; b=iU2YeDw0+KmV+KlGCGxwMCKZCQkUrdiF5WCQNwlojIeieMYXK814unM4/oicfQia2p exDhR9XwTGCHEiNJ0BIomeGizHOjS5YIStbkfPZPDOfymkYO0FsdoN2psReIyrlH1WJG Lx+jJomAAc2UwBgMQ20eoo96quWFmxhAIO6Ag+GzkJzPPCY8MesZ/mbvaRI7W5ALrVOK Pv6IcQaagWgW3+C1m8HZ8NkzvWI9rw1BqpPOM5bC+0gMSLVqk0Uh+xxqKmKxB11t2S4/ DUrUMpVh6gZSGINxuvZZ8qxe2VJdSAJGpSDEe9+yGoSUsWcR13dQSqlEpZ2J7PjWH+fp ZcQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Wggx+YzD; 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=pass (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 v17si1184233ilo.17.2021.07.26.14.49.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 Jul 2021 14:49:22 -0700 (PDT) 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=pass header.i=@linaro.org header.s=google header.b=Wggx+YzD; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:49074 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m88TR-0006Uo-DK for patch@linaro.org; Mon, 26 Jul 2021 17:49:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38910) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m88Rm-0002Mf-1a for qemu-devel@nongnu.org; Mon, 26 Jul 2021 17:47:38 -0400 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]:33390) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m88Rk-00065h-H6 for qemu-devel@nongnu.org; Mon, 26 Jul 2021 17:47:37 -0400 Received: by mail-pj1-x102e.google.com with SMTP id gv20-20020a17090b11d4b0290173b9578f1cso1120136pjb.0 for ; Mon, 26 Jul 2021 14:47:36 -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 :mime-version:content-transfer-encoding; bh=dczMECoCZ2fE11SIUOsBRrLY8h7p8j2HpmwPdyA/v6o=; b=Wggx+YzDxrfg/4O9cLnBAxj+Rgk/ng+sse/jf9XIUIxtvJnZsgjMEk4RkZWlLSzNdh +k38iNFGyLnB6Jg4Huvx8WHvvLMxQkivZuh7NsMRDwFH4vqnuaNtGmH1/cDgrAbSP74s Ta3ZDRLUjs2lG08OghVE/2mOpwRWPgzSfnmIAEAsEBLp2wN2xX8eB2/NyGmCel1i9fon QpABpg1tXDMYArPmz8wVKdWNK5veSIWnDQcvdenfaEBnOmxRvx6sFVLSqmo50s9U73Br MZo1o1989pnxDXmqBSSVJg+d46uSwz41zkdpU+JLNcBa0qLJ+RI/UWp5itmBiL6joZoP iVEg== 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=dczMECoCZ2fE11SIUOsBRrLY8h7p8j2HpmwPdyA/v6o=; b=YacIJ+VIKs3VoxJ1Cx5cwG/EoKxgNqJCEk3o65o5qO/8ATlbOTpWdklJTgkFgoNwOC /jtdG2nz14dwdwtUyLprtWA//9/TPspRO7CGjm25YdZjk0XLiF8h14a3W312MHrqWkmw D/XVMBJ0lRknQGZOkSwuAu5MXyP3B0WQI9MTjVWLs8eoKTi1OVmKA3HpXGisfLx253d3 TS5EEk4la6zmyAax1rrdyXHEJTR1kCbctG/k6lrLNwFRFktmv4pdR3141MRk6tW4eyJw It1ykZRkWAr2DeAjcLpHDZt0ilYpnzgXgn0BRP3fAtJw0Evwz7rzHF7mcvdGvMyA0A4c Ieow== X-Gm-Message-State: AOAM530+/QhEU07bAaDTfQCG0rd/BoEQFp/aVAkftHDSWTEX92JSjQux QZRTRQqK8yUbtRgqWKACw+LgNf6EcatY4g== X-Received: by 2002:a17:902:7c81:b029:12b:6ac2:3ad9 with SMTP id y1-20020a1709027c81b029012b6ac23ad9mr15843971pll.76.1627336055122; Mon, 26 Jul 2021 14:47:35 -0700 (PDT) Received: from cloudburst.home (2603-800c-3202-ffa7-497b-6ae4-953c-7ad1.res6.spectrum.com. [2603:800c:3202:ffa7:497b:6ae4:953c:7ad1]) by smtp.gmail.com with ESMTPSA id e8sm997679pfm.218.2021.07.26.14.47.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jul 2021 14:47:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL for-6.1 02/12] accel/tcg: Remove unnecessary check on icount_extra in cpu_loop_exec_tb() Date: Mon, 26 Jul 2021 11:47:19 -1000 Message-Id: <20210726214729.2062862-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210726214729.2062862-1-richard.henderson@linaro.org> References: <20210726214729.2062862-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102e; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102e.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: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell In cpu_loop_exec_tb(), we decide whether to look for a TB with exactly insns_left instructions in it using the condition (!cpu->icount_extra && insns_left > 0 && insns_left < tb->icount) The check for icount_extra == 0 is unnecessary, because we just set insns_left = MIN(0xffff, cpu->icount_budget); icount_extra = icount_budget - insns_left; and so icount_extra can only be non-zero if icount_budget > 0xffff and insns_left == 0xffff. But in that case insns_left >= tb->icount because 0xffff is much larger than TCG_MAX_INSNS, so the condition will be false anyway. Remove the unnecessary check, and instead assert: * that we are only going to execute a partial TB here if the icount budget has run out (ie icount_extra == 0) * that the number of insns we're going to execute does fit into the CF_COUNT_MASK Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-Id: <20210725174405.24568-3-peter.maydell@linaro.org> Signed-off-by: Richard Henderson --- accel/tcg/cpu-exec.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 2.25.1 diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 6e8dc29119..5aa42fbff3 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -843,7 +843,9 @@ static inline void cpu_loop_exec_tb(CPUState *cpu, TranslationBlock *tb, * 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) { + if (insns_left > 0 && insns_left < tb->icount) { + assert(insns_left <= CF_COUNT_MASK); + assert(cpu->icount_extra == 0); cpu->cflags_next_tb = (tb->cflags & ~CF_COUNT_MASK) | insns_left; } #endif