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 58A71C433F5 for ; Mon, 4 Oct 2021 11:47:33 +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 18FEB6136F for ; Mon, 4 Oct 2021 11:47:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 18FEB6136F 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=Y9pxCSGeRI9RSbn8+Kmfo4LxFka6KigMX28ZiuCQTJU=; b=EZ8UiChfPa9U3T b8oThSHhjkPRcWhcyi95oQKy2qXQ38Uap9AH5dUHNggVOBVe3WnmzY0mk6glnRlKNawyXz/R+jyd5 fMEZs3j2YnS0YlSyqcup1z56YvnYK2n5FiWheeEaTMZD2JvQ1BqAPuFyJ9lhoLd1xRL7zS4ajLFn8 mWbHMrFM9V0nDpfhYnmXAipxwcv15hN10ucnZr7ibtJn0HSFTosxhbLmEYYG82aiBVFMOsPD7CzAG JXdRQ7s398LLIW/yOPAJjWJwttPYwKeBV/02BHrzCP2W7Z2Eaw9pG/OuhRNnDvVA03qKRiA79yCHS k/Ocwqae8iZSIWCyY1Bw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mXMOp-006GCs-Ee; Mon, 04 Oct 2021 11:44:52 +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 1mXMOe-006GAr-UG for linux-arm-kernel@lists.infradead.org; Mon, 04 Oct 2021 11:44:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633347879; 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=GTIIQiwexuN1RAdzEPgfC+3jBs1EDWZPLEcgd8QeZcU=; b=Iwj57JAN+ZtEu4OSWQOMq3eJNWoHLHfQM0IJcu2WvDZwoOROQwXBH0HdC9jB/Vreo+Rrw8 4lqUK6KiY7CXzdEmO3mP4Zpvash6vNMYgM0GxY+PXFI+fevc4IfGUyZOcdrkKcMfOfALdy JYiUOlSujnvsOkEYjYH1daoOaW8GKGM= 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-310-4sNBv-V9M3qUZooxmNQpIg-1; Mon, 04 Oct 2021 07:44:38 -0400 X-MC-Unique: 4sNBv-V9M3qUZooxmNQpIg-1 Received: by mail-ed1-f71.google.com with SMTP id t28-20020a508d5c000000b003dad7fc5caeso7002378edt.11 for ; Mon, 04 Oct 2021 04:44:38 -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=GTIIQiwexuN1RAdzEPgfC+3jBs1EDWZPLEcgd8QeZcU=; b=2y4ZDOy3u6db9Wii80N4nAX9IjmdorktRXe3l1357VgcZOM9az8KAlaeyFzClyXE83 uuS29glDe0RnSZiLh3x2oU9IDfVnbe+Fw1TfDVFzDIIhyJzafJ0WnFChiEmrT6FfVrWo tEOWxs5oNoK0TYGIq4F/7QLkvOi8LqKxn99kpqXFUqr1c2QOcYLTrUjwJLN6GKz2VQXQ r+qps87QNFZO5UIGWIgkh2G9mJzMvhAI/Chp8pFeHHDuw77XvlnHsQB4Zc4TIom6UO/5 AJPXJCu6Dro2zfnmPXrMfP/ta5a9i1poTtz8S2CqNRNutMtaoByCqJwsGPlx1VKb1ZVM qUNA== X-Gm-Message-State: AOAM530VxXhePcjTuisKL707gS7dpGoGdjxaemdGObbvmWyCKgecZjTr dy6fMfcdIOOhclPRJjzGhvVsJdpZJ+y9InSjIIg8/8GgIBEZbex/WcG75Rqc3QBFc6E3Pl5q6UK 3rCDxf3+EzxBfgptem3PzKkWw0bim613ULXo= X-Received: by 2002:a17:906:e85:: with SMTP id p5mr16759550ejf.159.1633347877512; Mon, 04 Oct 2021 04:44:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDeQKGDooaTNNGCBgf5hxRexDWyP01P+aRkP4Sg07t5/j6jHx/UP99CoVqUE4SEK2W0rQKSg== X-Received: by 2002:a17:906:e85:: with SMTP id p5mr16759518ejf.159.1633347877279; Mon, 04 Oct 2021 04:44:37 -0700 (PDT) Received: from ?IPV6:2001:b07:6468:f312:c8dd:75d4:99ab:290a? ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id b5sm7125953edu.13.2021.10.04.04.44.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 04 Oct 2021 04:44:36 -0700 (PDT) Message-ID: <89b4ab4e-c443-2b14-e878-8c04d066f5b0@redhat.com> Date: Mon, 4 Oct 2021 13:44:35 +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 7/7] KVM: x86: Expose TSC offset controls to userspace To: Marcelo Tosatti Cc: Oliver Upton , 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-8-oupton@google.com> <20210930191416.GA19068@fuller.cnet> <48151d08-ee29-2b98-b6e1-f3c8a1ff26bc@redhat.com> <20211001103200.GA39746@fuller.cnet> <7901cb84-052d-92b6-1e6a-028396c2c691@redhat.com> <20211001191117.GA69579@fuller.cnet> From: Paolo Bonzini In-Reply-To: <20211001191117.GA69579@fuller.cnet> 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-20211004_044441_136491_F7D10A53 X-CRM114-Status: GOOD ( 12.67 ) 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 21:11, Marcelo Tosatti wrote: > That said, the point is: why not advance the_TSC_ values > (instead of kvmclock nanoseconds), as doing so would reduce > the "the CLOCK_REALTIME delay which is introduced during migration" > for both kvmclock users and modern tsc clocksource users. It already does, that's the cool part. Take again the formula here: guest_off_1 = t_0 + guest_off_0 + (k_1 - k_0) * freq - t_1 and set: t_1 = t_0 + host_off_0_1 + (k_1 - k_0) * freq i.e. t_0 and t_1 are different because 1) the machines were booted at different times, which is host_off_0_1 2) t_1 includes the migration downtime between k_0 and k_1 Now you have: guest_off_1 = t_0 + guest_off_0 + (k_1 - k_0) * freq - t_0 - real_off_n - (k_1 - k_0) * freq guest_off_1 = guest_off_0 - host_off_0_1 That is, the TSC is exactly the same as it was on the source, just adjusted because the two machines were booted at different times. The need to have precise (ns, cycle) pairings is exactly because it ensures that everything cancels in the formula, and all that is left is the differences in the TSC of the two hosts. Paolo > So yes, i also like this patchset, but would like it even more > if it fixed the case above as well (and not sure whether adding > the migration delta to KVMCLOCK makes it harder to fix TSC case > later). _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel