From patchwork Thu Oct 18 11:04:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artem Pisarenko X-Patchwork-Id: 10647001 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0BA43112B for ; Thu, 18 Oct 2018 11:11:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1339285D2 for ; Thu, 18 Oct 2018 11:11:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E2A93285DA; Thu, 18 Oct 2018 11:11:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 548F0285D2 for ; Thu, 18 Oct 2018 11:11:28 +0000 (UTC) Received: from localhost ([::1]:41673 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD6D9-0005Kj-Ir for patchwork-qemu-devel@patchwork.kernel.org; Thu, 18 Oct 2018 07:11:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35585) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD69H-0002d9-SQ for qemu-devel@nongnu.org; Thu, 18 Oct 2018 07:07:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gD69E-0008WJ-Hr for qemu-devel@nongnu.org; Thu, 18 Oct 2018 07:07:27 -0400 Received: from mail-lj1-x244.google.com ([2a00:1450:4864:20::244]:37623) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gD69E-0008Sn-3q for qemu-devel@nongnu.org; Thu, 18 Oct 2018 07:07:24 -0400 Received: by mail-lj1-x244.google.com with SMTP id 63-v6so27319721ljs.4 for ; Thu, 18 Oct 2018 04:07:18 -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; bh=7z623pNkO+jjGol20n99SRHI+P1c60eoj9o5CcsAt0g=; b=k3YSFx8B3duc5lligvGoXfzt3wI79HFHrlbaT5JRCVbsbR7NmRgNTKjPRtMqMe9Fp1 W+NVNhWS+Y7fsakG3wM3WQnIiq5wZxfu9e2z+IzEe5sxzWB/n7IeG1L/6lk95nyI4iyq 7tqigk/fLyJ79zNk4TowesLhy3AdlNrwxXj83w3PLhMBl8Bbe10NS+guR3Rr3lt42a3H usErI6JUPNp39pnMBHvNdtDbrSdYRPjYA4hH6OQMeYKb2xOYSBYyIRGgqIu8/8kRG+uc ho/JAoH5keeKKwQwhCBE+kViQRbCNWLLTkwtF2bmCSr7Rv7cbzU2vLoEYAPRjWzP0ylx KDsQ== 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; bh=7z623pNkO+jjGol20n99SRHI+P1c60eoj9o5CcsAt0g=; b=GMDeApw+4etg7YRKTkm+h1/VbyQ4GOuoSZVtfBz9arwsvU1fsGebEnCXozlxKHlOeq d1/hfoPf7dM4mWH9NajI6pEk+1Kl0FORDx5TqYbLli9e8gKi1wJ4Hp4PD9MuFn0VldvD rMsr7AzLyGxfr7GHltvgXwu2pEcRBbTAIAgX+wHsm5b6/eDq481pezyyvvuhSPuNWVQj PZjePKWDVbaTborEeu5TI16o87xEKps+dzNN/k2iRuPH+gBdEZHqmvYjNfVAZNXNDnnD 9b9jTtAnSQoVHs3KtwDgzasZj0SPp6lkMPXIpZDcf1dLMX+kBOpRffnyEryVLREjx/NF i6Yw== X-Gm-Message-State: ABuFfoh9NhKx3ALRbyAUl/ZJdVQUOfECBWVQdbjYgjJlPRwyICt76o8q zXUiUSte3AyZcpmLukOMVy2bLNlqTm8= X-Google-Smtp-Source: ACcGV63A+Q83qvjjawRKNQffqW3Tzmbc3hgsg6xt0CbLl3KRKZ3Zw5BsXOMGl2yGbJAndw4M56Z0cw== X-Received: by 2002:a2e:7a19:: with SMTP id v25-v6mr3795401ljc.147.1539860836791; Thu, 18 Oct 2018 04:07:16 -0700 (PDT) Received: from localhost.localdomain ([77.221.221.49]) by smtp.gmail.com with ESMTPSA id u77-v6sm4575811lja.37.2018.10.18.04.07.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Oct 2018 04:07:16 -0700 (PDT) From: Artem Pisarenko To: qemu-devel@nongnu.org Date: Thu, 18 Oct 2018 17:04:27 +0600 Message-Id: X-Mailer: git-send-email 2.7.4 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::244 Subject: [Qemu-devel] [PATCH v3 0/4] Introduce attributes for timers subsystem and remove QEMU_CLOCK_VIRTUAL_EXT clock type 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: Paolo Bonzini , Artem Pisarenko , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Recent patches from series [PATCH v6] "Fixing record/replay and adding reverse debugging" introduced new clock type QEMU_CLOCK_VIRTUAL_EXT and replaced virtual timers in some external subsystems with it. This resulted in small change to existing behavior, which I consider to be unacceptable. Processing of virtual timers, belonging to new clock type, was kicked off to main loop, which made them asynchronous with vCPU thread and, in icount mode, with whole guest execution. This breaks expected determinism in non-record/replay icount mode of emulation where these "external subsystems" are isolated from host (i.e. they external only to guest core, not to emulation environment). Example for slirp ("user" backend for network device): User runs qemu in icount mode with rtc clock=vm without any external communication interfaces but with "-netdev user,restrict=on". It expects deterministic execution, because network services are emulated inside qemu and isolated from host. There are no reasons to get reply from DHCP server with different delay or something like that. These series of patches revert those commits and reimplement their modifications in a better way. Current implementation of timers/clock processing is confusing (at least for me) because of exceptions from design concept behind them, which already introduced by icount mode (which adds QEMU_CLOCK_VIRTUAL_RT). Adding QEMU_CLOCK_VIRTUAL_EXT just made things even more complicated. I consider these "alternative" virtual clocks to be some kind of hacks being convinient only to authors of relevant qemu features. Lets don't touch fundamental clock types and keep them orthogonal to special cases of timers handling. As far as I understand, original intention of author was just to make optimization in replay log by avoiding storing extra events which don't change guest state directly. Indeed, for example, ipv6 icmp timer in slirp does things which external to guest core and ends with sending network packet to guest, but record/replay will anyway catch event, corresponding to packet reception in guest network frontend, and store it to replay log, so there are no need in making checkpoint for corresponding clock when that timer fires. If so, then we just need to skip checkpoints for clock values, when only these specific timers are run. It is individual timers which are specific, not clock. Adding some kind of attribute/flag/property to individual timer allows any special qemu feature (such as record/replay) to inspect it and handle as needed. This design achieves less dependencies, more transparency and has more intuitive and clear sense. For record/replay feature it's achieved with 'EXTERNAL' attribute. The only drawback is that it required to add one extra mutex unlock/lock pair for virtual clock type in timerlist_run_timers() function (see patch 3), but it's being added only when qemu runs in record/replay mode. Finally, this patch series optimizes checkpointing for all other clocks it applies to. v3 changes: - fixed failed build in last patch - attributes has been refactored and restricted to be used only within qemu-timer (as suggested by Stefan Hajnoczi and Paolo Bonzini) v2 changes: - timers/aio interface refactored and improved, addition to couroutines removed (as Paolo Bonzini suggested) - fixed wrong reimplementation in qemu-timer.c caused race conditions - added bonus patch which optimizes checkpointing for other clocks P.S. I've tried to test record/replay with slirp, but in replay mode qemu stucks at guest linux boot after "Configuring network interfaces..." message, where DHCP communication takes place. It's broken in a same way both in master and master with reverted commits being fixed. P.S.2. I wasn't able to test these patches on purely clean master branch because of bugs https://bugs.launchpad.net/qemu/+bug/1790460 and https://bugs.launchpad.net/qemu/+bug/1795369, which workarounded by several not-accepted (yet?) modifications. Artem Pisarenko (4): Revert some patches from recent [PATCH v6] "Fixing record/replay and adding reverse debugging" Introduce attributes to qemu timer subsystem Restores record/replay behavior related to special virtual clock processing for timers used in external subsystems. Optimize record/replay checkpointing for all clocks it applies to include/block/aio.h | 59 ++++++++++++++++++--- include/qemu/timer.h | 128 +++++++++++++++++++++++----------------------- slirp/ip6_icmp.c | 9 ++-- tests/ptimer-test-stubs.c | 13 +++-- ui/input.c | 9 ++-- util/qemu-timer.c | 95 +++++++++++++++++++++++----------- 6 files changed, 201 insertions(+), 112 deletions(-)