From nobody Thu Nov 6 04:25:30 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; 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=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539529226998688.4951937984702; Sun, 14 Oct 2018 08:00:26 -0700 (PDT) Received: from localhost ([::1]:48655 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gBhsQ-0002UK-RY for importer@patchew.org; Sun, 14 Oct 2018 11:00:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56791) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gBhpb-0000Ow-Ln for qemu-devel@nongnu.org; Sun, 14 Oct 2018 10:57:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gBhpR-0003WN-RE for qemu-devel@nongnu.org; Sun, 14 Oct 2018 10:57:18 -0400 Received: from mail-lj1-x241.google.com ([2a00:1450:4864:20::241]:39983) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gBhpO-0003Pg-5t for qemu-devel@nongnu.org; Sun, 14 Oct 2018 10:57:12 -0400 Received: by mail-lj1-x241.google.com with SMTP id r83-v6so15208788ljr.7 for ; Sun, 14 Oct 2018 07:57:08 -0700 (PDT) Received: from localhost.localdomain ([77.221.221.49]) by smtp.gmail.com with ESMTPSA id b29-v6sm1516654lfj.81.2018.10.14.07.57.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 14 Oct 2018 07:57:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=O20jC3QsUYZtTk3J0luh6RD4XXRD3tfo9DOulOBOi7g=; b=lNy0USZ56Jc+1foUW7p2JRIu0GJdwSoUeDjgZ3KOhODBnttrIJyXRGAVqXvAJNOXBg GLXzCMkEgfkLadql9aElng1TLDKLXsLPDYlCU1x7LMK0sLJci7cMwBD/34UHjI5xk9Fi 1IqmlQzZHT5Rtnj0IMTkrFrnXAcKsAX8+sXaimzKuHmA2ehVAH4XYjYZfLarhk5x0K4a dM01Zea2GMlvvfI4vAyib3d/bRV7s24a4PKe9gbByyxC4UApvkmAi0sbVUmMfwdyp0MG ZKVBm9MAe8OYNSbkC8oZfdGiS+Yd1Gk6F1H50dEron5nClATcasV/iAr71kr1N0DfJNn BYmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=O20jC3QsUYZtTk3J0luh6RD4XXRD3tfo9DOulOBOi7g=; b=FoGnp1Xh2k2iM7Dr6UXaok1E72MC0Is516Mb51eUWpl1OjNNgQZBOWWtDo1mFzyKGR WGLd5zMx3U95RPQ5GglMoX75Ax3Q+tcoh8fnW8SmKwlfpbExwEjbHhPCfSPo3lERRby6 v3fwLDt87ZZudJQdfkmcNkDfyv6iInI062yc6pQ7hCO3uIbtni71oFR9615gqsBi74wJ Cjibe1WxEnrot9mlq/+cfX9+LUyvOvYPq5tUaznseCoggOCvFs1vxKIl99JxMR9maW5I MCpWpdL2u5zdKQgE8qhg7tOjADjAHmQzKFIS8dTjiX8emIOvsVGAcCYlb6E0Of8HL6aX jtug== X-Gm-Message-State: ABuFfojoXGUhfFq7jSRgE8+5lth69UbYcG3CLQHLBAFoeodjUl6r8Oqs hgaCgGiUFY42jYIqw0UOZBCa4JvmXfs= X-Google-Smtp-Source: ACcGV60SzeKGydwJEXASabFDDfCMfiybYxuQ/qezSHl2FJNFmSwY8Zg61FAaf2gUZDQQ+4iitncLQg== X-Received: by 2002:a2e:9e88:: with SMTP id f8-v6mr8553489ljk.142.1539529026824; Sun, 14 Oct 2018 07:57:06 -0700 (PDT) From: Artem Pisarenko To: qemu-devel@nongnu.org Date: Sun, 14 Oct 2018 20:55:09 +0600 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::241 Subject: [Qemu-devel] [PATCH 3/3] Restores record/replay behavior related to special virtual clock processing for timers used in external subsystems. 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: Jan Kiszka , Gerd Hoffmann , Pavel Dovgalyuk , Samuel Thibault , Paolo Bonzini , 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" Adds EXTERNAL attribute definition to qemu timers subsystem and assigns it = to virtual clock timers, used in slirp (ICMP IPv6) and ui (key queue). Virtual clock processing in rr mode reimplemented using this attribute. Fixes: 87f4fe7653baf55b5c2f2753fe6003f473c07342 Fixes: 775a412bf83f6bc0c5c02091ee06cf649b34c593 Fixes: 9888091404a702d7ec79d51b088d994b9fc121bd Signed-off-by: Artem Pisarenko --- include/qemu/timer.h | 10 ++++++-- slirp/ip6_icmp.c | 4 +++- ui/input.c | 5 ++-- util/qemu-timer.c | 67 ++++++++++++++++++++++++++++++++++++------------= ---- 4 files changed, 60 insertions(+), 26 deletions(-) diff --git a/include/qemu/timer.h b/include/qemu/timer.h index 031e3a1..53bfba5 100644 --- a/include/qemu/timer.h +++ b/include/qemu/timer.h @@ -65,11 +65,17 @@ typedef enum { * instead each attribute in bit set accessed with QEMU_TIMER_ATTR(id) mac= ro, * where 'id' is a unique part of attribute identifier. * - * No attributes defined currently. + * The following attributes are available: + * + * 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 + * with virtual clock type. */ =20 typedef enum { - /* none */ + QEMU_TIMER_ATTRBIT_EXTERNAL, } QEMUTimerAttrBit; =20 #define QEMU_TIMER_ATTR(id) (1 << QEMU_TIMER_ATTRBIT_ ## id) diff --git a/slirp/ip6_icmp.c b/slirp/ip6_icmp.c index ee333d0..7c08433 100644 --- a/slirp/ip6_icmp.c +++ b/slirp/ip6_icmp.c @@ -27,7 +27,9 @@ void icmp6_init(Slirp *slirp) return; } =20 - slirp->ra_timer =3D timer_new_ms(QEMU_CLOCK_VIRTUAL, ra_timer_handler,= slirp); + slirp->ra_timer =3D timer_new_a(QEMU_CLOCK_VIRTUAL, SCALE_MS, + QEMU_TIMER_ATTR(EXTERNAL), + ra_timer_handler, slirp); timer_mod(slirp->ra_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + NDP_Interval); } diff --git a/ui/input.c b/ui/input.c index 51b1019..6279187 100644 --- a/ui/input.c +++ b/ui/input.c @@ -448,8 +448,9 @@ void qemu_input_event_send_key_delay(uint32_t delay_ms) } =20 if (!kbd_timer) { - kbd_timer =3D timer_new_ms(QEMU_CLOCK_VIRTUAL, qemu_input_queue_pr= ocess, - &kbd_queue); + kbd_timer =3D timer_new_a(QEMU_CLOCK_VIRTUAL, SCALE_MS, + QEMU_TIMER_ATTR(EXTERNAL), + qemu_input_queue_process, &kbd_queue); } if (queue_count < queue_limit) { qemu_input_queue_delay(&kbd_queue, kbd_timer, diff --git a/util/qemu-timer.c b/util/qemu-timer.c index 29d8e39..8c6d1cb 100644 --- a/util/qemu-timer.c +++ b/util/qemu-timer.c @@ -490,6 +490,7 @@ bool timerlist_run_timers(QEMUTimerList *timer_list) bool progress =3D false; QEMUTimerCB *cb; void *opaque; + bool need_replay_checkpoint =3D false; =20 if (!atomic_read(&timer_list->active_timers)) { return false; @@ -500,28 +501,52 @@ 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_checkpoint(CHECKPOINT_CLOCK_VIRTUAL)) { - goto out; - } - 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; - } - current_time =3D qemu_clock_get_ns(timer_list->clock->type); + + if (replay_mode !=3D REPLAY_MODE_NONE) { + switch (timer_list->clock->type) { + case QEMU_CLOCK_REALTIME: + break; + default: + case QEMU_CLOCK_VIRTUAL: + /* Check whether there are pending timers used for external + * subsystems, before doing replay checkpoint. If there are on= ly + * such timers, then checkpoint will be redundant, because the= se + * timers don't change guest state directly. + * Procedure optimized to finish traversing timer list quickly, + * because it's a rare condition. + */ + qemu_mutex_lock(&timer_list->active_timers_lock); + ts =3D timer_list->active_timers; + while (timer_expired_ns(ts, current_time)) { + if (!(ts->attributes & QEMU_TIMER_ATTR(EXTERNAL))) { + need_replay_checkpoint =3D true; + break; + } + ts =3D ts->next; + } + qemu_mutex_unlock(&timer_list->active_timers_lock); + if (!need_replay_checkpoint) { + break; + } + + if (!replay_checkpoint(CHECKPOINT_CLOCK_VIRTUAL)) { + goto out; + } + 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; + } + } + for(;;) { qemu_mutex_lock(&timer_list->active_timers_lock); ts =3D timer_list->active_timers; --=20 2.7.4