From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BFD79C433F5 for ; Fri, 1 Oct 2021 14:19:22 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8D43E61A6F for ; Fri, 1 Oct 2021 14:19:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8D43E61A6F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=MUwCBShLh6TIuHX0haDR6d6OOWLWLk18FLbl0hnqMGI=; b=YE5ppftjyppvrd k4+5MXCa5KG7/ZMyrvca/fFGuBUBfjG1R6uZ4c6uSNiGy5w+PBfsohSSvgSYDcDpfTEQwnAVxePvc KpYSUCIWP0jBh0MMsj9GTQjCVVvghqkENmHUMdT7T58OmWhxx7HZ+bm0Dj/L0+jZVimVNH3G4RWPw PHheJYr+1ti/ovTPi7feYDB4ABXFgg4yj8zBmeug9wGTsDt33lPscyb+iMWcGd+GyIsLWxVdrclAW UEhxDW7Ot+IISwUlFiIsHrDJQ9KgwubqEvA1Zkg+R7ip0bWiWhY7uS54J5Y8/ToDdfmmG9+KuqryF IXTFcvxR+MlTe/IolKzA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mWJLq-000VRf-Gf; Fri, 01 Oct 2021 14:17:26 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mWJLn-000VQn-6f for linux-arm-kernel@lists.infradead.org; Fri, 01 Oct 2021 14:17:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633097840; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QXYa/6pNkGh7DhVVHoCv6tDp16H1ut5Qth6GnXzzM4k=; b=KiTdvseBvHaGgHFczbl1dfpFw6l5q5YlfP6d8JDmFyks9FNdwZ29T2gYZEqR5SByZGYxOC dgU9TlLxNG/w3mZwZdq0X7OqrcaOq7GpWC3eCMbGoWDzfU2tmPHELRmYH192FR5P0ydSGZ 4ERU/yt+EVom2dTzuQsrX7zn/keamTI= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-302-eqP2krS5MFOW2YTOc3PxrA-1; Fri, 01 Oct 2021 10:17:06 -0400 X-MC-Unique: eqP2krS5MFOW2YTOc3PxrA-1 Received: by mail-ed1-f71.google.com with SMTP id c7-20020a05640227c700b003d27f41f1d4so10490430ede.16 for ; Fri, 01 Oct 2021 07:17:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=QXYa/6pNkGh7DhVVHoCv6tDp16H1ut5Qth6GnXzzM4k=; b=29AVzZ+v72POItfgjFgFa299abH03zxjK323zu2iNjF0EDnBKqLlnjTMfyQaV+ZZ+r FOIbTKm6nvmxRa3pPUakL6Xu2BIP3yXyv5ScbFNT3EV0S5e2uZONuAB7mDkMPioqJKth bRAsrXrlZZiGTnlkWS/1pzFJnD1SuF3+pip2Iq/IDfUkle5tpdOCVT63EHztk39iMQ2q jYuyH+kCAb6MJGbnDRZpyEVfdQFKGAI42Uf2BPLydHtmVauQFNPR0hQnNYdwCL5wLPNS 53X1lAEyvPJDQpz3HKOPcb0eJiKJrm5DJgDJc4wj9myVAjNqy7Mqy8/fWGIkE30gSYPr yF5g== X-Gm-Message-State: AOAM533VfdYyWFOfZzGs2X+V82ok5ox4UCST+Nur12t0NdgQnjeq6UEH YDyM2mRybMMqSPH/QmewBWtVNuG6QNUeYOiWCknf1JfV9sQwuMPSACEKoh6uYGd8Qvw1ulpg/Vm M5VLXktzOztnzl1YK3VeijWLbTXVr7jUegLc= X-Received: by 2002:aa7:c7c2:: with SMTP id o2mr14606960eds.166.1633097824765; Fri, 01 Oct 2021 07:17:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxCiMsXBYCQ8UWIYXEv0CCzQitsksl4VwheKReCDgqX9Kwx4ytTAjcLaQ0AagoSgyQ5wyZQng== X-Received: by 2002:aa7:c7c2:: with SMTP id o2mr14606924eds.166.1633097824509; Fri, 01 Oct 2021 07:17:04 -0700 (PDT) Received: from ?IPV6:2001:b07:6468:f312:5e2c:eb9a:a8b6:fd3e? ([2001:b07:6468:f312:5e2c:eb9a:a8b6:fd3e]) by smtp.gmail.com with ESMTPSA id f25sm1228903ejb.34.2021.10.01.07.17.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 01 Oct 2021 07:17:03 -0700 (PDT) Message-ID: Date: Fri, 1 Oct 2021 16:17:02 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.0 Subject: Re: [PATCH v8 4/7] KVM: x86: Report host tsc and realtime values in KVM_GET_CLOCK To: Thomas Gleixner , Marcelo Tosatti , Oliver Upton Cc: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, Sean Christopherson , Marc Zyngier , Peter Shier , Jim Mattson , David Matlack , Ricardo Koller , Jing Zhang , Raghavendra Rao Anata , James Morse , Alexandru Elisei , Suzuki K Poulose , linux-arm-kernel@lists.infradead.org, Andrew Jones , Will Deacon , Catalin Marinas References: <20210916181538.968978-1-oupton@google.com> <20210916181538.968978-5-oupton@google.com> <20210929185629.GA10933@fuller.cnet> <20210930192107.GB19068@fuller.cnet> <871r557jls.ffs@tglx> From: Paolo Bonzini In-Reply-To: <871r557jls.ffs@tglx> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211001_071723_376213_8D555B08 X-CRM114-Status: GOOD ( 18.55 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 01/10/21 01:02, Thomas Gleixner wrote: > > Now the proposed change is creating exactly the same problem: > > + if (data.flags & KVM_CLOCK_REALTIME) { > + u64 now_real_ns = ktime_get_real_ns(); > + > + /* > + * Avoid stepping the kvmclock backwards. > + */ > + if (now_real_ns > data.realtime) > + data.clock += now_real_ns - data.realtime; > + } Indeed, though it's opt-in (you can always not pass KVM_CLOCK_REALTIME and then the kernel will not muck with the value you gave it). > virt came along and created a hard to solve circular dependency > problem: > > - If CLOCK_MONOTONIC stops for too long then NTP/PTP gets out of > sync, but everything else is happy. > > - If CLOCK_MONOTONIC jumps too far forward, then all hell breaks > lose, but NTP/PTP is happy. Yes, I agree that this sums it up. For example QEMU (meaning: Marcelo :)) has gone for the former and "hoping" that NTP/PTP sorts it out sooner or later. The clock in nanoseconds is sent out to the destination and restored. Google's userspace instead went for the latter. The reason is that they've always started running on the destination before finishing the memory copy[1], therefore it's much easier to bound the CLOCK_MONOTONIC jump. I do like very much the cooperative S2IDLE or even S3 way to handle the brownout during live migration. However if your stopping time is bounded, these patches are nice because, on current processors that have TSC scaling, they make it possible to keep the illusion of the TSC running. Of course that's a big "if"; however, you can always bound the stopping time by aborting the restart on the destination machine once you get close enough to the limit. Paolo [1] see https://dl.acm.org/doi/pdf/10.1145/3296975.3186415, figure 3 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel