Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1402344ybn; Wed, 25 Sep 2019 17:50:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqyNcYnMmPoLv+Yj3MiNJHMrAzDVU9mHflE/f4o0E8Fbw4ilQid6IcCxibVW2dDwFf/EXSbg X-Received: by 2002:a17:906:53c1:: with SMTP id p1mr815538ejo.227.1569459021186; Wed, 25 Sep 2019 17:50:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569459021; cv=none; d=google.com; s=arc-20160816; b=DHEcwKovljhk46PTX+HYXsOPrwUi1k6gUKJLQXL8ujNqNsQC9sYhWtTzQ3EcJo7RIP 9XdY86EBsGF2eLWo5eYgYHr7z1F2HisLPQLC0ViDFjRgHHGfyxcuaiW1foexx0uQEhW2 7tsnYRfp7RL15qvmLMQZvC0br73EoLOfDJ/Hy+OH30RsSL564PSWwjYiKz0gUPVx6mmi wkvv1w+HpJVdIfnSJnElJufRKu8+ilBB2SugRNDtJIriChY2+rYzdA8EW+GIoS5QsVxl 4dvJ0ZNeH7n4b1+OhHYaKS5wnH5qsxG1SJUJQMI8VZcEZYc433MYLQls24HAAEbnjp8/ 6CZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=bf7s21SxYMbnBeKNwTjTIeOSbHSDn1quny+f4Km2hrQ=; b=up5N9xjM94RulksCMviCXWq/rUoPkmCegQYrJdLwvcC1W47nr0UAYGzCIceXV9roZJ PpfDZOr2KYqtzWeWSZLJyfSkIiqjhDVKt70odpUIN72YEPfR6pIuWhusEU6SzhDu4w4I +8E9OkU6Bj9x3XSqoGOkOH8JWaaOgsHWFkmdbh5sOdv80EESAImG+AmA9g3CEV45XIzO 0zaHHzJi6aobVuX916pP25c9RdBv4fLdLx/2wwmJnmOhv0XFm5oNanoqOcYMU8+aJr4B SECoXWIE5AyvWDbUWWBPmFyY47IrvKMBCGrpcgT2P6ZXUylDw0ZOHPSKakh2wcOng5hz h+4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="VdDPs/1s"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c8si452211edb.82.2019.09.25.17.49.57; Wed, 25 Sep 2019 17:50:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="VdDPs/1s"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2409436AbfIXILH (ORCPT + 99 others); Tue, 24 Sep 2019 04:11:07 -0400 Received: from mail-yb1-f195.google.com ([209.85.219.195]:32770 "EHLO mail-yb1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405749AbfIXILH (ORCPT ); Tue, 24 Sep 2019 04:11:07 -0400 Received: by mail-yb1-f195.google.com with SMTP id z7so382365ybg.0 for ; Tue, 24 Sep 2019 01:11:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=bf7s21SxYMbnBeKNwTjTIeOSbHSDn1quny+f4Km2hrQ=; b=VdDPs/1sIsEkegjUIVHkkeG5PDpTz9X7KNKBX0xYqC7EmyVYJpig/q7IDxU+UXayYk zdr+gbsCdBtydnWIwKXJetwELemHgI3OhABAfGaK8WjKEHFG3s86tLK7sViG9Fn2tthy 8sBr7PuUQ2vUszuL/cuoBol2A/e59ssGzKZFuaZ2fLH4EFSIu3y2y+hYMEFijrO8YZuf k0JaDlYoouQHL1gSjmZZIsIw9j3H3utE21SdlhlSEjHW9sxMG3dxDSEdKoqu8BcCluml qfQWkGch453WluvEHTlyAa/3xElXDBqYOxL7w8Gt8BNUJyfTfeb8WqXXs+X+GdsBLkO3 K36A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=bf7s21SxYMbnBeKNwTjTIeOSbHSDn1quny+f4Km2hrQ=; b=OfBMppedr/JQlSylrgHf1/HyRDtILlq0ea2tKqvJVhElbJPnCzr4LGrKSGmWtquKQ+ 15j0LuFa/kIqK7KEgUxUAFPpMAAGbgOx1tF9pgr2bu1yWRlTl9hgwLjhbWIYKXzOJ1Q7 C+GsoTHI162oir/jtXePMi9yIKL/7TiX0rGgEDkLY28KNTmxSQqurSDL/HIAlHF75fq7 TzcHnFVbsxZH6NLOws+0aM1Bjh3XsGvoD3+V3Mo5LmXNtCFdp95ADFO5vQTNdjfLq3a3 G0Fem2nECa8Sp+O2aqIvYf/VG9LTiLPNR3/TKMn5dWH/fkH0STEBHV+51qCGbwGLHFvY EMbQ== X-Gm-Message-State: APjAAAW3x3zH17NRUc9n13lhCFHT7v9QDw/9AhvkhWFq3NFHgkF3aIGQ sXgnbVwGeWkGjgfbOw8hO5FEh54AxMdmRLs+44YXeQ== X-Received: by 2002:a5b:38c:: with SMTP id k12mr1158117ybp.320.1569312666248; Tue, 24 Sep 2019 01:11:06 -0700 (PDT) MIME-Version: 1.0 References: <20190920062713.78503-1-suleiman@google.com> <20190920062713.78503-3-suleiman@google.com> <87woe38538.fsf@vitty.brq.redhat.com> In-Reply-To: <87woe38538.fsf@vitty.brq.redhat.com> From: Suleiman Souhlal Date: Tue, 24 Sep 2019 17:10:55 +0900 Message-ID: Subject: Re: [RFC 2/2] x86/kvmclock: Use host timekeeping. To: Vitaly Kuznetsov Cc: John Stultz , sboyd@kernel.org, Linux Kernel , kvm@vger.kernel.org, Paolo Bonzini , rkrcmar@redhat.com, Thomas Gleixner , Tomasz Figa Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 20, 2019 at 10:33 PM Vitaly Kuznetsov wrote: > > Suleiman Souhlal writes: > > > When CONFIG_KVMCLOCK_HOST_TIMEKEEPING is enabled, and the host > > supports it, update our timekeeping parameters to be the same as > > the host. This lets us have our time synchronized with the host's, > > even in the presence of host NTP or suspend. > > > > When enabled, kvmclock uses raw tsc instead of pvclock. > > > > When enabled, syscalls that can change time, such as settimeofday(2) > > or adj_timex(2) are disabled in the guest. > > > > Signed-off-by: Suleiman Souhlal > > --- > > arch/x86/Kconfig | 9 +++ > > arch/x86/include/asm/kvmclock.h | 2 + > > arch/x86/kernel/kvmclock.c | 127 +++++++++++++++++++++++++++++++- > > kernel/time/timekeeping.c | 21 ++++++ > > 4 files changed, 155 insertions(+), 4 deletions(-) > > > > diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig > > index 4195f44c6a09..37299377d9d7 100644 > > --- a/arch/x86/Kconfig > > +++ b/arch/x86/Kconfig > > @@ -837,6 +837,15 @@ config PARAVIRT_TIME_ACCOUNTING > > config PARAVIRT_CLOCK > > bool > > > > +config KVMCLOCK_HOST_TIMEKEEPING > > + bool "kvmclock uses host timekeeping" > > + depends on KVM_GUEST > > + ---help--- > > + Select this option to make the guest use the same timekeeping > > + parameters as the host. This means that time will be almost > > + exactly the same between the two. Only works if the host uses "tsc" > > + clocksource. > > + > > I'd also like to speak up against this config, it is confusing. In case > the goal is to come up with a TSC-based clock for guests which will > return the same as clock_gettime() on the host (or, is the goal to just > have the same reading for all guests on the host?) I'd suggest we create > a separate (from KVMCLOCK) clocksource (mirroring host timekeeper) and > guests will be free to pick the one they like. Fair enough. I'll do that in the next version of the patch. The goal is to have a guest clock that gives the same clock_gettime(CLOCK_MONOTONIC) as the host. Thanks, -- Suleiman