From nobody Mon Mar 10 02:54:47 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1741165992; cv=none; d=zohomail.com; s=zohoarc; b=DP6kEbrXpzfTNOddNGd1c7FxyVnVvN0MnplrqpKLRFGmmAxZ3g5q6iqrf3jU4+c1cYz80o+5heHIztfzMW8ust+6Wz9CDwB2qJ4Ik2L5EfMf4yC5hrrjj+G07Cq1HYz6uBmwaJmezPGrHAtndD8IjKJOH57OCLhTFitqBY9LqJs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1741165992; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=kd9A3RPHtE4WbhtZy7g4A6o5dxf1Hpbh5fmcqVM2Avc=; b=ZLQTpWG2MleuMIVQ8mz1sit4sx63nqVTvB+tJ+S7wIkK2hY2paCeOLAY9+3YMxQ0Gza5VXjDMjT3jlzhpQQfaX1+9PsVIqN6JSTMQXsoOeKzaFTPviCaNopS674svCiFCCnyTAbCMZ9AiUewgevD47r7T7B6Klhy2KbXsWrLT7c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1741165992748949.670314128384; Wed, 5 Mar 2025 01:13:12 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.901877.1309872 (Exim 4.92) (envelope-from ) id 1tpknS-0000Po-Eb; Wed, 05 Mar 2025 09:12:10 +0000 Received: by outflank-mailman (output) from mailman id 901877.1309872; Wed, 05 Mar 2025 09:12:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tpknS-0000Op-2g; Wed, 05 Mar 2025 09:12:10 +0000 Received: by outflank-mailman (input) for mailman id 901877; Wed, 05 Mar 2025 09:12:08 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tpknQ-0006ew-8W for xen-devel@lists.xenproject.org; Wed, 05 Mar 2025 09:12:08 +0000 Received: from mail-lj1-x22d.google.com (mail-lj1-x22d.google.com [2a00:1450:4864:20::22d]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id e88812e1-f9a1-11ef-9898-31a8f345e629; Wed, 05 Mar 2025 10:12:05 +0100 (CET) Received: by mail-lj1-x22d.google.com with SMTP id 38308e7fff4ca-30795988ebeso70454201fa.3 for ; Wed, 05 Mar 2025 01:12:05 -0800 (PST) Received: from EPUAKYIW02F7.. ([95.67.15.120]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5495de028fasm1078264e87.139.2025.03.05.01.12.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Mar 2025 01:12:04 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: e88812e1-f9a1-11ef-9898-31a8f345e629 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741165925; x=1741770725; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kd9A3RPHtE4WbhtZy7g4A6o5dxf1Hpbh5fmcqVM2Avc=; b=X0ey0JHH8QNYZUAscvqafQ9HXMVnKLqo2M/kcasVOuYQ7acU2yE2/81aarCn2gPPAH gfJLkKPqn4EOWG1Bu64H91ZevnlQrPkovmvrChtG7yiMzPVRiriTNWpwV10MEYQiw7Ve dETSkXgzgM80cFE0lUyLcAiPi28GjeDNVC4OkRrkg1sqKoSI6KmdUf9ELuhHU4spXGIB XJFWhG67jomZn7jKHeaxKOFzdMUUmlNPvl0WTMPGSY7gD/njwmT1/MXhrKYXHD+OiIVB sY5ldm7kkZ+nGoPDtWptkyH3WztpTXvER6kO5ftcf5LiEw4zGX9xOyrGAn3vrcevg93T FLXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741165925; x=1741770725; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kd9A3RPHtE4WbhtZy7g4A6o5dxf1Hpbh5fmcqVM2Avc=; b=brWwbFnEdjgGvM2ZvDshauVsukazoe6rLd+jS/OWJw9WIDqL6/7HyfU2RsRaQPEk09 LT7wg8ePKAMDJZbKP7cb0RPsiVvSmpvEpiS8ojS5vzGIZAMjHFQ0nM4vmLeSvwVZl7t5 pX3xJ09jxPJGcTJr+zdZxYc7su0drPqAzDvlGGpHUOXkcHCWSa1IbG+bN8Jj30weiZSZ diJtV9B5TrVtSumRy5xZWNX6CuIv8Iej3Qu6w3jbGUISRRmJL4V4oF9XPlR764k+bOzG d8kkg0R1M1lKXgcCuCIVFUqcybo0FgXK7MVnlcB50v3/teIs2RXOMvzuMhgPIy1TZX2I tMLw== X-Gm-Message-State: AOJu0YwiIxJ9OVEUpWGDciugkPoKAuobXm1bINF/9hVhaE1yN/dXcQmd bpaCIg0bIM6HITME18r1WyqGSTet+lKK5CsQx7cSWcBYqMMW925eJOAq8vOe X-Gm-Gg: ASbGncvjT4kifJRjYmwEpxNXYIL3u/XHK6W6wncKw4oc97Oct8XK/n+l5We6TilFutq pwyqVJlMmSem7Wf5HRAJVSwWxllsP034jETUbOzyUO5RJ9zUC/9pRf2OFJ7BiN9RUkSZ1iWejGY pM88uc/RYmoidrhwTt4pj8LRBdFjOyGtzVYHuzi75g75tA8ErrZc+AuR/yjDntGLSL6TFtfK7MC L/mvkc+2qzgUpC/QizSSZ2u/y7I1zsPzmwxTfIkogztQs9QN+rf4wj9KiLPw1LlsvCQEv6ByQdY 7EghN5l2iPnYRpAHpR4Us6oPHsmR8FmWmg9ATmxSzbtgiaGiOQ== X-Google-Smtp-Source: AGHT+IHrsYsDR4qMXWVpxHaZu+wKGEz/PXJcy2Ue5u4oge/Kp9XG1dzWJFj7drL2FXF8JTW6lj9+WA== X-Received: by 2002:a05:6512:3e06:b0:546:2f7a:38c4 with SMTP id 2adb3069b0e04-5497d335a4bmr910391e87.13.1741165924863; Wed, 05 Mar 2025 01:12:04 -0800 (PST) From: Mykola Kvach To: xen-devel@lists.xenproject.org Cc: Mykola Kvach , Dario Faggioli , Juergen Gross , George Dunlap , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini , Mirela Simonovic , Saeed Nowshadi , Mykyta Poturai Subject: [PATCH 08/16] xen/arm: add watchdog domain suspend/resume helpers Date: Wed, 5 Mar 2025 11:11:16 +0200 Message-ID: <15604985aae5333670467a84cccbaaa403a10000.1741164138.git.xakep.amatop@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1741165995480019100 Content-Type: text/plain; charset="utf-8" From: Mykola Kvach This patch implements suspend/resume helpers for the watchdog. 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. Signed-off-by: Mirela Simonovic Signed-off-by: Saeed Nowshadi Signed-off-by: Mykyta Poturai Signed-off-by: Mykola Kvach --- Changes in v3: - cover the code with CONFIG_SYSTEM_SUSPEND Changes in v2: - drop suspended field from timer structure - drop the call of watchdog_domain_resume from ctxt_switch_to --- xen/common/sched/core.c | 39 +++++++++++++++++++++++++++++++++++++++ xen/include/xen/sched.h | 9 +++++++++ 2 files changed, 48 insertions(+) diff --git a/xen/common/sched/core.c b/xen/common/sched/core.c index b1c6b6b9fa..6c2231826a 100644 --- a/xen/common/sched/core.c +++ b/xen/common/sched/core.c @@ -1605,6 +1605,45 @@ void watchdog_domain_destroy(struct domain *d) kill_timer(&d->watchdog_timer[i].timer); } =20 +#ifdef CONFIG_SYSTEM_SUSPEND + +void watchdog_domain_suspend(struct domain *d) +{ + unsigned int i; + + spin_lock(&d->watchdog_lock); + + for ( i =3D 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 =3D 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); +} + +#endif /* CONFIG_SYSTEM_SUSPEND */ + /* * 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 d0d10612ce..caab4aad93 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -1109,6 +1109,15 @@ void scheduler_disable(void); void watchdog_domain_init(struct domain *d); void watchdog_domain_destroy(struct domain *d); =20 +#ifdef CONFIG_SYSTEM_SUSPEND +/* + * 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); +#endif /* CONFIG_SYSTEM_SUSPEND */ + /* * Use this check when the following are both true: * - Using this feature or interface requires full access to the hardware --=20 2.43.0