From nobody Sat Apr 20 03:39:26 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