[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 03/19] xen/arm: While a domain is suspended put its watchdogs on pause


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Mykyta Poturai <Mykyta_Poturai@xxxxxxxx>
  • Date: Fri, 7 Oct 2022 10:32:45 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=vI8WYCk3EkX7EbqmfQgeu3vc77XT/c/fe+8/1HjADBA=; b=YtKBkwRhMlrnY+BK4X3vUMb3jZiNVtp0xKucJ9YDIjZBaHNNJJfXbSIlHX0KqwcqIsfM6USEqyucZpsEmx2mC4XykLrXq58ecj2sF5EPyTt/TQCCyUxBoeVFHUox9EDM/VpUFmBgE2kLGQdYGoK3VhQJUHjdNEfHOCDY1VFAvtyx83r7A87BEt26IKHgXu1q0VGWTtsRiEX7ya1X8n+qywbxS/NKlitTr2mEt5N+H+vse6fm4ieSZst9o6PXSWmHXm+62FaCYkLGMcI8zzsowGYXXXdcuRKAO9KlNC3rV1onWKeFxHcOR4l3Q69GJzAxyZAExMEa3JNMuI43JqbntA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GTNT+Ai2rm8uXBBVwwRXaYKdygnQ/iTmN1JZHN3y5N5WXxZUxSItPewHCZziIIy6bAH4J1vuKhnc0JAQGlPkC0qG3pNJW6OMVhR4NsO+xdqqcF/VHWKmZbfY4dwATPB0frfEZeulmYPEZZ2KB57ftYJuXMiX1+siTvkbAXaYYqlt47/O8CiaFHVWS1g/6s5hmdCtfLkt62ywds4GtCuG3vlMauaexsTNANdc4xrc9JdangEVBb1whn4EYG0WwXZ8jlpMWliy771F/zTkTBMIdguU9JQyrURtxdyc+vF8ZWqm4gXBmZPwqhGyeiT4+MN3v1RHu8Z97QJr03BNP/zKuQ==
  • Cc: Mirela Simonovic <mirela.simonovic@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Wei Liu <wl@xxxxxxx>, Dario Faggioli <dfaggioli@xxxxxxxx>, Saeed Nowshadi <saeed.nowshadi@xxxxxxxxxx>, Mykyta Poturai <Mykyta_Poturai@xxxxxxxx>
  • Delivery-date: Fri, 07 Oct 2022 10:33:04 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHY2jgj3tJ62NzvY0CshbpyuWlDtw==
  • Thread-topic: [PATCH 03/19] xen/arm: While a domain is suspended put its watchdogs on pause

From: Mirela Simonovic <mirela.simonovic@xxxxxxxxxx>

While a domain is suspended its watchdogs must be paused. Otherwise,
if the domain stays in the suspend state for a longer period of time
compared to the watchdog period, the domain would be shutdown on resume.
Proper solution to this problem is to stop (suspend) the watchdog timers
after the domain suspends and to restart (resume) the watchdog timers
before the domain resumes. The suspend/resume of watchdog timers is done
in Xen and is invisible to the guests.
Just before the domain starts resuming the watchdog timers are programmed
with a new expire value. The new expire value is set according to the
last offset provided by the last hypercall before suspend was triggered,
effectively restarting the timer.

Signed-off-by: Mirela Simonovic <mirela.simonovic@xxxxxxxxxx>
Signed-off-by: Saeed Nowshadi <saeed.nowshadi@xxxxxxxxxx>
Signed-off-by: Mykyta Poturai <mykyta_poturai@xxxxxxxx>
---
 xen/arch/arm/suspend.c  |  4 ++++
 xen/common/sched/core.c | 36 ++++++++++++++++++++++++++++++++++++
 xen/include/xen/sched.h |  7 +++++++
 3 files changed, 47 insertions(+)

diff --git a/xen/arch/arm/suspend.c b/xen/arch/arm/suspend.c
index 987ba6ac11..d19545744f 100644
--- a/xen/arch/arm/suspend.c
+++ b/xen/arch/arm/suspend.c
@@ -128,6 +128,7 @@ void vcpu_resume(struct vcpu *v)
 
     /* Initialize VCPU registers */
     arch_set_info_guest(v, &ctxt);
+    watchdog_domain_resume(v->domain);
     clear_bit(_VPF_suspended, &v->pause_flags);
 }
 
@@ -162,6 +163,9 @@ int32_t domain_suspend(register_t epoint, register_t cid)
      */
     vcpu_suspend(epoint, cid);
 
+    /* Disable watchdogs of this domain */
+    watchdog_domain_suspend(d);
+
     /*
      * The calling domain is suspended by blocking its last running VCPU. If an
      * event is pending the domain will resume right away (VCPU will not block,
diff --git a/xen/common/sched/core.c b/xen/common/sched/core.c
index 0ecb41cfe1..ebed0ec49e 100644
--- a/xen/common/sched/core.c
+++ b/xen/common/sched/core.c
@@ -1616,6 +1616,42 @@ void watchdog_domain_destroy(struct domain *d)
         kill_timer(&d->watchdog_timer[i].timer);
 }
 
+void watchdog_domain_suspend(struct domain *d)
+{
+    unsigned int i;
+
+    spin_lock(&d->watchdog_lock);
+
+    for ( i = 0; i < NR_DOMAIN_WATCHDOG_TIMERS; i++ )
+    {
+        if ( test_bit(i, &d->watchdog_inuse_map) )
+        {
+            stop_timer(&d->watchdog_timer[i].timer);
+        }
+    }
+
+    spin_unlock(&d->watchdog_lock);
+}
+
+void watchdog_domain_resume(struct domain *d)
+{
+    unsigned int i;
+
+    spin_lock(&d->watchdog_lock);
+
+    for ( i = 0; i < NR_DOMAIN_WATCHDOG_TIMERS; i++ )
+    {
+        if ( test_bit(i, &d->watchdog_inuse_map) )
+        {
+            set_timer(&d->watchdog_timer[i].timer,
+                      NOW() + SECONDS(d->watchdog_timer[i].timeout));
+        }
+    }
+
+    spin_unlock(&d->watchdog_lock);
+}
+
+
 /*
  * Pin a vcpu temporarily to a specific CPU (or restore old pinning state if
  * cpu is NR_CPUS).
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index 7a4aef4c17..00a939aa01 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -1025,6 +1025,13 @@ void scheduler_disable(void);
 void watchdog_domain_init(struct domain *d);
 void watchdog_domain_destroy(struct domain *d);
 
+/*
+ * Suspend/resume watchdogs of domain (while the domain is suspended its
+ * watchdogs should be on pause)
+ */
+void watchdog_domain_suspend(struct domain *d);
+void watchdog_domain_resume(struct domain *d);
+
 /*
  * Use this check when the following are both true:
  *  - Using this feature or interface requires full access to the hardware
-- 
2.37.1



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.