Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1119396imu; Fri, 25 Jan 2019 18:15:40 -0800 (PST) X-Google-Smtp-Source: ALg8bN6NudWYEEi6SiFySfEQCQ4OicIKGX2DQKjLXKlJCFlYmj9d/DBagyfEKMyEpalJojVtQEIu X-Received: by 2002:a17:902:2f03:: with SMTP id s3mr13152039plb.277.1548468940063; Fri, 25 Jan 2019 18:15:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548468940; cv=none; d=google.com; s=arc-20160816; b=B3oRwcOKz9XBy3BjyKHb0r7DOoT5YN3gZjgOle6if+mWH4cCvAckfirHXsIXGMxO3D TXiRrGz65LXzgy8R/QLYr+MylWJC9rRgzid5p4oQSiYAcgd+BLHo5m5Dit/pf+7OxK0z ZP+TYBysjqWSY6m+RXPEsnvJ5qfWps8U6IvoQyXdNFXjpx+EVt45QcmqiBaUKtnbMuCi zCz51KHoM8eq8kWEqg0M04Btkscr6h108TMHX+Zr5cIgUnppEisYyIgwQROzxSLWJtZZ KImVDfw6wb/DbdNyNLefeJrJNY5n/sr5xqn6xGWG3H0a214FqXTZXak5M2aSYNtjIPBF 6p6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date; bh=RuGM3+caJl3hCP2bcPEL5dTic/dD1xNRkgQtuljwe4A=; b=NaeX9juFr+lIKnjkeuJ8qQj6PuXuLqEfIYdAQHus6vKjYvE5/ohAs3FntVFX2uolSK Ib4AiBUMgO2UaeF2+O1OEzKSO3iSSFYZLq8kOdM3mePLwUDNQLDBA2E/uHMlaX9qyUbN GveOZ1q3gbBBJsHCjvx+DSln5cnAPsuKxWjXgZjJLHurK2dDQNx8dZ+s8I3R7mKfRM82 fFLiRGn+6VbpT4VDrwOnt/pxLXXV2bIPjIyy1OYQ+EEla+elEKxwwejhd/q/ALVXcNZ+ 2O01YhyTr15n3YFHfZz1btJkd6vXX32/HypV29M/l1JLsjIM0n9rjw93NirK2usAXY1m HqpA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y18si25068529plp.269.2019.01.25.18.15.24; Fri, 25 Jan 2019 18:15:40 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729505AbfAZCOF (ORCPT + 99 others); Fri, 25 Jan 2019 21:14:05 -0500 Received: from pinero.vault24.org ([69.164.212.126]:38228 "EHLO pinero.vault24.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725550AbfAZCOF (ORCPT ); Fri, 25 Jan 2019 21:14:05 -0500 X-Greylist: delayed 590 seconds by postgrey-1.27 at vger.kernel.org; Fri, 25 Jan 2019 21:14:03 EST Received: from feynman.vault24.org (c-98-243-50-21.hsd1.mi.comcast.net [98.243.50.21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by pinero.vault24.org (Postfix) with ESMTPS id 68348603D; Fri, 25 Jan 2019 21:04:12 -0500 (EST) Received: by feynman.vault24.org (Postfix, from userid 1000) id 1FCCB3020AE7; Fri, 25 Jan 2019 21:04:10 -0500 (EST) Date: Fri, 25 Jan 2019 21:04:10 -0500 From: Jon DeVree To: Pavel Tatashin Cc: Dominique Martinet , Salvatore Bonaccorso , Steven Sistare , Pavel Tatashin , Daniel Jordan , linux@armlinux.org.uk, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com, John Stultz , sboyd@codeaurora.org, x86@kernel.org, LKML , mingo@redhat.com, Thomas Gleixner , hpa@zytor.com, douly.fnst@cn.fujitsu.com, Peter Zijlstra , prarit@redhat.com, feng.tang@intel.com, Petr Mladek , gnomes@lxorguk.ukuu.org.uk, linux-s390@vger.kernel.org, boris.ostrovsky@oracle.com, jgross@suse.com, pbonzini@redhat.com, virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, qemu-devel@nongnu.org Subject: Re: [PATCH v15 23/26] sched: early boot clock Message-ID: <20190126020410.GB3796@feynman.vault24.org> Mail-Followup-To: Pavel Tatashin , Dominique Martinet , Salvatore Bonaccorso , Steven Sistare , Pavel Tatashin , Daniel Jordan , linux@armlinux.org.uk, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com, John Stultz , sboyd@codeaurora.org, x86@kernel.org, LKML , mingo@redhat.com, Thomas Gleixner , hpa@zytor.com, douly.fnst@cn.fujitsu.com, Peter Zijlstra , prarit@redhat.com, feng.tang@intel.com, Petr Mladek , gnomes@lxorguk.ukuu.org.uk, linux-s390@vger.kernel.org, boris.ostrovsky@oracle.com, jgross@suse.com, pbonzini@redhat.com, virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, qemu-devel@nongnu.org References: <20180719205545.16512-1-pasha.tatashin@oracle.com> <20180719205545.16512-24-pasha.tatashin@oracle.com> <20181106054212.GA31768@nautica> <95c3920e-bf80-0c7e-7854-01a1c3189c23@oracle.com> <20190102202032.GA1034@eldamar.local> <20190103234339.GA17457@nautica> <20190107234839.GA15269@nautica> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 07, 2019 at 20:04:41 -0500, Pavel Tatashin wrote: > I did exactly the same sequence on Kaby Lake CPU and could not > reproduce it. What is your host CPU? > I have some machines which display this bug and others that don't, so I was able to figure out the difference between their configurations. TL;DR the bug appears to be based on wther or not /sys/devices/system/clocksource/clocksource0/current_clocksource is set to TSC in the hypervisor This is the log from a machine with the bug: [ 0.000000] Hypervisor detected: KVM [ 0.000000] kvm-clock: Using msrs 12 and 11 [1162908.013830] kvm-clock: cpu 0, msr 3e0fea001, primary cpu clock [1162908.013830] clocksource: kvm-clock: mask: 0xffffffffffffffff max_cycles: 0x1cd42e4dffb, max_idle_ns: 881590591483 ns [1162908.013834] tsc: Detected 1899.888 MHz processor This is the log from a machine without the bug: [ 0.000000] Hypervisor detected: KVM [ 0.000000] kvm-clock: Using msrs 4b564d01 and 4b564d00 [ 0.000000] kvm-clock: cpu 0, msr 149fea001, primary cpu clock [ 0.000000] kvm-clock: using sched offset of 1558436482528906 cycles [ 0.000002] clocksource: kvm-clock: mask: 0xffffffffffffffff max_cycles: 0x1cd42e4dffb, max_idle_ns: 881590591483 ns [ 0.000004] tsc: Detected 2097.570 MHz processor Note the additional line of output on the machine without the bug: [ 0.000000] kvm-clock: using sched offset of 1558436482528906 cycles This is printed from kvm_sched_clock_init() in arch/x86/kernel/kvmclock.c based on whether or not the clock is stable. For the clock to be stable both KVM_FEATURE_CLOCKSOURCE_STABLE_BIT and PVCLOCK_TSC_STABLE_BIT have to be set. Both of these are controlled by the hypervisor kernel. * KVM_FEATURE_CLOCKSOURCE_STABLE_BIT is always set by the hypervisor starting with Linux v2.6.35 - 371bcf646d17 ("KVM: x86: Tell the guest we'll warn it about tsc stability") * PVCLOCK_TSC_STABLE_BIT is set starting in Linux v3.8 but only if the clocksource is the TSC - d828199e8444 ("KVM: x86: implement PVCLOCK_TSC_STABLE_BIT pvclock flag") I changed the clocksource of a hypervisor that wasn't having issues from TSC to HPET and when I started up a guest VM the bug suddenly appeared. I shut down the guest, set the hypervisor's clocksource back to TSC, started up the guest and the bug went away again. You don't actually have to reboot the guest before the bug is visible either, just letting the guest sit at the GRUB menu for a minute or two before loading Linux is enough to make the bug plainly visible in the printk timestamps. I don't know enough to actually fix the bug, but hopefully this is enough to allow everyone else to reproduce it and come up with a fix. -- Jon X(7): A program for managing terminal windows. See also screen(1) and tmux(1).