From nobody Wed Apr 24 06:30:28 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557512987; cv=none; d=zoho.com; s=zohoarc; b=FcaxQICK1RJ6/Vuehb+eOI8QJqkZ0JSMO8WQOAjQBN/D0oSG9eKHNxl2AqNya6NsgCN3vhckkd/Oj8iZxZwL05pCcdiol6PVWar3VUAcWER9hkGW0QG0v1jU3ooth0wlXGRm67AN5oJE0DtW4IDtn2L1KwNv1ORjuCCsJZC4fLs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557512987; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=tr3H+ugH+/eq0jdFAPhKlseUjhXfG19shYOZQJdubWY=; b=K5jBIIX57Q8WaWVdyK4/GWRV4fLYxOezko50cUnwS0b72HISAc4dVMt+yO2HC9mgEwJ+U5ku1j2HU7O7CD5ek80EKa/k+cwJKvr/Ey9slQ4lKAecsojLFMofu8ilBLweomzwWNO7G8z+2TtyPfz6U8Z/DQWrDi5bb/gvzOI1QXE= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557512987117725.8512096243352; Fri, 10 May 2019 11:29:47 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hPAFf-0006vW-Lp; Fri, 10 May 2019 18:28:11 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hPAFe-0006vK-Fx for xen-devel@lists.xenproject.org; Fri, 10 May 2019 18:28:10 +0000 Received: from SMTP03.CITRIX.COM (unknown [162.221.156.55]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 5caea7a1-7351-11e9-8980-bc764e045a96; Fri, 10 May 2019 18:28:09 +0000 (UTC) X-Inumbo-ID: 5caea7a1-7351-11e9-8980-bc764e045a96 X-IronPort-AV: E=Sophos;i="5.60,454,1549929600"; d="scan'208";a="85337735" From: Andrew Cooper To: Xen-devel Date: Fri, 10 May 2019 19:28:01 +0100 Message-ID: <1557512884-32395-2-git-send-email-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1557512884-32395-1-git-send-email-andrew.cooper3@citrix.com> References: <1557512884-32395-1-git-send-email-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 1/4] xen/watchdog: Fold exit paths to have a single unlock X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Wei Liu , George Dunlap , Andrew Cooper , Christian Lindig , Pau Ruiz Safont , Julien Grall , =?UTF-8?q?Edwin=20T=C3=B6r=C3=B6k?= , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" This is mostly to simplify future logical changes, but it does come with a modest redunction in compiled code size (-55, 345 =3D> 290). No functional change. Signed-off-by: Andrew Cooper Reviewed-by: George Dunlap Reviewed-by: Wei Liu --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monn=C3=A9 CC: Stefano Stabellini CC: Julien Grall CC: George Dunlap CC: Edwin T=C3=B6r=C3=B6k CC: Christian Lindig CC: Pau Ruiz Safont --- xen/common/schedule.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 66f1e26..47f5d04 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -1050,6 +1050,8 @@ static void domain_watchdog_timeout(void *data) =20 static long domain_watchdog(struct domain *d, uint32_t id, uint32_t timeou= t) { + long rc =3D 0; + if ( id > NR_DOMAIN_WATCHDOG_TIMERS ) return -EINVAL; =20 @@ -1064,15 +1066,15 @@ static long domain_watchdog(struct domain *d, uint3= 2_t id, uint32_t timeout) set_timer(&d->watchdog_timer[id], NOW() + SECONDS(timeout)); break; } - spin_unlock(&d->watchdog_lock); - return id =3D=3D NR_DOMAIN_WATCHDOG_TIMERS ? -ENOSPC : id + 1; + rc =3D id =3D=3D NR_DOMAIN_WATCHDOG_TIMERS ? -ENOSPC : id + 1; + goto unlock; } =20 id -=3D 1; if ( !test_bit(id, &d->watchdog_inuse_map) ) { - spin_unlock(&d->watchdog_lock); - return -EINVAL; + rc =3D -EINVAL; + goto unlock; } =20 if ( timeout =3D=3D 0 ) @@ -1085,8 +1087,10 @@ static long domain_watchdog(struct domain *d, uint32= _t id, uint32_t timeout) set_timer(&d->watchdog_timer[id], NOW() + SECONDS(timeout)); } =20 + unlock: spin_unlock(&d->watchdog_lock); - return 0; + + return rc; } =20 void watchdog_domain_init(struct domain *d) --=20 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Wed Apr 24 06:30:28 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557512983; cv=none; d=zoho.com; s=zohoarc; b=H/9u3hmDmvfrjAGu89FCz/SmQpAWqhKuAYZD8p/4BHMmidYY/jl8EwYdBGeORmUGNOI7PfSNH47RoeYKrRfc0G45syLNx5FqJabCwoiRkLNJOPj1sjUIDwSilGwz6CTvVaSlaUrtd0H1SXSLwBx2Sq/kkEEyvumXC14im4C53qs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557512983; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=2eTrEyF0/kxL92mfLvBn4p6lf8IuCrU4lmIMzPfujxY=; b=GUShQAiHUEtEX7tU5G3Fo5PpAuXE3PsYXUFfZj974dUI028hgPsVgvrrar7mlMgooloLoDfNrDA3v8S2uCVmY9zCju70E/2IVmACYVqKsqxasoHTS5kqGVCV+7WXzAgmCjrg2sukyTmOXh3LJdgVAUA44+m+cmFTUtvr8IN0BAU= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557512983295385.32085431667224; Fri, 10 May 2019 11:29:43 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hPAFl-0006wJ-FT; Fri, 10 May 2019 18:28:17 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hPAFj-0006vy-N7 for xen-devel@lists.xenproject.org; Fri, 10 May 2019 18:28:15 +0000 Received: from SMTP03.CITRIX.COM (unknown [162.221.156.55]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 5cba340a-7351-11e9-b1a9-c7d1e482a741; Fri, 10 May 2019 18:28:10 +0000 (UTC) X-Inumbo-ID: 5cba340a-7351-11e9-b1a9-c7d1e482a741 X-IronPort-AV: E=Sophos;i="5.60,454,1549929600"; d="scan'208";a="85337736" From: Andrew Cooper To: Xen-devel Date: Fri, 10 May 2019 19:28:02 +0100 Message-ID: <1557512884-32395-3-git-send-email-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1557512884-32395-1-git-send-email-andrew.cooper3@citrix.com> References: <1557512884-32395-1-git-send-email-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 2/4] xen/watchdog: Rearrange the logic to fold the timer-arming paths X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Wei Liu , George Dunlap , Andrew Cooper , Christian Lindig , Pau Ruiz Safont , Julien Grall , =?UTF-8?q?Edwin=20T=C3=B6r=C3=B6k?= , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" By rearranging the logic, the timer allocation loop can reuse the common ti= mer arming/clearing logic. This results in easier to follow code, and a modest reduction in compiled code size (-64, 290 =3D> 226). For domains which use watchdogs, the overwhemling majoriy of hypercalls will be re-arming an existing timer. Arrange the fastpath to match. This does cause one change in behaviour for a corner case. Previously, specifying id =3D 0, timeout =3D 0 would instantly kill the domain, as the = timer would fire before returning to the guest. This corner case is going to be reused for a different purpose in a later change. Signed-off-by: Andrew Cooper --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monn=C3=A9 CC: Stefano Stabellini CC: Julien Grall CC: George Dunlap CC: Edwin T=C3=B6r=C3=B6k CC: Christian Lindig CC: Pau Ruiz Safont --- xen/common/schedule.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 47f5d04..89aba88 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -1057,35 +1057,39 @@ static long domain_watchdog(struct domain *d, uint3= 2_t id, uint32_t timeout) =20 spin_lock(&d->watchdog_lock); =20 - if ( id =3D=3D 0 ) + if ( likely(id !=3D 0) ) /* Operate on a specific timer. */ + { + id -=3D 1; + if ( !test_bit(id, &d->watchdog_inuse_map) ) + { + rc =3D -EINVAL; + goto unlock; + } + } + else /* Allocate the next available timer. */ { for ( id =3D 0; id < NR_DOMAIN_WATCHDOG_TIMERS; id++ ) { if ( test_and_set_bit(id, &d->watchdog_inuse_map) ) continue; - set_timer(&d->watchdog_timer[id], NOW() + SECONDS(timeout)); break; } - rc =3D id =3D=3D NR_DOMAIN_WATCHDOG_TIMERS ? -ENOSPC : id + 1; - goto unlock; - } - - id -=3D 1; - if ( !test_bit(id, &d->watchdog_inuse_map) ) - { - rc =3D -EINVAL; - goto unlock; + if ( id =3D=3D NR_DOMAIN_WATCHDOG_TIMERS ) + { + rc =3D -ENOSPC; + goto unlock; + } + rc =3D id + 1; } =20 - if ( timeout =3D=3D 0 ) + /* (re-)arm, or clear a specific timer. */ + if ( unlikely(timeout =3D=3D 0) ) { stop_timer(&d->watchdog_timer[id]); clear_bit(id, &d->watchdog_inuse_map); } else - { set_timer(&d->watchdog_timer[id], NOW() + SECONDS(timeout)); - } =20 unlock: spin_unlock(&d->watchdog_lock); --=20 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Wed Apr 24 06:30:28 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557512984; cv=none; d=zoho.com; s=zohoarc; b=n8V5o6/nEhPtn1Ny9NINdksh442Bj+H5yZhH8Ua4kXpb/c1JWlCK0P5m/lOmOT0c0Jk86UciUHWqBMFHkuyQyM2RcJHRn2r8XBeX5+TYhVt4QFR283q3ajbCqV3B5b8pEIwSk8HLlIoXcLVDKG/niOqpk3JVErlQ/c5Colf0aoA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557512984; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Tcf+5OEnLCkyiMlcET0vIwm27e7Ix9mPIzgeChRph+4=; b=ji+Audr2VyYjsAqBbjgBBFLezkC0keq108eCyX4nYjRGG+Tw/fa5773YhwGc5xMZT0s6ioDOTovTvGfQJVz39RnU4xgSDrCFrZ8zp8B5A1XendKV6cXGc2VzP5Gepuk1zUc6qCHhATK0V5S4b3YoCJ8PiMi4BByM4jvb4caNszU= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557512984137722.1086067613847; Fri, 10 May 2019 11:29:44 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hPAFh-0006vs-6c; Fri, 10 May 2019 18:28:13 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hPAFf-0006vY-P8 for xen-devel@lists.xenproject.org; Fri, 10 May 2019 18:28:11 +0000 Received: from SMTP03.CITRIX.COM (unknown [162.221.156.55]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 5d2fecb4-7351-11e9-8980-bc764e045a96; Fri, 10 May 2019 18:28:10 +0000 (UTC) X-Inumbo-ID: 5d2fecb4-7351-11e9-8980-bc764e045a96 X-IronPort-AV: E=Sophos;i="5.60,454,1549929600"; d="scan'208";a="85337737" From: Andrew Cooper To: Xen-devel Date: Fri, 10 May 2019 19:28:03 +0100 Message-ID: <1557512884-32395-4-git-send-email-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1557512884-32395-1-git-send-email-andrew.cooper3@citrix.com> References: <1557512884-32395-1-git-send-email-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 3/4] xen/watchdog: Drop all locked operations on the watchdog_inuse_map X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Wei Liu , George Dunlap , Andrew Cooper , Christian Lindig , Pau Ruiz Safont , Julien Grall , =?UTF-8?q?Edwin=20T=C3=B6r=C3=B6k?= , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" All modifications to the watchdog_inuse_map happen with d->watchdog_lock he= ld, so there are no concurrency problems to deal with. Furthermore, there is no need to use a loop to locate the next available watchdog. As the bitmap is currently 2 bits wide and is stored in a uint32= _t, the next available timer can be located in O(1) time using bit-scanning instructions. No change in behaviour, but should have less cache-coherency impact. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monn=C3=A9 CC: Stefano Stabellini CC: Julien Grall CC: George Dunlap CC: Edwin T=C3=B6r=C3=B6k CC: Christian Lindig CC: Pau Ruiz Safont --- xen/common/schedule.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 89aba88..98c2c35 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -1068,17 +1068,15 @@ static long domain_watchdog(struct domain *d, uint3= 2_t id, uint32_t timeout) } else /* Allocate the next available timer. */ { - for ( id =3D 0; id < NR_DOMAIN_WATCHDOG_TIMERS; id++ ) - { - if ( test_and_set_bit(id, &d->watchdog_inuse_map) ) - continue; - break; - } - if ( id =3D=3D NR_DOMAIN_WATCHDOG_TIMERS ) + id =3D ffs(~d->watchdog_inuse_map) - 1; + + if ( unlikely(id >=3D NR_DOMAIN_WATCHDOG_TIMERS) ) { rc =3D -ENOSPC; goto unlock; } + + __set_bit(id, &d->watchdog_inuse_map); rc =3D id + 1; } =20 @@ -1086,7 +1084,7 @@ static long domain_watchdog(struct domain *d, uint32_= t id, uint32_t timeout) if ( unlikely(timeout =3D=3D 0) ) { stop_timer(&d->watchdog_timer[id]); - clear_bit(id, &d->watchdog_inuse_map); + __clear_bit(id, &d->watchdog_inuse_map); } else set_timer(&d->watchdog_timer[id], NOW() + SECONDS(timeout)); --=20 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Wed Apr 24 06:30:28 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557512988; cv=none; d=zoho.com; s=zohoarc; b=X1q3LmiLciU1aGbM/dhWRRh+pyhT8FhFpgE2sAe26MoQwntD3iI6EmNb4mJ31z6qHwp4nnxFo7vB9h7bUe0KgteSjD8eANsF9N+Rzng+HFYcPArIlGdikJaXt1bGqw3a3cKO3e8U1BnKBPfzK180vshrdWSMdKBlzlYf/PB14yo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557512988; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=iCpF0FMAgm26iHyiXJ0zAbP1+yFSFUMjoACE+iItje8=; b=DvpGZhgg6EvkhAjYiP+0v5sYf4qjPuJ5P/2SkG5SXbeouV7MiW5868PhwBOiUZlagCkV/a5PdV7qGcJbR/Q8oLBtwQEAhvwES7pTgVho1ssSakRx/GOYLp6mITpXhbkCxEjXiuBLRBpZBLBJC7QxAktv9roNHDSnrc8aamLT7R0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557512988346521.5876549699516; Fri, 10 May 2019 11:29:48 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hPAFg-0006vm-UI; Fri, 10 May 2019 18:28:12 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hPAFf-0006vX-Nk for xen-devel@lists.xenproject.org; Fri, 10 May 2019 18:28:11 +0000 Received: from SMTP03.CITRIX.COM (unknown [162.221.156.55]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 5d84b725-7351-11e9-8980-bc764e045a96; Fri, 10 May 2019 18:28:11 +0000 (UTC) X-Inumbo-ID: 5d84b725-7351-11e9-8980-bc764e045a96 X-IronPort-AV: E=Sophos;i="5.60,454,1549929600"; d="scan'208";a="85337738" From: Andrew Cooper To: Xen-devel Date: Fri, 10 May 2019 19:28:04 +0100 Message-ID: <1557512884-32395-5-git-send-email-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1557512884-32395-1-git-send-email-andrew.cooper3@citrix.com> References: <1557512884-32395-1-git-send-email-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 4/4] xen/watchdog: Support disable all watchdog timers in one go X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Wei Liu , George Dunlap , Andrew Cooper , Christian Lindig , Pau Ruiz Safont , Julien Grall , =?UTF-8?q?Edwin=20T=C3=B6r=C3=B6k?= , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" For a domain which has been using watchdogs, but wants to cleanly reboot, stopping all active timers is necessary to avoid crashing late during shutdown. The number of watchdogs isn't part of Xen's ABI, so to simplify cleanup and error handling logic, support using id =3D 0, timeout =3D 0 to deactivate a= ll timers in one go. Signed-off-by: Andrew Cooper --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monn=C3=A9 CC: Stefano Stabellini CC: Julien Grall CC: George Dunlap CC: Edwin T=C3=B6r=C3=B6k CC: Christian Lindig CC: Pau Ruiz Safont --- xen/common/schedule.c | 9 ++++++++- xen/include/public/sched.h | 6 ++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 98c2c35..284f657 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -1066,7 +1066,7 @@ static long domain_watchdog(struct domain *d, uint32_= t id, uint32_t timeout) goto unlock; } } - else /* Allocate the next available timer. */ + else if ( timeout ) /* Allocate the next available timer. */ { id =3D ffs(~d->watchdog_inuse_map) - 1; =20 @@ -1079,6 +1079,13 @@ static long domain_watchdog(struct domain *d, uint32= _t id, uint32_t timeout) __set_bit(id, &d->watchdog_inuse_map); rc =3D id + 1; } + else /* id 0, timeout 0 =3D> disable all timers. */ + { + d->watchdog_inuse_map =3D 0; + for ( ; id < NR_DOMAIN_WATCHDOG_TIMERS; ++id ) + stop_timer(&d->watchdog_timer[id]); + goto unlock; + } =20 /* (re-)arm, or clear a specific timer. */ if ( unlikely(timeout =3D=3D 0) ) diff --git a/xen/include/public/sched.h b/xen/include/public/sched.h index 811bd87..994a0e5 100644 --- a/xen/include/public/sched.h +++ b/xen/include/public/sched.h @@ -112,8 +112,10 @@ /* * Setup, poke and destroy a domain watchdog timer. * @arg =3D=3D pointer to sched_watchdog_t structure. - * With id =3D=3D 0, setup a domain watchdog timer to cause domain shutdown - * after timeout, returns watchdog id. + * With id =3D=3D 0 and timeout !=3D 0, setup a domain watchdog timer to c= ause + * domain shutdown after timeout, returns + * watchdog id. + * With id =3D=3D 0 and timeout =3D=3D 0, destroy all watchdog timers. * With id !=3D 0 and timeout =3D=3D 0, destroy domain watchdog timer. * With id !=3D 0 and timeout !=3D 0, poke watchdog timer and set new time= out. */ --=20 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel