From nobody Mon Feb 9 20:10:17 2026 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; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539895814622486.96277541070083; Thu, 18 Oct 2018 13:50:14 -0700 (PDT) Received: from localhost ([::1]:44591 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDFFF-0005NH-7X for importer@patchew.org; Thu, 18 Oct 2018 16:50:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47961) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDEy8-00075x-OK for qemu-devel@nongnu.org; Thu, 18 Oct 2018 16:32:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gDEy3-00069O-G2 for qemu-devel@nongnu.org; Thu, 18 Oct 2018 16:32:31 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:46267) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gDEy1-00067D-H3 for qemu-devel@nongnu.org; Thu, 18 Oct 2018 16:32:25 -0400 Received: by mail-wr1-x444.google.com with SMTP id n11-v6so35030281wru.13 for ; Thu, 18 Oct 2018 13:32:24 -0700 (PDT) Received: from 640k.lan (dynamic-adsl-78-12-231-174.clienti.tiscali.it. [78.12.231.174]) by smtp.gmail.com with ESMTPSA id a12-v6sm14270952wrr.71.2018.10.18.13.32.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Oct 2018 13:32:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=ePtbzgc70k9gGLpBJMUy8rTVhabLbrTY1Yy2JOKpK+Y=; b=Ql3RYpkhNk++KGgQFnhWgA9gCk/As2O0rQ9UNO1+dX9gwMP0OEMU4R6bIwlUuUiBpY y3aqdzh3nIKPw8FI5y5wN7Kc6h9fV7IsX+PPZ/1OwF8+6R8ovdx3goNlM9GYDfVQcMYJ CSxakcVzZX4lZua5OWmjYul8pdLYXdQVqEYeJuhKaZsoXB0RMYe+Vb1l9oiVPu6H+bCy vhKoLHHsdjPBzJW/HH+b4xi8DoIf2/34xlBQWcp55JkXIRRoODO0kuuM2ZV9HfW8El7X KD+DFR72q36MKHmoKjHwZ1Hk5Z4NvCZPeKv57x6XssUMiAJPlUAgzIK70ATkOmHKSrlb IkZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=ePtbzgc70k9gGLpBJMUy8rTVhabLbrTY1Yy2JOKpK+Y=; b=endB1uUTjB6+mOSwYcqfIPwXSOZB8aLP7qybLYRuJA9m2G2J0ipx5dW49NJ24km9ii vNOfW5SbkSkicozX/7FG1cQLG1uWFkV8z1ShB04w8VRo81RdLXbJJB7WqkEvjI7hd1IE PTpn9QiiqTsQkb5PJXwRuespbm4rGPqLd8pfsbvJaIiXCuvbTsVxa7/UH/3Yumczp10I G4q7L5mXUSEx82tGwxfKr4QAeEtXNYLpgkKnpuSnPza5EU8CwrYGnDkKy9QqBp1ksCYT 0nVB4UUiQFzl1GYlUOd3KsW5nMJFZJX8EcBEb5wimugqpq+n77Hb2RuO6oqSIUpAwjMH 7FFg== X-Gm-Message-State: ABuFfohNgOHY1dKZzowQjfb01NEgBCXSBYZOGq5H+AAVvGZTexDEJ5Z7 iPSPWh5SZaRNFr0ARtSF8wD9hadN X-Google-Smtp-Source: ACcGV60667TNLJ9adr6jY7nY5PQClLZvesFxq7ah2xxua4OwNKr+3Kme0mHVD0wDMTTUxjvch90Y3Q== X-Received: by 2002:adf:aa90:: with SMTP id h16-v6mr29120135wrc.216.1539894742800; Thu, 18 Oct 2018 13:32:22 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 18 Oct 2018 22:31:32 +0200 Message-Id: <1539894735-14232-6-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1539894735-14232-1-git-send-email-pbonzini@redhat.com> References: <1539894735-14232-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 Subject: [Qemu-devel] [PULL 05/48] qemu-timer: optimize record/replay checkpointing for all clocks 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: Artem Pisarenko Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Artem Pisarenko Removes redundant checkpoints in replay log when there are no expired timers in timers list, associated with corresponding clock (i.e. no rr events associated with current clock value). This also improves performance in rr mode. Signed-off-by: Artem Pisarenko Message-Id: <549dbf4ebfa4c82051d01a264c27f88929fc277b.1539764043.git.artem.= k.pisarenko@gmail.com> Signed-off-by: Paolo Bonzini --- include/qemu/timer.h | 2 +- util/qemu-timer.c | 67 +++++++++++++++++++++++-------------------------= ---- 2 files changed, 31 insertions(+), 38 deletions(-) diff --git a/include/qemu/timer.h b/include/qemu/timer.h index 9f37c92..9c668c8 100644 --- a/include/qemu/timer.h +++ b/include/qemu/timer.h @@ -65,7 +65,7 @@ typedef enum { * QEMU_TIMER_ATTR_EXTERNAL: drives external subsystem * * Timers with this attribute do not recorded in rr mode, therefore it cou= ld be - * used for the subsystems that operate outside the guest core. Applicable= only + * used for the subsystems that operate outside the guest core. Relevant o= nly * with virtual clock type. */ =20 diff --git a/util/qemu-timer.c b/util/qemu-timer.c index 1cc1b2f..8d3a806 100644 --- a/util/qemu-timer.c +++ b/util/qemu-timer.c @@ -482,6 +482,25 @@ bool timer_expired(QEMUTimer *timer_head, int64_t curr= ent_time) return timer_expired_ns(timer_head, current_time * timer_head->scale); } =20 +static bool timer_checkpoint(QEMUClockType clock) +{ + assert(replay_mode !=3D REPLAY_MODE_NONE); + switch (clock) { + case QEMU_CLOCK_VIRTUAL: + return replay_checkpoint(CHECKPOINT_CLOCK_VIRTUAL); + case QEMU_CLOCK_HOST: + return replay_checkpoint(CHECKPOINT_CLOCK_HOST); + case QEMU_CLOCK_VIRTUAL_RT: + return replay_checkpoint(CHECKPOINT_CLOCK_VIRTUAL_RT); + default: + /* QEMU_CLOCK_REALTIME is external to the emulation and does + * not need checkpointing. + */ + break; + } + return true; +} + bool timerlist_run_timers(QEMUTimerList *timer_list) { QEMUTimer *ts; @@ -489,7 +508,7 @@ bool timerlist_run_timers(QEMUTimerList *timer_list) bool progress =3D false; QEMUTimerCB *cb; void *opaque; - bool need_replay_checkpoint =3D false; + bool need_replay_checkpoint =3D (replay_mode !=3D REPLAY_MODE_NONE); =20 if (!atomic_read(&timer_list->active_timers)) { return false; @@ -500,43 +519,17 @@ bool timerlist_run_timers(QEMUTimerList *timer_list) goto out; } =20 - switch (timer_list->clock->type) { - case QEMU_CLOCK_REALTIME: - break; - default: - case QEMU_CLOCK_VIRTUAL: - if (replay_mode !=3D REPLAY_MODE_NONE) { - /* Checkpoint for virtual clock is redundant in cases where - * it's being triggered with only non-EXTERNAL timers, because - * these timers don't change guest state directly. - * Since it has conditional dependence on specific timers, it = is - * subject to race conditions and requires special handling. - * See below. - */ - need_replay_checkpoint =3D true; - } - break; - case QEMU_CLOCK_HOST: - if (!replay_checkpoint(CHECKPOINT_CLOCK_HOST)) { - goto out; - } - break; - case QEMU_CLOCK_VIRTUAL_RT: - if (!replay_checkpoint(CHECKPOINT_CLOCK_VIRTUAL_RT)) { - goto out; - } - break; - } - /* - * Extract expired timers from active timers list and and process them. + * Extract expired timers from active timers list and and process them, + * taking into account checkpointing required in rr mode. * - * In rr mode we need "filtered" checkpointing for virtual clock. The - * checkpoint must be recorded/replayed before processing any non-EXTE= RNAL timer, - * and that must only be done once since the clock value stays the sam= e. Because - * non-EXTERNAL timers may appear in the timers list while it being pr= ocessed, - * the checkpoint can be issued at a time until no timers are left and= we are - * done". + * The checkpoint must be recorded/replayed before processing any non-= EXTERNAL + * timer (external timers are those that don't affect guest state dire= ctly; + * usually they are QEMU_CLOCK_REALTIME, which doesn't checkpoint at a= ll, + * but there are exceptions). Checkpointing, furthermore, must only b= e done once + * since the clock value stays the same. Because non-EXTERNAL timers m= ay appear + * in the timers list while it being processed, the checkpoint can be = issued at + * a time until no timers are left and we are done". */ current_time =3D qemu_clock_get_ns(timer_list->clock->type); qemu_mutex_lock(&timer_list->active_timers_lock); @@ -552,7 +545,7 @@ bool timerlist_run_timers(QEMUTimerList *timer_list) /* once we got here, checkpoint clock only once */ need_replay_checkpoint =3D false; qemu_mutex_unlock(&timer_list->active_timers_lock); - if (!replay_checkpoint(CHECKPOINT_CLOCK_VIRTUAL)) { + if (!timer_checkpoint(timer_list->clock->type)) { goto out; } qemu_mutex_lock(&timer_list->active_timers_lock); --=20 1.8.3.1