From patchwork Tue Feb 7 15:28:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 725219 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vHprm53Ttz9s7f for ; Wed, 8 Feb 2017 02:57:44 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="N7MNAbK1"; dkim-atps=neutral Received: from localhost ([::1]:55028 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cb89G-0001ZK-5T for incoming@patchwork.ozlabs.org; Tue, 07 Feb 2017 10:57:42 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36203) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cb7gr-0003d1-0p for qemu-devel@nongnu.org; Tue, 07 Feb 2017 10:28:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cb7go-0007bx-0D for qemu-devel@nongnu.org; Tue, 07 Feb 2017 10:28:21 -0500 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:35101) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cb7gn-0007aj-QB for qemu-devel@nongnu.org; Tue, 07 Feb 2017 10:28:17 -0500 Received: by mail-wm0-x244.google.com with SMTP id u63so28937188wmu.2 for ; Tue, 07 Feb 2017 07:28:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=c/bw5TfrsNrBwne/QW3LpykZMuo3cgwyABlHzJFnV8w=; b=N7MNAbK1u18SEk6RLZd07hFw2uQunDzzHE4NwtXy4LL12hFohMBReIg6MrciqgDpHz a9OY6UkczsT1DbmpwvG2AXD2SLAhGgwW22ZHAoBozxFtRKvjyAu4pA5EUzdCNvPUkSPZ Bd/HolYjVGNYf6KP/V4N0SdjvNduuD+anPDR5WiCnb6rJkm/yNc1fnl/qftwoM4246TS gZLtBBNGXszlzNYT0hsrIypgSfTucAG0LMKD6Iz46jiABi4ztYlSGk9JtMF2PMfw8Rtc SyRXmW0eyDktM0kPBF6/+kPRAEvQ+K2xowRuuP7nsAdiAbKYgzL5hIpQHWv6oYDaInfD 5KVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=c/bw5TfrsNrBwne/QW3LpykZMuo3cgwyABlHzJFnV8w=; b=qLr3ysyhffMNGzktdQsWA5Kz2oRoqkZhlXsypJJQsNBjrgsLg30a8/tmvltPDDF4o3 oqm9dreM8+yMd+sCybq/JWiyfWGCNlhZz6evd3vKQ3UeN5TaIkQ5Q3kAOokRwyeZ8i3b BGSAoeYe1LTKNWUzQmL6o3+k5gQfS/GCh5x/jOtLNeDjf/G97g0bN9I7cirCFI3Lq2Yd gbesvWqnKB1KnTOjlxhtcBsgbCNzGNH7ZeuPvz/YXITYjAGjXxPNu4taAcIGvrJPyljn 6Qs0J6LoeFIgj9Zn6zEFNGfLsYTbAW3+gv9b7POh+8ZAhF5t2wcvF35Tho9I3dilH9sz ZWAg== X-Gm-Message-State: AMke39lhUdYZ7gh8S6AY4DcrIyuxhueC7GJ5GhCNePRQIQnb0F1EaNw2RQ6ppOWLkVds3Q== X-Received: by 10.28.232.196 with SMTP id f65mr12849433wmi.19.1486481296491; Tue, 07 Feb 2017 07:28:16 -0800 (PST) Received: from [192.168.10.165] (94-39-187-56.adsl-ull.clienti.tiscali.it. [94.39.187.56]) by smtp.googlemail.com with ESMTPSA id t103sm7886888wrc.43.2017.02.07.07.28.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Feb 2017 07:28:15 -0800 (PST) To: Pavel Dovgalyuk , qemu-devel@nongnu.org References: <002801d2810f$18809c20$4981d460$@ru> From: Paolo Bonzini Message-ID: <4ff40db3-ca73-42a3-c565-7b450e1ea2ea@redhat.com> Date: Tue, 7 Feb 2017 16:28:15 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <002801d2810f$18809c20$4981d460$@ru> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::244 Subject: Re: [Qemu-devel] [PATCH] icount: remove useless exit_request assignment X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" On 07/02/2017 07:54, Pavel Dovgalyuk wrote: > This patch removes unneeded assignment to cpu->exit_request. > cpu_exec_nocache executes all available instructions and therefore > icount becomes 0. Then other conditions will break the execution > loop, making assignment to cpu->exit_request useless. > > This patch should be applied over Paolo's series: > https://www.mail-archive.com/qemu-devel@nongnu.org/msg426058.html > > Signed-off-by: Pavel Dovgalyuk > --- > cpu-exec.c | 1 - > 1 file changed, 1 deletion(-) > > diff --git a/cpu-exec.c b/cpu-exec.c > index 5cef8bc..91d1faf 100644 > --- a/cpu-exec.c > +++ b/cpu-exec.c > @@ -577,7 +577,6 @@ static inline void cpu_loop_exec_tb(CPUState *cpu, TranslationBlock *tb, > if (insns_left > 0) { > cpu_exec_nocache(cpu, insns_left, tb, false); > } > - atomic_set(&cpu->exit_request, 1); > } > } > > Nice, thanks. We can just squash the two patches with my 7/7 like this: diff --git a/cpu-exec.c b/cpu-exec.c index 9a7ff1b..1026cd0 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -517,7 +517,10 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, *last_tb = NULL; } } - if (unlikely(atomic_read(&cpu->exit_request) || replay_has_interrupt())) { + + /* Finally, check if we need to exit to the main loop. */ + if (unlikely(atomic_read(&cpu->exit_request) + || (use_icount && cpu->icount_decr.u16.low + cpu->icount_extra == 0))) { atomic_set(&cpu->exit_request, 0); cpu->exception_index = EXCP_INTERRUPT; return true; @@ -527,8 +530,7 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, } static inline void cpu_loop_exec_tb(CPUState *cpu, TranslationBlock *tb, - TranslationBlock **last_tb, int *tb_exit, - SyncClocks *sc) + TranslationBlock **last_tb, int *tb_exit) { uintptr_t ret; int32_t insns_left; @@ -578,10 +580,7 @@ static inline void cpu_loop_exec_tb(CPUState *cpu, TranslationBlock *tb, */ if (insns_left > 0) { cpu_exec_nocache(cpu, insns_left, tb, false); - align_clocks(sc, cpu); } - cpu->exception_index = EXCP_INTERRUPT; - cpu_loop_exit(cpu); } } @@ -641,7 +640,7 @@ int cpu_exec(CPUState *cpu) while (!cpu_handle_interrupt(cpu, &last_tb)) { TranslationBlock *tb = tb_find(cpu, last_tb, tb_exit); - cpu_loop_exec_tb(cpu, tb, &last_tb, &tb_exit, &sc); + cpu_loop_exec_tb(cpu, tb, &last_tb, &tb_exit); /* Try to align the host and virtual clocks if the guest is in advance */ align_clocks(&sc, cpu);