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

[PATCH 02/19] watchdog: Introduce a separate struct for watchdog timers


  • 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=ZmVWcxM9/DbUaCNEQfmMZgnERngyZjpgdvYuQaC2TtU=; b=m2lPa8IU3n6ZJtdmeYb2f9oqGHwA2nySshTvUbSWRIodJ2PXylYcHGZlIg5QxWqEkRKyUcTkaLrencPPRMpuUiF9GFp7QqzSu6+nwIdlaiS7iD+6gFhS15CnjRoGVxRg/obP57/D1HBwN/G8TWEQBFwPLqGvDuN2vPBigeTY0V0ZMnaAEsXAP9cMK8U5sg40Zm5R77GXXDXilnebBIiROyapn3bbMtiAM6DuN71PgoADbcJGfqKlbtOdHdjzROWoFe8iA5an5yHeZq8gEcCDUMLazYKs76XLxh1JhIpz7xAdkVF6h3ZaGRc+u277E3YyTP8QHm7H6ijze0VkY1LfjQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KMC7JkhV+J/9z/lC7lqhRk023/VvOJ5u+PKGwAbAFLa+MDm9izEvqvTxPW3rfNya6xmAFh6X0JSeLEr6CYjzJD/p/8vKIDHpbDuX29k2NcxVVPoga/ip0N3vQWX+sNkeTPxmgphs7z1J4on6UFaCCROXQdSo6/NARiHX6vXIsMp2KbFc3KeGfK9vbNN7V46u8StXF1RYRnCC+n8g2y3dKG2ASfcWt8zX4jk0bkzh6JGG3CYdRQyQn/MkVZPXwnsVxRBCBCf2RhJhaTMNZhImXWKMhqP22uFi1Qn+L41tpNwH/R2v4jOi0ohkqzYg9hRVDGnMvd6s47NQTGJ7QJwprQ==
  • Cc: Mykyta Poturai <Mykyta_Poturai@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Dario Faggioli <dfaggioli@xxxxxxxx>
  • Delivery-date: Fri, 07 Oct 2022 10:33:03 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHY2jgj6wETIb7ouE6AlSobgU5oww==
  • Thread-topic: [PATCH 02/19] watchdog: Introduce a separate struct for watchdog timers

This change is needed to properly implement the suspend/resume actions
for the watchdog timers. To be able to restart watchdog timer after
suspend we need to remember their frequency somewhere. To not bloat the
struct timer a new struct watchdog_timer is introduced, containing the
original timer and the last set timeout.

Signed-off-by: Mykyta Poturai <mykyta_poturai@xxxxxxxx>
---
 xen/common/keyhandler.c    |  2 +-
 xen/common/sched/core.c    | 11 ++++++-----
 xen/include/xen/sched.h    |  3 ++-
 xen/include/xen/watchdog.h |  6 ++++++
 4 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/xen/common/keyhandler.c b/xen/common/keyhandler.c
index 8b9f378371..e9bd48fa5b 100644
--- a/xen/common/keyhandler.c
+++ b/xen/common/keyhandler.c
@@ -289,7 +289,7 @@ static void dump_domains(unsigned char key)
         for ( i = 0 ; i < NR_DOMAIN_WATCHDOG_TIMERS; i++ )
             if ( test_bit(i, &d->watchdog_inuse_map) )
                 printk("    watchdog %d expires in %d seconds\n",
-                       i, (u32)((d->watchdog_timer[i].expires - NOW()) >> 30));
+                       i, (u32)((d->watchdog_timer[i].timer.expires - NOW()) 
>> 30));
 
         arch_dump_domain_info(d);
 
diff --git a/xen/common/sched/core.c b/xen/common/sched/core.c
index 4e1ea62c44..0ecb41cfe1 100644
--- a/xen/common/sched/core.c
+++ b/xen/common/sched/core.c
@@ -1567,7 +1567,8 @@ static long domain_watchdog(struct domain *d, uint32_t 
id, uint32_t timeout)
         {
             if ( test_and_set_bit(id, &d->watchdog_inuse_map) )
                 continue;
-            set_timer(&d->watchdog_timer[id], NOW() + SECONDS(timeout));
+            d->watchdog_timer[id].timeout = timeout;
+            set_timer(&d->watchdog_timer[id].timer, NOW() + SECONDS(timeout));
             break;
         }
         spin_unlock(&d->watchdog_lock);
@@ -1583,12 +1584,12 @@ static long domain_watchdog(struct domain *d, uint32_t 
id, uint32_t timeout)
 
     if ( timeout == 0 )
     {
-        stop_timer(&d->watchdog_timer[id]);
+        stop_timer(&d->watchdog_timer[id].timer);
         clear_bit(id, &d->watchdog_inuse_map);
     }
     else
     {
-        set_timer(&d->watchdog_timer[id], NOW() + SECONDS(timeout));
+        set_timer(&d->watchdog_timer[id].timer, NOW() + SECONDS(timeout));
     }
 
     spin_unlock(&d->watchdog_lock);
@@ -1604,7 +1605,7 @@ void watchdog_domain_init(struct domain *d)
     d->watchdog_inuse_map = 0;
 
     for ( i = 0; i < NR_DOMAIN_WATCHDOG_TIMERS; i++ )
-        init_timer(&d->watchdog_timer[i], domain_watchdog_timeout, d, 0);
+        init_timer(&d->watchdog_timer[i].timer, domain_watchdog_timeout, d, 0);
 }
 
 void watchdog_domain_destroy(struct domain *d)
@@ -1612,7 +1613,7 @@ void watchdog_domain_destroy(struct domain *d)
     unsigned int i;
 
     for ( i = 0; i < NR_DOMAIN_WATCHDOG_TIMERS; i++ )
-        kill_timer(&d->watchdog_timer[i]);
+        kill_timer(&d->watchdog_timer[i].timer);
 }
 
 /*
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index b2f6d1af28..7a4aef4c17 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -24,6 +24,7 @@
 #include <asm/atomic.h>
 #include <xen/vpci.h>
 #include <xen/wait.h>
+#include <xen/watchdog.h>
 #include <public/xen.h>
 #include <public/domctl.h>
 #include <public/sysctl.h>
@@ -517,7 +518,7 @@ struct domain
 #define NR_DOMAIN_WATCHDOG_TIMERS 2
     spinlock_t watchdog_lock;
     uint32_t watchdog_inuse_map;
-    struct timer watchdog_timer[NR_DOMAIN_WATCHDOG_TIMERS];
+    struct watchdog_timer watchdog_timer[NR_DOMAIN_WATCHDOG_TIMERS];
 
     struct rcu_head rcu;
 
diff --git a/xen/include/xen/watchdog.h b/xen/include/xen/watchdog.h
index 86fde0884a..3398dcba37 100644
--- a/xen/include/xen/watchdog.h
+++ b/xen/include/xen/watchdog.h
@@ -8,6 +8,12 @@
 #define __XEN_WATCHDOG_H__
 
 #include <xen/types.h>
+#include <xen/timer.h>
+
+struct watchdog_timer {
+    struct timer timer;
+    uint32_t timeout;
+};
 
 #ifdef CONFIG_WATCHDOG
 
-- 
2.37.1



 


Rackspace

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