From patchwork Thu Jul 2 18:22:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anchal Agarwal X-Patchwork-Id: 1321866 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amazon.com header.i=@amazon.com header.a=rsa-sha256 header.s=amazon201209 header.b=c7fmKlSS; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 49yRLR3lwXz9sSJ for ; Fri, 3 Jul 2020 04:23:43 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728247AbgGBSXb (ORCPT ); Thu, 2 Jul 2020 14:23:31 -0400 Received: from smtp-fw-6002.amazon.com ([52.95.49.90]:38543 "EHLO smtp-fw-6002.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728148AbgGBSXY (ORCPT ); Thu, 2 Jul 2020 14:23:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1593714204; x=1625250204; h=date:from:to:subject:message-id:references:mime-version: in-reply-to; bh=I7turOllMrL/CNEMBFGxOPTAV9RKwwcOD5Qzsp0RMCI=; b=c7fmKlSS9D6/IpT70PI5fH9mttjKMj5kvfM9pbdiE05xxjXwgnLe847s +vjzfqCLbXAwpMN9LnXKImKE5DG6XVgYNmdgsn5DvvPKGcUM/kIDFvp9r kknU0wIyk2LNukqQ9w0I+YFgMrW5O5TEQH2VjwpiHqPVuYdcBIutRKMO/ c=; IronPort-SDR: gtZOu0dMiB3ehEJQSAxthJy8slH3FlYoulPxQjoZIUWyHzAH9qA9TfOTryU3wg6sLJrulv+kzq yxHeXV2LgO7A== X-IronPort-AV: E=Sophos;i="5.75,305,1589241600"; d="scan'208";a="39736466" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-2c-4e7c8266.us-west-2.amazon.com) ([10.43.8.6]) by smtp-border-fw-out-6002.iad6.amazon.com with ESMTP; 02 Jul 2020 18:23:16 +0000 Received: from EX13MTAUEE002.ant.amazon.com (pdx4-ws-svc-p6-lb7-vlan2.pdx.amazon.com [10.170.41.162]) by email-inbound-relay-2c-4e7c8266.us-west-2.amazon.com (Postfix) with ESMTPS id A0D51A2540; Thu, 2 Jul 2020 18:23:14 +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; Thu, 2 Jul 2020 18:22:51 +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; Thu, 2 Jul 2020 18:22:51 +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; Thu, 2 Jul 2020 18:22:51 +0000 Received: by dev-dsk-anchalag-2a-9c2d1d96.us-west-2.amazon.com (Postfix, from userid 4335130) id 651F840844; Thu, 2 Jul 2020 18:22:51 +0000 (UTC) Date: Thu, 2 Jul 2020 18:22:51 +0000 From: Anchal Agarwal To: , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v2 08/11] x86/xen: save and restore steal clock during PM hibernation Message-ID: <20200702182251.GA3606@dev-dsk-anchalag-2a-9c2d1d96.us-west-2.amazon.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Save/restore steal times in syscore suspend/resume during PM hibernation. Commit '5e25f5db6abb9: ("xen/time: do not decrease steal time after live migration on xen")' fixes xen guest steal time handling during migration. A similar issue is seen during PM hibernation. Currently, steal time accounting code in scheduler expects steal clock callback to provide monotonically increasing value. If the accounting code receives a smaller value than previous one, it uses a negative value to calculate steal time and results in incorrectly updated idle and steal time accounting. This breaks userspace tools which read /proc/stat. top - 08:05:35 up 2:12, 3 users, load average: 0.00, 0.07, 0.23 Tasks: 80 total, 1 running, 79 sleeping, 0 stopped, 0 zombie Cpu(s): 0.0%us, 0.0%sy, 0.0%ni,30100.0%id, 0.0%wa, 0.0%hi, 0.0%si,-1253874204672.0%st This can actually happen when a Xen PVHVM guest gets restored from hibernation, because such a restored guest is just a fresh domain from Xen perspective and the time information in runstate info starts over from scratch. Changelog: v1->v2: Removed patches that introduced new function calls for saving/restoring sched clock offset and using existing ones that are used during LM Signed-off-by: Anchal Agarwal --- arch/x86/xen/suspend.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/arch/x86/xen/suspend.c b/arch/x86/xen/suspend.c index e8c924e93fc5..10cd14326472 100644 --- a/arch/x86/xen/suspend.c +++ b/arch/x86/xen/suspend.c @@ -94,10 +94,9 @@ static int xen_syscore_suspend(void) int ret; gnttab_suspend(); - + xen_manage_runstate_time(-1); xrfp.domid = DOMID_SELF; xrfp.gpfn = __pa(HYPERVISOR_shared_info) >> PAGE_SHIFT; - ret = HYPERVISOR_memory_op(XENMEM_remove_from_physmap, &xrfp); if (!ret) HYPERVISOR_shared_info = &xen_dummy_shared_info; @@ -111,7 +110,7 @@ static void xen_syscore_resume(void) xen_hvm_map_shared_info(); pvclock_resume(); - + xen_manage_runstate_time(0); gnttab_resume(); }