From nobody Tue Oct 28 01:48:39 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515660351307399.8876125995097; Thu, 11 Jan 2018 00:45:51 -0800 (PST) Received: from localhost ([::1]:53160 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZYUe-0000K3-DF for importer@patchew.org; Thu, 11 Jan 2018 03:45:48 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47721) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZYD8-0001hU-7p for qemu-devel@nongnu.org; Thu, 11 Jan 2018 03:27:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZYD4-0002yM-5j for qemu-devel@nongnu.org; Thu, 11 Jan 2018 03:27:42 -0500 Received: from mail.ispras.ru ([83.149.199.45]:42080) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZYD3-0002xk-OD for qemu-devel@nongnu.org; Thu, 11 Jan 2018 03:27:38 -0500 Received: from [127.0.1.1] (unknown [85.142.117.226]) by mail.ispras.ru (Postfix) with ESMTPSA id DB46454006F; Thu, 11 Jan 2018 11:27:36 +0300 (MSK) From: Pavel Dovgalyuk To: qemu-devel@nongnu.org Date: Thu, 11 Jan 2018 11:27:38 +0300 Message-ID: <20180111082738.27295.80055.stgit@pasha-VirtualBox> In-Reply-To: <20180111082452.27295.85707.stgit@pasha-VirtualBox> References: <20180111082452.27295.85707.stgit@pasha-VirtualBox> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 83.149.199.45 Subject: [Qemu-devel] [RFC PATCH v3 29/30] replay: improve replay performance 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: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, pavel.dovgaluk@ispras.ru, mst@redhat.com, jasowang@redhat.com, quintela@redhat.com, zuban32s@gmail.com, maria.klimushenkova@ispras.ru, dovgaluk@ispras.ru, kraxel@redhat.com, boost.lists@gmail.com, pbonzini@redhat.com, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 This patch skips cpu_exec when there is no CPU code to execute in replay mo= de. Signed-off-by: Pavel Dovgalyuk Signed-off-by: Maria Klimushenkova --- cpus.c | 50 +++++++++++++++++++++++++------------------= ---- include/sysemu/replay.h | 3 +++ replay/replay.c | 13 ++++++++++++ 3 files changed, 43 insertions(+), 23 deletions(-) diff --git a/cpus.c b/cpus.c index bafedfc..ef4c5b9 100644 --- a/cpus.c +++ b/cpus.c @@ -1449,39 +1449,43 @@ static void *qemu_tcg_rr_cpu_thread_fn(void *arg) cpu =3D first_cpu; } =20 - while (cpu && !cpu->queued_work_first && !cpu->exit_request) { + if (!replay_has_checkpoint()) { + while (cpu && !cpu->queued_work_first && !cpu->exit_request) { =20 - atomic_mb_set(&tcg_current_rr_cpu, cpu); - current_cpu =3D cpu; + atomic_mb_set(&tcg_current_rr_cpu, cpu); + current_cpu =3D cpu; =20 - qemu_clock_enable(QEMU_CLOCK_VIRTUAL, - (cpu->singlestep_enabled & SSTEP_NOTIMER) = =3D=3D 0); + qemu_clock_enable(QEMU_CLOCK_VIRTUAL, + (cpu->singlestep_enabled & SSTEP_NOTIMER= ) =3D=3D 0); =20 - if (cpu_can_run(cpu)) { - int r; + if (cpu_can_run(cpu)) { + int r; =20 - prepare_icount_for_run(cpu); + prepare_icount_for_run(cpu); =20 - r =3D tcg_cpu_exec(cpu); + r =3D tcg_cpu_exec(cpu); =20 - process_icount_data(cpu); + process_icount_data(cpu); =20 - if (r =3D=3D EXCP_DEBUG) { - cpu_handle_guest_debug(cpu); - break; - } else if (r =3D=3D EXCP_ATOMIC) { - cpu_exec_step_atomic(cpu); + if (r =3D=3D EXCP_DEBUG) { + cpu_handle_guest_debug(cpu); + break; + } else if (r =3D=3D EXCP_ATOMIC) { + cpu_exec_step_atomic(cpu); + break; + } + } else if (cpu->stop) { + if (cpu->unplug) { + cpu =3D CPU_NEXT(cpu); + } break; } - } else if (cpu->stop) { - if (cpu->unplug) { - cpu =3D CPU_NEXT(cpu); - } - break; - } =20 - cpu =3D CPU_NEXT(cpu); - } /* while (cpu && !cpu->exit_request).. */ + cpu =3D CPU_NEXT(cpu); + } /* while (cpu && !cpu->exit_request).. */ + } else { + qemu_notify_event(); + } =20 /* Does not need atomic_mb_set because a spurious wakeup is okay. = */ atomic_set(&tcg_current_rr_cpu, NULL); diff --git a/include/sysemu/replay.h b/include/sysemu/replay.h index d026b28..44c1ff7 100644 --- a/include/sysemu/replay.h +++ b/include/sysemu/replay.h @@ -122,6 +122,9 @@ void replay_shutdown_request(ShutdownCause cause); Returns 0 in PLAY mode if checkpoint was not found. Returns 1 in all other cases. */ bool replay_checkpoint(ReplayCheckpoint checkpoint); +/*! Used to determine that checkpoint is pending. + Does not proceed to the next event in the log. */ +bool replay_has_checkpoint(void); =20 /* Asynchronous events queue */ =20 diff --git a/replay/replay.c b/replay/replay.c index c9fd984..b9c496a 100644 --- a/replay/replay.c +++ b/replay/replay.c @@ -219,6 +219,19 @@ out: return res; } =20 +bool replay_has_checkpoint(void) +{ + bool res =3D false; + if (replay_mode =3D=3D REPLAY_MODE_PLAY) { + replay_mutex_lock(); + replay_account_executed_instructions(); + res =3D EVENT_CHECKPOINT <=3D replay_state.data_kind + && replay_state.data_kind <=3D EVENT_CHECKPOINT_LAST; + replay_mutex_unlock(); + } + return res; +} + void replay_init_locks(void) { replay_mutex_init();