Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6249524imu; Mon, 21 Jan 2019 05:50:22 -0800 (PST) X-Google-Smtp-Source: ALg8bN6l4/JUAW2IMk5bOYEHJy/aaf7Ww0GmxWRQFYMdongkka7VjgESZhwSvu6fZaRTpHSfOBz0 X-Received: by 2002:a17:902:8d95:: with SMTP id v21mr30272889plo.162.1548078621956; Mon, 21 Jan 2019 05:50:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548078621; cv=none; d=google.com; s=arc-20160816; b=Q8QY9MKMQsJ8ocazhEOTFd0spZQNE55nKIIb8J63Flg6jWYzTx90Iie1G1LS5y7syj eklD3dwoO3y2s8eCugHrkSHxMkKXLI2iGPunoZSkoJX8ViYyvmU717nguHjLOvGvRmuC dcz7S0l5U9EY5RSQYoL2yL89K49VAhyZLLemXKx4zChEMMHSCXexlPeiUCLsdvK2C+Zy oQDDcLB+ntaU7eYgaowVTViheqqtZGNyUrD+fzgtZq9SUhoPIFEo4bnf4WiOCcT7c19n fovbnHRIpZrpkQp8QdlPduK3VIglHOqBJL64pZA/TVBIJGB7p64LmePNGUIP4BGZlCL5 DF9w== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qSO+V7sQFvjgdNYQ3i0UM2GHCA184OvQROGuGplE09I=; b=SZ0qdVTPQIQkApu9wqVU8pJGXpFN2KkF6lIHv9/OdXtdH25Jefrtzs8Uh4KTeLdP8r yYhrEfVbkqaDCW0dk7KTSztCS11+tu6LOjhu0R4div9yoPWY2atBdpWXHfeV3P1Ws4/A VsNGUo0kRHPcgA16bnq3s1oZLYeIxTps5MtANtQh6y9aiiGUr/jHQ+NNm4ZVjWrQ3o07 tU2plkdrZY6M8gId5tUbaxSDyr5GMLv8sh6GQafoRDnyWlLpBX/2gT1ITafjRM7JeOwO FEwOtexYr4MOzGReMMQXzCVO0sXMWeOGw+H0Wns5ehUA95jKB1ZIU0tLoOunKIHIWtS0 dD9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=igIlAYSV; 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 j11si12840310pgk.265.2019.01.21.05.50.06; Mon, 21 Jan 2019 05:50:21 -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; dkim=pass header.i=@kernel.org header.s=default header.b=igIlAYSV; 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 S1729039AbfAUNrs (ORCPT + 99 others); Mon, 21 Jan 2019 08:47:48 -0500 Received: from mail.kernel.org ([198.145.29.99]:57236 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729697AbfAUNrp (ORCPT ); Mon, 21 Jan 2019 08:47:45 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 131AA20870; Mon, 21 Jan 2019 13:47:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548078464; bh=m3DmqvcSVW8Ns5sr4RRm199ebn5NmiDtHWAoldosmKw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=igIlAYSVybrjVvTgElOV8W+eMat+zj7w6TURxAwwVycheu2k8EijNnu1RuZqhMLZC bHM5ClZ68fyUmqoYMEzLIRstknI0Iq7zdix0B8X0bf11qMynfTWfr8MkPeCGcY1oz2 9Bxmhe4d5XKiR6OzjK2XSmxBjnrxxZzB8+OUzy3M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hans van Kranenburg , Juergen Gross , Boris Ostrovsky Subject: [PATCH 4.20 040/111] xen: Fix x86 sched_clock() interface for xen Date: Mon, 21 Jan 2019 14:42:34 +0100 Message-Id: <20190121122500.230638876@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190121122455.819406896@linuxfoundation.org> References: <20190121122455.819406896@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ From: Juergen Gross commit 867cefb4cb1012f42cada1c7d1f35ac8dd276071 upstream. 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 Fix that by setting xen_sched_clock_offset at resume time to ensure a monotonic clock value. [boris: replaced pr_info() with pr_info_once() in xen_callback_vector() to avoid printing with incorrect timestamp during resume (as we haven't re-adjusted the clock yet)] 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 Tested-by: Hans van Kranenburg Signed-off-by: Boris Ostrovsky Signed-off-by: Greg Kroah-Hartman --- arch/x86/xen/time.c | 12 +++++++++--- drivers/xen/events/events_base.c | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) --- a/arch/x86/xen/time.c +++ b/arch/x86/xen/time.c @@ -361,8 +361,6 @@ void xen_timer_resume(void) { int cpu; - pvclock_resume(); - if (xen_clockevent != &xen_vcpuop_clockevent) return; @@ -379,12 +377,15 @@ static const struct pv_time_ops xen_time }; static struct pvclock_vsyscall_time_info *xen_clock __read_mostly; +static u64 xen_clock_value_saved; void xen_save_time_memory_area(void) { struct vcpu_register_time_memory_area t; int ret; + xen_clock_value_saved = xen_clocksource_read() - xen_sched_clock_offset; + if (!xen_clock) return; @@ -404,7 +405,7 @@ void xen_restore_time_memory_area(void) int ret; if (!xen_clock) - return; + goto out; t.addr.v = &xen_clock->pvti; @@ -421,6 +422,11 @@ void xen_restore_time_memory_area(void) if (ret != 0) pr_notice("Cannot restore secondary vcpu_time_info (err %d)", ret); + +out: + /* Need pvclock_resume() before using xen_clocksource_read(). */ + pvclock_resume(); + xen_sched_clock_offset = xen_clocksource_read() - xen_clock_value_saved; } static void xen_setup_vsyscall_time_info(void) --- a/drivers/xen/events/events_base.c +++ b/drivers/xen/events/events_base.c @@ -1650,7 +1650,7 @@ void xen_callback_vector(void) xen_have_vector_callback = 0; return; } - pr_info("Xen HVM callback vector for event delivery is enabled\n"); + pr_info_once("Xen HVM callback vector for event delivery is enabled\n"); alloc_intr_gate(HYPERVISOR_CALLBACK_VECTOR, xen_hvm_callback_vector); }