From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D69E8C4361B for ; Fri, 11 Dec 2020 21:44:47 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 48BBC233A2 for ; Fri, 11 Dec 2020 21:44:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 48BBC233A2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:54976 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1knqDW-0003kX-5j for qemu-devel@archiver.kernel.org; Fri, 11 Dec 2020 16:44:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52402) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knqAk-0002IA-8x for qemu-devel@nongnu.org; Fri, 11 Dec 2020 16:41:54 -0500 Received: from mail-ot1-x343.google.com ([2607:f8b0:4864:20::343]:45713) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1knqAd-0006sO-JV for qemu-devel@nongnu.org; Fri, 11 Dec 2020 16:41:53 -0500 Received: by mail-ot1-x343.google.com with SMTP id h18so9598151otq.12 for ; Fri, 11 Dec 2020 13:41:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=1wZQo08W4y18MFXQvXuGaqmeyVDr030sK43u1+GHIEU=; b=VrZBKe67V0jCJxp4AP7ZhaFnaFo0RRX+tnb7H/J9nJlwIMhWldCaiPKLjIZQi5EJFf wRNhbFdRwWjNqPLcZQcMPa6R7eDE7krC08IOVzdbNN2/s7SrpCg+iuhiJJu53+piMvqM 928nd5aR73JvktpvwNdCbJjMgLlpjTPP5TbPEglY1ovi41r8ZB+Ew2fh2CLXunzcK9vS noQ7Czl39ugu1CFvsAV9QD3HYNqqfnVWGpc0FkTFwM3Ie8JDiLB1CmmbIF4QrvBdC1qJ LCjZKlvC7vgPIoADkpVanLeDFf5xAPoNp1fQyDcFdy7VAhKEx6aZ5OShVXAbwJ7koNCB vZGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=1wZQo08W4y18MFXQvXuGaqmeyVDr030sK43u1+GHIEU=; b=ofHJn5JM4YFv8g4/S2SJyvv2+Q+rEWHGIE2HImgwUPLy6qpWPAeUsUK/sN84MOc8WW FCWzWCy5s2YrvpZwkpAZvrwyYGc769WIsCYaiHpaOkP+hbWdgFsVXbHqKw+I7gV4TMyb 3+XyimiIp+cOAQV4NTfBSbFL4jqTuzChRA0iDWbi/J2yIo9672QxAbtynPF6Ccq4ynOD 2DUWYfhwyuWhzOCEXwgx09GmcQzD1gmON1EbqnWa+Bz3FNVMiiA4awJ22aQKDLkgjA9O sl01l8k5VglqD88KIS25rSoiajCZo8W8c1A4WzxZYlDFC9zCLQEEGFGuDxh8IukVYrcP jsfw== X-Gm-Message-State: AOAM533tPjqgZ6ccf3+X+2689IbwKizh7rGJ0YSNwVbXZw05ERVOHAEm ke1qybpX50sapatO/HbpR3q8lQ== X-Google-Smtp-Source: ABdhPJwcgNyQHPKy/uQRLag+cvdjUdPWmJnPP9xVXHOFL9uwJnM+9xZxK3Z+PiZdWk9mR9KhbJMMLA== X-Received: by 2002:a9d:506:: with SMTP id 6mr10796575otw.95.1607722901208; Fri, 11 Dec 2020 13:41:41 -0800 (PST) Received: from [10.10.121.52] (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id y204sm2116898oiy.38.2020.12.11.13.41.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 11 Dec 2020 13:41:40 -0800 (PST) Subject: Re: [PATCH] icount: improve exec nocache usage To: Pavel Dovgalyuk , qemu-devel@nongnu.org References: <160741865825.348476.7169239332367828943.stgit@pasha-ThinkPad-X280> From: Richard Henderson Message-ID: Date: Fri, 11 Dec 2020 15:41:38 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <160741865825.348476.7169239332367828943.stgit@pasha-ThinkPad-X280> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=2607:f8b0:4864:20::343; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x343.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, NICE_REPLY_A=-0.001, 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: pbonzini@redhat.com, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On 12/8/20 3:10 AM, Pavel Dovgalyuk wrote: > cpu-exec tries to execute TB without caching when current > icount budget is over. But sometimes refilled budget is big > enough to try executing cached blocks. > This patch checks that instruction budget is big enough > for next block execution instead of just running cpu_exec_nocache. > It halves the number of calls of cpu_exec_nocache function > during tested OS boot scenario. > > Signed-off-by: Pavel Dovgalyuk > --- > accel/tcg/cpu-exec.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c > index 58aea605d8..251b340fb9 100644 > --- a/accel/tcg/cpu-exec.c > +++ b/accel/tcg/cpu-exec.c > @@ -685,7 +685,7 @@ static inline void cpu_loop_exec_tb(CPUState *cpu, TranslationBlock *tb, > insns_left = MIN(0xffff, cpu->icount_budget); > cpu_neg(cpu)->icount_decr.u16.low = insns_left; > cpu->icount_extra = cpu->icount_budget - insns_left; > - if (!cpu->icount_extra) { > + if (!cpu->icount_extra && insns_left < tb->icount) { Reviewed-by: Richard Henderson I also wonder if we should really be not caching these. Ever since MTTCG, we have not actually been reusing the memory. We're simply removing the TB from the hash table. I think we should be remembering these just in case we can in fact reuse them. r~