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 <[email protected]>
> ---
>  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 <[email protected]>

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~


Reply via email to