Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2115007imu; Thu, 10 Jan 2019 08:31:10 -0800 (PST) X-Google-Smtp-Source: ALg8bN52D7satvUpwYwVnzREgfT8smUd8oNsyfUUdEL5snhQBQ0FRyHnIoMsaX2WinV4xlMnAfgi X-Received: by 2002:a17:902:4624:: with SMTP id o33mr10744635pld.289.1547137870516; Thu, 10 Jan 2019 08:31:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547137870; cv=none; d=google.com; s=arc-20160816; b=NdDVwU2mgEX8ToCVbPInSE7AutukdI8HQQD7um/J6/JMTygscQvM9hq6VWOlvDhjuZ 4ocEIB7QxUYNTM/NfMuAquGXu2+WcyYoTpv4d3VRailqKDAv3BVwTSarQZfaWkeuY2qh Zoks4B4Nph5bOlMKYNoK0IrRfq5Wcm4lrn/ls5LUF02vZSvUfFzSNmbRQem4bLnAVdPm vMKVv15cHBMhk4J6bPO/W4rXkaI1qWR1zLcM/1bLy406b+oZIqmEyjKWaIFUjt5/0owW XKJ2vvFn1K1I36MTKAZu90YXr/drucvdTIdbDOKODP0BcZiwf+f1GH+xvaZUG1pT967P UDkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:cc:to:subject; bh=SUg4jtzPH2Bn+YfGVs/LQXsUyvU4Sbn/+K8wv3cnBKE=; b=yc+bAcRPQ16kaxvqqNXJZ+uwi4O5gPo00qSejPc3MWQsSpUjqJW1QMvPfgbVKEOaF5 eIsETs9bv3bMuZSAzdRn86Ls0PnczHjcDpxf9G8jFtxt5vf9ixVVhp3CDPJQvNo8mhCe 3Tiv992zzkafScqs4Cjb3X2jHgDOFQOy6sBjwieVONnCHnu+b5xqVrM8GVOh1JdOhmOm 95JjNtp1Xofikq50Qtz/p76KJNM9WWU9YJ5yZl2c7CO/tRee+cbsCGKQb/7oMerfpA4P PojPLppiZGQXZeajpFvDN6EMVQHzNGUTHeUfPRqnOTLf3XCIcntiDB3Gj0g+pCV3jsdI ukWg== 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 az5si51195102plb.166.2019.01.10.08.30.55; Thu, 10 Jan 2019 08:31:10 -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 S1728131AbfAJQ3f (ORCPT + 99 others); Thu, 10 Jan 2019 11:29:35 -0500 Received: from syrinx.knorrie.org ([82.94.188.77]:45982 "EHLO syrinx.knorrie.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726242AbfAJQ3e (ORCPT ); Thu, 10 Jan 2019 11:29:34 -0500 X-Greylist: delayed 587 seconds by postgrey-1.27 at vger.kernel.org; Thu, 10 Jan 2019 11:29:33 EST Received: from [10.200.4.80] (unknown [85.146.242.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by syrinx.knorrie.org (Postfix) with ESMTPSA id A355434825C30; Thu, 10 Jan 2019 17:19:45 +0100 (CET) Subject: Re: [PATCH] xen: Fix x86 sched_clock() interface for xen To: Juergen Gross , linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, x86@kernel.org Cc: boris.ostrovsky@oracle.com, sstabellini@kernel.org, hpa@zytor.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, stable@vger.kernel.org References: <20190110100722.11216-1-jgross@suse.com> From: Hans van Kranenburg Openpgp: preference=signencrypt Autocrypt: addr=hans@knorrie.org; prefer-encrypt=mutual; keydata= mQINBFo2pooBEADwTBe/lrCa78zuhVkmpvuN+pXPWHkYs0LuAgJrOsOKhxLkYXn6Pn7e3xm+ ySfxwtFmqLUMPWujQYF0r5C6DteypL7XvkPP+FPVlQnDIifyEoKq8JZRPsAFt1S87QThYPC3 mjfluLUKVBP21H3ZFUGjcf+hnJSN9d9MuSQmAvtJiLbRTo5DTZZvO/SuQlmafaEQteaOswme DKRcIYj7+FokaW9n90P8agvPZJn50MCKy1D2QZwvw0g2ZMR8yUdtsX6fHTe7Ym+tHIYM3Tsg 2KKgt17NTxIqyttcAIaVRs4+dnQ23J98iFmVHyT+X2Jou+KpHuULES8562QltmkchA7YxZpT mLMZ6TPit+sIocvxFE5dGiT1FMpjM5mOVCNOP+KOup/N7jobCG15haKWtu9k0kPz+trT3NOn gZXecYzBmasSJro60O4bwBayG9ILHNn+v/ZLg/jv33X2MV7oYXf+ustwjXnYUqVmjZkdI/pt 30lcNUxCANvTF861OgvZUR4WoMNK4krXtodBoEImjmT385LATGFt9HnXd1rQ4QzqyMPBk84j roX5NpOzNZrNJiUxj+aUQZcINtbpmvskGpJX0RsfhOh2fxfQ39ZP/0a2C59gBQuVCH6C5qsY rc1qTIpGdPYT+J1S2rY88AvPpr2JHZbiVqeB3jIlwVSmkYeB/QARAQABtCZIYW5zIHZhbiBL cmFuZW5idXJnIDxoYW5zQGtub3JyaWUub3JnPokCTgQTAQoAOBYhBOJv1o/B6NS2GUVGTueB VzIYDCpVBQJaNq7KAhsDBQsJCAcDBRUKCQgLBRYCAwEAAh4BAheAAAoJEOeBVzIYDCpVgDMQ ANSQMebh0Rr6RNhfA+g9CKiCDMGWZvHvvq3BNo9TqAo9BC4neAoVciSmeZXIlN8xVALf6rF8 lKy8L1omocMcWw7TlvZHBr2gZHKlFYYC34R2NvxS0xO8Iw5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231-8e34-8ef7-bb9c7e2b3dbb@knorrie.org> Date: Thu, 10 Jan 2019 17:19:44 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.1 MIME-Version: 1.0 In-Reply-To: <20190110100722.11216-1-jgross@suse.com> Content-Type: text/plain; charset=utf-8 Content-Language: en_US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/10/19 11:07 AM, Juergen Gross wrote: > Commit f94c8d11699759 ("sched/clock, x86/tsc: Rework the x86 'unstable' > sched_clock() interface") broke Xen guest time handling across > migration: > > [ 187.249951] Freezing user space processes ... (elapsed 0.001 seconds) done. > [ 187.251137] OOM killer disabled. > [ 187.251137] Freezing remaining freezable tasks ... (elapsed 0.001 seconds) done. > [ 187.252299] suspending xenstore... > [ 187.266987] xen:grant_table: Grant tables using version 1 layout > [18446743811.706476] OOM killer enabled. > [18446743811.706478] Restarting tasks ... done. > [18446743811.720505] Setting capacity to 16777216 I tried this on top of 4.19.14 (together with "x86/mm: Fix guard hole handling", which still doesn't seem to be in 4.19) and I can confirm the fix: Using a PV domU, 4.19 without patch: [ 646.199018] Freezing user space processes ... (elapsed 0.002 seconds) done. [ 646.201305] OOM killer disabled. [ 646.201311] Freezing remaining freezable tasks ... (elapsed 0.001 seconds) done. [ 646.202699] suspending xenstore... [ 646.203005] xen:grant_table: Grant tables using version 1 layout [18446200797.089367] OOM killer enabled. [18446200797.089382] Restarting tasks ... done. 4.19 with patch, doing live migration movement between exactly the same set of physical servers: [ 74.878062] Freezing user space processes ... (elapsed 0.002 seconds) done. [ 74.880308] OOM killer disabled. [ 74.880314] Freezing remaining freezable tasks ... (elapsed 0.000 seconds) done. [ 74.881681] suspending xenstore... [ 74.887497] xen:grant_table: Grant tables using version 1 layout [ 74.942011] OOM killer enabled. [ 74.942025] Restarting tasks ... done. [ 74.947688] Setting capacity to 6291456 [ 74.950833] Setting capacity to 10485760 Tested-by: Hans van Kranenburg Thanks! > > Fix that by setting xen_sched_clock_offset at resume time to ensure a > monotonic clock value. > > Fixes: f94c8d11699759 ("sched/clock, x86/tsc: Rework the x86 'unstable' sched_clock() interface") > Cc: # 4.11 > Reported-by: Hans van Kranenburg > Signed-off-by: Juergen Gross > --- > arch/x86/xen/suspend.c | 4 ++++ > arch/x86/xen/time.c | 11 +++++++++++ > arch/x86/xen/xen-ops.h | 2 ++ > 3 files changed, 17 insertions(+) > > diff --git a/arch/x86/xen/suspend.c b/arch/x86/xen/suspend.c > index 1d83152c761b..45fc9caf3880 100644 > --- a/arch/x86/xen/suspend.c > +++ b/arch/x86/xen/suspend.c > @@ -67,6 +67,8 @@ void xen_arch_resume(void) > { > int cpu; > > + xen_clocksource_resume(); > + > on_each_cpu(xen_vcpu_notify_restore, NULL, 1); > > for_each_online_cpu(cpu) > @@ -81,4 +83,6 @@ void xen_arch_suspend(void) > xen_pmu_finish(cpu); > > on_each_cpu(xen_vcpu_notify_suspend, NULL, 1); > + > + xen_clocksource_suspend(); > } > diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c > index 72bf446c3fee..117ce958ffe6 100644 > --- a/arch/x86/xen/time.c > +++ b/arch/x86/xen/time.c > @@ -32,6 +32,7 @@ > #define TIMER_SLOP 100000 > > static u64 xen_sched_clock_offset __read_mostly; > +static u64 xen_clock_value_saved; > > /* Get the TSC speed from Xen */ > static unsigned long xen_tsc_khz(void) > @@ -54,6 +55,16 @@ static u64 xen_clocksource_read(void) > return ret; > } > > +void xen_clocksource_suspend(void) > +{ > + xen_clock_value_saved = xen_clocksource_read() - xen_sched_clock_offset; > +} > + > +void xen_clocksource_resume(void) > +{ > + xen_sched_clock_offset = xen_clocksource_read() - xen_clock_value_saved; > +} > + > static u64 xen_clocksource_get_cycles(struct clocksource *cs) > { > return xen_clocksource_read(); > diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h > index 0e60bd918695..a17d3bdab6b8 100644 > --- a/arch/x86/xen/xen-ops.h > +++ b/arch/x86/xen/xen-ops.h > @@ -63,6 +63,8 @@ void __init xen_build_dynamic_phys_to_machine(void); > void __init xen_vmalloc_p2m_tree(void); > > void xen_init_irq_ops(void); > +void xen_clocksource_suspend(void); > +void xen_clocksource_resume(void); > void xen_setup_timer(int cpu); > void xen_setup_runstate_info(int cpu); > void xen_teardown_timer(int cpu); >