Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp591152pxa; Fri, 21 Aug 2020 15:34:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7y3BwALAHXjoBXsu78ssfv5TOCqJXCmbfQLOZCwvIrMXOru6diSrJeUyF71N3Wx/rZkbp X-Received: by 2002:a17:906:f24c:: with SMTP id gy12mr4831109ejb.275.1598049244070; Fri, 21 Aug 2020 15:34:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598049244; cv=none; d=google.com; s=arc-20160816; b=sgThYFC8P2aHfpQhi2YxWCud3L/2ZaUjoM6Wo83YS4oIs36SHXltSRLYnsq5GV8Yls WBs2B/6LdIkPQXuTyF18OyPQrbGqSbqUO+tGvzKHQJm1ZvY5EkKx4wVh2PPayEROiLdo h4Zo+Wd+MCHA+TacN7qVMr/fDFbQic57t+ADN2T/H54r6vPutXMTI6F3O4aFFV0rVu+b Jm369FxSSmC3tZydkLyLg4yuNqurVxXQr24Hz70ptBfK/xINjd8jOC+qFLl3LxDOXZJg DQCkn8sR/EqSGQrsearCT6N8HCx8TuQ2LaNKNeFBQVRqEv6bt/G25cVLfvTuTEfpQTXs f0sw== 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:message-id:subject:to :from:date:dkim-signature; bh=8mKR6nGsN4/J6yUPoHqgy6Vb/KbDSfcnRfNiku5bjZI=; b=fxU0dOi320D7ai+rTdJSGREpix+lHXnaZT7phO8SC1I72HPUp3GReR/lw2cmnvZQCs Od+vhsDow7cz5nAERfP1VjHFs8bLhdolfWiua0dgB0LWSSEdYjVMgoHdC74tYq2nIoEO 0kIaibJ65k2LU5snIQnSi+pZg6RrpMaYeubbGv9hdSB6zA9qmtJBBAk44SwjnivM+ZNA 8Ro5wnc21u16ZMXUKbY4DHBRJVGOYP2e+UbG4+hANiMbYUx2fKzPyyUegeGxvvYjWyQh AHyequVo5KIdaJnTTQG6iw1uuJJ+l05W95srapemtJHVj/vHr9Jrp/IAN+6g822I9dc5 7yBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=RgsIr8Z7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k24si2199314eds.441.2020.08.21.15.33.41; Fri, 21 Aug 2020 15:34:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=RgsIr8Z7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727836AbgHUWa7 (ORCPT + 99 others); Fri, 21 Aug 2020 18:30:59 -0400 Received: from smtp-fw-4101.amazon.com ([72.21.198.25]:12254 "EHLO smtp-fw-4101.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726747AbgHUWa5 (ORCPT ); Fri, 21 Aug 2020 18:30:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1598049057; x=1629585057; h=date:from:to:subject:message-id:references:mime-version: in-reply-to; bh=8mKR6nGsN4/J6yUPoHqgy6Vb/KbDSfcnRfNiku5bjZI=; b=RgsIr8Z7VXg/2KiGmru6OI2t0IpbT+jjoTnyR+KBB1255FwjNnNT5zSG LTwZRsFZd5c/zrYvE/mDlVNPKXZsu119muuZfuZ0zZOpcR5B/cwpZMYHF IQ7GrE3nZUGkSB8JSkg3PWKM5pbiZMUhjnGB8Qv6N6pS5UvmHuhmuELLe E=; X-IronPort-AV: E=Sophos;i="5.76,338,1592870400"; d="scan'208";a="49403856" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1a-af6a10df.us-east-1.amazon.com) ([10.43.8.6]) by smtp-border-fw-out-4101.iad4.amazon.com with ESMTP; 21 Aug 2020 22:30:56 +0000 Received: from EX13MTAUEE002.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1a-af6a10df.us-east-1.amazon.com (Postfix) with ESMTPS id 51046A22AF; Fri, 21 Aug 2020 22:30:48 +0000 (UTC) Received: from EX13D08UEE002.ant.amazon.com (10.43.62.92) by EX13MTAUEE002.ant.amazon.com (10.43.62.24) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 21 Aug 2020 22:30:29 +0000 Received: from EX13MTAUEE002.ant.amazon.com (10.43.62.24) by EX13D08UEE002.ant.amazon.com (10.43.62.92) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 21 Aug 2020 22:30:29 +0000 Received: from dev-dsk-anchalag-2a-9c2d1d96.us-west-2.amazon.com (172.22.96.68) by mail-relay.amazon.com (10.43.62.224) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 21 Aug 2020 22:30:29 +0000 Received: by dev-dsk-anchalag-2a-9c2d1d96.us-west-2.amazon.com (Postfix, from userid 4335130) id 1520540362; Fri, 21 Aug 2020 22:30:29 +0000 (UTC) Date: Fri, 21 Aug 2020 22:30:29 +0000 From: Anchal Agarwal To: , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v3 10/11] xen: Update sched clock offset to avoid system instability in hibernation Message-ID: <238e837b8d4e17925801c4e85de17bdfca4ddd00.1598042152.git.anchalag@amazon.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Save/restore xen_sched_clock_offset in syscore suspend/resume during PM hibernation. Commit '867cefb4cb1012: ("xen: Fix x86 sched_clock() interface for xen")' fixes xen guest time handling during migration. A similar issue is seen during PM hibernation when system runs CPU intensive workload. Post resume pvclock resets the value to 0 however, xen sched_clock_offset is never updated. System instability is seen during resume from hibernation when system is under heavy CPU load. Since xen_sched_clock_offset is not updated, system does not see the monotonic clock value and the scheduler would then think that heavy CPU hog tasks need more time in CPU, causing the system to freeze Signed-off-by: Anchal Agarwal --- arch/x86/xen/suspend.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/arch/x86/xen/suspend.c b/arch/x86/xen/suspend.c index b12db6966af6..a62e08a11681 100644 --- a/arch/x86/xen/suspend.c +++ b/arch/x86/xen/suspend.c @@ -98,8 +98,9 @@ static int xen_syscore_suspend(void) return 0; gnttab_suspend(); - xen_manage_runstate_time(-1); + xen_save_sched_clock_offset(); + xrfp.domid = DOMID_SELF; xrfp.gpfn = __pa(HYPERVISOR_shared_info) >> PAGE_SHIFT; @@ -120,6 +121,12 @@ static void xen_syscore_resume(void) xen_hvm_map_shared_info(); pvclock_resume(); + + /* + * Restore xen_sched_clock_offset during resume to maintain + * monotonic clock value + */ + xen_restore_sched_clock_offset(); xen_manage_runstate_time(0); gnttab_resume(); } -- 2.16.6