From nobody Fri Apr 26 19:02:43 2024 Delivered-To: importer@patchew.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=1559564929; cv=none; d=zoho.com; s=zohoarc; b=M2MtehTGqlY6N+u4n+RT+9ltXjkVJlhoSlVA+aa1Gkr7E/PccNSLspKL2cZrhwSRBwX1LZpvZbfUhq96zDDguYetQduCAhMF5nTqdzmhmENN/3y3s+Kmu5ByPzZdS391r6rWtXzJjdB+/JcjrOe/ExavYpP+kGmIC7NJXCmr1BQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559564929; 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=6mG4sMs7uFmf/S6GJkucVctEw6lPi3IQ5zpZCfF7TDE=; b=UjLsrYyiF0hujdstHNCSs+Q7zTlxpSSkDuus39k20KC1RuCR9RuWXDyFfpcUMjBJWf+w8l5/2duHv8jBnrzxgoMya8isSxmC3xR7y4Cz8z/JztIcLjHF8ShhX3yBJTtOhIc9pqYY0EmHpSPrDk3Rx0kXr6cMk1DVTVdW90XrlcU= 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 1559564929140794.8705890021588; Mon, 3 Jun 2019 05:28:49 -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 1hXm3f-0002iH-Qx; Mon, 03 Jun 2019 12:27:23 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hXm3e-0002i0-AQ for xen-devel@lists.xenproject.org; Mon, 03 Jun 2019 12:27:22 +0000 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id ef61dfa3-85fa-11e9-8980-bc764e045a96; Mon, 03 Jun 2019 12:27:21 +0000 (UTC) X-Inumbo-ID: ef61dfa3-85fa-11e9-8980-bc764e045a96 Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=andrew.cooper3@citrix.com; spf=Pass smtp.mailfrom=Andrew.Cooper3@citrix.com; spf=None smtp.helo=postmaster@MIAPEX02MSOL01.citrite.net 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; Received-SPF: None (esa6.hc3370-68.iphmx.com: no sender authenticity information available from domain of andrew.cooper3@citrix.com) identity=pra; client-ip=23.29.105.83; receiver=esa6.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa6.hc3370-68.iphmx.com: domain of Andrew.Cooper3@citrix.com designates 23.29.105.83 as permitted sender) identity=mailfrom; client-ip=23.29.105.83; receiver=esa6.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="Andrew.Cooper3@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:23.29.105.83 ip4:162.221.156.50 ~all" Received-SPF: None (esa6.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@MIAPEX02MSOL01.citrite.net) identity=helo; client-ip=23.29.105.83; receiver=esa6.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@MIAPEX02MSOL01.citrite.net"; x-conformance=sidf_compatible IronPort-SDR: crs1FslT3zE6b2V/cXzj73zLbpgWfeKCZTP/X1z0psQ6M9g3LkeiUNVPT31v3aP2M6/VsaaHiZ d3ibihag/3qMDlHfVVjvOIw5gM+EehVf+/ZeHJN638Vk44ic08dUKAfya+K1yBZrnglUgiTove vABf3cpvn3bAw235qYodlWNOzZZ3Roc3BgCh2c7PhoxhaPxb2ZZNHeY1tBKGra/GPO+y540nmD s3mBOj4NttjnF5DkIF6tp7SxreFoNRdrsHx+q2mmpfVweOH4bkovjVUDzBLtxTYH6x2eUQbIkI XDg= X-SBRS: 2.7 X-MesageID: 1206004 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 23.29.105.83 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.60,546,1549947600"; d="scan'208";a="1206004" From: Andrew Cooper To: Xen-devel Date: Mon, 3 Jun 2019 13:25:24 +0100 Message-ID: <1559564728-17167-2-git-send-email-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1559564728-17167-1-git-send-email-andrew.cooper3@citrix.com> References: <1559564728-17167-1-git-send-email-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 1/5] xen/vm-event: Drop unused u_domctl parameter from vm_event_domctl() 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: Petre Pircalabu , Andrew Cooper , Tamas K Lengyel , Razvan Cojocaru Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" This parameter isn't used at all. Futhermore, elide the copyback in failing cases, as it is only successful paths which generate data which needs sending back to the caller. Finally, drop a redundant d =3D=3D NULL check, as that logic is all common at the begining of do_domctl(). No functional change. Signed-off-by: Andrew Cooper Acked-by: Jan Beulich Acked-by: Razvan Cojocaru --- CC: Razvan Cojocaru CC: Tamas K Lengyel CC: Petre Pircalabu --- xen/common/domctl.c | 6 +++--- xen/common/vm_event.c | 6 +----- xen/include/xen/vm_event.h | 3 +-- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/xen/common/domctl.c b/xen/common/domctl.c index bade9a6..72a4495 100644 --- a/xen/common/domctl.c +++ b/xen/common/domctl.c @@ -1018,9 +1018,9 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u= _domctl) break; =20 case XEN_DOMCTL_vm_event_op: - ret =3D vm_event_domctl(d, &op->u.vm_event_op, - guest_handle_cast(u_domctl, void)); - copyback =3D 1; + ret =3D vm_event_domctl(d, &op->u.vm_event_op); + if ( ret =3D=3D 0 ) + copyback =3D true; break; =20 #ifdef CONFIG_MEM_ACCESS diff --git a/xen/common/vm_event.c b/xen/common/vm_event.c index 74a4755..902e152 100644 --- a/xen/common/vm_event.c +++ b/xen/common/vm_event.c @@ -583,8 +583,7 @@ void vm_event_cleanup(struct domain *d) #endif } =20 -int vm_event_domctl(struct domain *d, struct xen_domctl_vm_event_op *vec, - XEN_GUEST_HANDLE_PARAM(void) u_domctl) +int vm_event_domctl(struct domain *d, struct xen_domctl_vm_event_op *vec) { int rc; =20 @@ -594,9 +593,6 @@ int vm_event_domctl(struct domain *d, struct xen_domctl= _vm_event_op *vec, return 0; } =20 - if ( unlikely(d =3D=3D NULL) ) - return -ESRCH; - rc =3D xsm_vm_event_control(XSM_PRIV, d, vec->mode, vec->op); if ( rc ) return rc; diff --git a/xen/include/xen/vm_event.h b/xen/include/xen/vm_event.h index 7f6fb6d..3cc2b20 100644 --- a/xen/include/xen/vm_event.h +++ b/xen/include/xen/vm_event.h @@ -64,8 +64,7 @@ void vm_event_cancel_slot(struct domain *d, struct vm_eve= nt_domain *ved); void vm_event_put_request(struct domain *d, struct vm_event_domain *ved, vm_event_request_t *req); =20 -int vm_event_domctl(struct domain *d, struct xen_domctl_vm_event_op *vec, - XEN_GUEST_HANDLE_PARAM(void) u_domctl); +int vm_event_domctl(struct domain *d, struct xen_domctl_vm_event_op *vec); =20 void vm_event_vcpu_pause(struct vcpu *v); void vm_event_vcpu_unpause(struct vcpu *v); --=20 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Fri Apr 26 19:02:43 2024 Delivered-To: importer@patchew.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=1559564919; cv=none; d=zoho.com; s=zohoarc; b=L8pHRIyYbixJ9G8vEB21x/qUEd18ypKSPficvrw+iqnr+Fq8V2THtbfwpUOuQ/LS18KFE3nyYrowAzxGtzLPXsxx7owOWyLHQ6QGSYWlUrJj/EUxkaBObEgYcxEFm9M6/rPkRK9WD/aZgaQ9qTmRKiJaL0N4sEC10kWqmavVH/g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559564919; 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=Wna5cMvyDn2STU+ltszQtuBHWpVAgdNetjcjByBrvIU=; b=eoFSiERjkqKxMOiIvMejyiuWw3ajLg4N6CV0bpbX5LI7EMDYa75TBoI1R4QZNFIAsyLFs0GZc3YGiaYDtLaiFH8902BTCACV3W2ucQ31QHaB+dP5VOoCBoD6aJPmsy6iLOfsZKz1uSWMjTEYPJlH+Y9+XOVpsqAW9fW+k8qxDCw= 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 1559564919303948.2907575352335; Mon, 3 Jun 2019 05:28:39 -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 1hXm3f-0002iA-HV; Mon, 03 Jun 2019 12:27:23 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hXm3e-0002hz-9W for xen-devel@lists.xenproject.org; Mon, 03 Jun 2019 12:27:22 +0000 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id ee9cd0cd-85fa-11e9-8980-bc764e045a96; Mon, 03 Jun 2019 12:27:20 +0000 (UTC) X-Inumbo-ID: ee9cd0cd-85fa-11e9-8980-bc764e045a96 Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=andrew.cooper3@citrix.com; spf=Pass smtp.mailfrom=Andrew.Cooper3@citrix.com; spf=None smtp.helo=postmaster@MIAPEX02MSOL01.citrite.net 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; Received-SPF: None (esa6.hc3370-68.iphmx.com: no sender authenticity information available from domain of andrew.cooper3@citrix.com) identity=pra; client-ip=23.29.105.83; receiver=esa6.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa6.hc3370-68.iphmx.com: domain of Andrew.Cooper3@citrix.com designates 23.29.105.83 as permitted sender) identity=mailfrom; client-ip=23.29.105.83; receiver=esa6.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="Andrew.Cooper3@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:23.29.105.83 ip4:162.221.156.50 ~all" Received-SPF: None (esa6.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@MIAPEX02MSOL01.citrite.net) identity=helo; client-ip=23.29.105.83; receiver=esa6.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@MIAPEX02MSOL01.citrite.net"; x-conformance=sidf_compatible IronPort-SDR: mFpd0BHq41rqUkknaawpmlgst8b43wtM2rGYzHUVKlX3x4UWFP0B8p6BdLHDCXipGDJ8PlBgMK hjY6m1Yx4I0TUAYyu/6YTwKZEfAkWWkFVjqv5jfNPe06KaxzE1QA+4q9Y/s8w7V1yCPNXx1kOU KfW4PH9rZGEQkXWiRQHrV1Oea5BD0eIu5ltlAbyRdLHvyIRLu/MU1bkdKxATprhmFNXQXVMKSq ecogSu31C0ZH58itwtbENSJ2A/JZwueKmjnKO3w55vCyl5h0sdg8pb38EEimgYeNWkqUtbFxAe qLY= X-SBRS: 2.7 X-MesageID: 1206003 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 23.29.105.83 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.60,546,1549947600"; d="scan'208";a="1206003" From: Andrew Cooper To: Xen-devel Date: Mon, 3 Jun 2019 13:25:25 +0100 Message-ID: <1559564728-17167-3-git-send-email-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1559564728-17167-1-git-send-email-andrew.cooper3@citrix.com> References: <1559564728-17167-1-git-send-email-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 2/5] xen/vm-event: Expand vm_event_* spinlock macros and rename the lock 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: Petre Pircalabu , Andrew Cooper , Tamas K Lengyel , Razvan Cojocaru Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" These serve no purpose, but to add to the congnitive load of following the code. Remove the level of indirection. Furthermore, the lock protects all data in vm_event_domain, making ring_lock a poor choice of name. For vm_event_get_response() and vm_event_grab_slot(), fold the exit paths to have a single unlock, as the compiler can't make this optimisation itself. No functional change. Signed-off-by: Andrew Cooper Acked-by: Razvan Cojocaru --- CC: Razvan Cojocaru CC: Tamas K Lengyel CC: Petre Pircalabu --- xen/common/vm_event.c | 58 ++++++++++++++++++++++++---------------------= ---- xen/include/xen/sched.h | 3 +-- 2 files changed, 30 insertions(+), 31 deletions(-) diff --git a/xen/common/vm_event.c b/xen/common/vm_event.c index 902e152..db975e9 100644 --- a/xen/common/vm_event.c +++ b/xen/common/vm_event.c @@ -35,10 +35,6 @@ #define xen_rmb() smp_rmb() #define xen_wmb() smp_wmb() =20 -#define vm_event_ring_lock_init(_ved) spin_lock_init(&(_ved)->ring_lock) -#define vm_event_ring_lock(_ved) spin_lock(&(_ved)->ring_lock) -#define vm_event_ring_unlock(_ved) spin_unlock(&(_ved)->ring_lock) - static int vm_event_enable( struct domain *d, struct xen_domctl_vm_event_op *vec, @@ -66,8 +62,8 @@ static int vm_event_enable( if ( ring_gfn =3D=3D 0 ) return -EOPNOTSUPP; =20 - vm_event_ring_lock_init(*ved); - vm_event_ring_lock(*ved); + spin_lock_init(&(*ved)->lock); + spin_lock(&(*ved)->lock); =20 rc =3D vm_event_init_domain(d); =20 @@ -101,13 +97,13 @@ static int vm_event_enable( /* Initialize the last-chance wait queue. */ init_waitqueue_head(&(*ved)->wq); =20 - vm_event_ring_unlock(*ved); + spin_unlock(&(*ved)->lock); return 0; =20 err: destroy_ring_for_helper(&(*ved)->ring_page, (*ved)->ring_pg_struct); - vm_event_ring_unlock(*ved); + spin_unlock(&(*ved)->lock); xfree(*ved); *ved =3D NULL; =20 @@ -200,11 +196,11 @@ static int vm_event_disable(struct domain *d, struct = vm_event_domain **ved) { struct vcpu *v; =20 - vm_event_ring_lock(*ved); + spin_lock(&(*ved)->lock); =20 if ( !list_empty(&(*ved)->wq.list) ) { - vm_event_ring_unlock(*ved); + spin_unlock(&(*ved)->lock); return -EBUSY; } =20 @@ -226,7 +222,7 @@ static int vm_event_disable(struct domain *d, struct vm= _event_domain **ved) =20 vm_event_cleanup_domain(d); =20 - vm_event_ring_unlock(*ved); + spin_unlock(&(*ved)->lock); } =20 xfree(*ved); @@ -292,7 +288,7 @@ void vm_event_put_request(struct domain *d, =20 req->version =3D VM_EVENT_INTERFACE_VERSION; =20 - vm_event_ring_lock(ved); + spin_lock(&ved->lock); =20 /* Due to the reservations, this step must succeed. */ front_ring =3D &ved->front_ring; @@ -319,7 +315,7 @@ void vm_event_put_request(struct domain *d, !atomic_read(&curr->vm_event_pause_count) ) vm_event_mark_and_pause(curr, ved); =20 - vm_event_ring_unlock(ved); + spin_unlock(&ved->lock); =20 notify_via_xen_event_channel(d, ved->xen_port); } @@ -329,17 +325,15 @@ static int vm_event_get_response(struct domain *d, st= ruct vm_event_domain *ved, { vm_event_front_ring_t *front_ring; RING_IDX rsp_cons; + int rc =3D 0; =20 - vm_event_ring_lock(ved); + spin_lock(&ved->lock); =20 front_ring =3D &ved->front_ring; rsp_cons =3D front_ring->rsp_cons; =20 if ( !RING_HAS_UNCONSUMED_RESPONSES(front_ring) ) - { - vm_event_ring_unlock(ved); - return 0; - } + goto out; =20 /* Copy response */ memcpy(rsp, RING_GET_RESPONSE(front_ring, rsp_cons), sizeof(*rsp)); @@ -353,9 +347,12 @@ static int vm_event_get_response(struct domain *d, str= uct vm_event_domain *ved, * there may be additional space available in the ring. */ vm_event_wake(d, ved); =20 - vm_event_ring_unlock(ved); + rc =3D 1; =20 - return 1; + out: + spin_unlock(&ved->lock); + + return rc; } =20 /* @@ -455,35 +452,38 @@ void vm_event_cancel_slot(struct domain *d, struct vm= _event_domain *ved) if( !vm_event_check_ring(ved) ) return; =20 - vm_event_ring_lock(ved); + spin_lock(&ved->lock); vm_event_release_slot(d, ved); - vm_event_ring_unlock(ved); + spin_unlock(&ved->lock); } =20 static int vm_event_grab_slot(struct vm_event_domain *ved, int foreign) { unsigned int avail_req; + int rc; =20 if ( !ved->ring_page ) return -EOPNOTSUPP; =20 - vm_event_ring_lock(ved); + spin_lock(&ved->lock); =20 avail_req =3D vm_event_ring_available(ved); + + rc =3D -EBUSY; if ( avail_req =3D=3D 0 ) - { - vm_event_ring_unlock(ved); - return -EBUSY; - } + goto out; =20 if ( !foreign ) ved->target_producers++; else ved->foreign_producers++; =20 - vm_event_ring_unlock(ved); + rc =3D 0; =20 - return 0; + out: + spin_unlock(&ved->lock); + + return rc; } =20 /* Simple try_grab wrapper for use in the wait_event() macro. */ diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 2201fac..b9691fc 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -282,8 +282,7 @@ struct vcpu /* VM event */ struct vm_event_domain { - /* ring lock */ - spinlock_t ring_lock; + spinlock_t lock; /* The ring has 64 entries */ unsigned char foreign_producers; unsigned char target_producers; --=20 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Fri Apr 26 19:02:43 2024 Delivered-To: importer@patchew.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=1559564933; cv=none; d=zoho.com; s=zohoarc; b=BWeacEHwYlmaQwEcSGslH3JOCv4934hhBDmYnkPq9CvdaxYWPhEXhWFaawWpPjpGiateyo3noHwqAUtXaNNy6Etl6/hCFSyDZav2cTNFaa89gm40H+K6R+McqLrhScHwT1uXe//bi+JtxM1KQnqif2RVLxs7/ALddro9pIXcVRo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559564933; 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=ZmnNCaC5DJZSWMhAbpNl9pgZ7nyrBK+6e2Sw1yh6cU8=; b=cLJnNUZ1Zbfsocb3uFZRC+/7oJ39bi/Pb4BR5I23tDbfDlXibpYdO9Lgr/EyfAPj0H98D2ZBxkb5K/Mi35f+buljMdYGJZdcseRQfluo4mm3ii5p3DyTwAYPwOZ2kGVKm/9bux802rE1csVi1yxmYMJ2JUBKw50Hhv7CIzq1O2A= 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 1559564933065859.0186364070069; Mon, 3 Jun 2019 05:28:53 -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 1hXm40-0002o3-RK; Mon, 03 Jun 2019 12:27:44 +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 1hXm3z-0002nC-Gj for xen-devel@lists.xenproject.org; Mon, 03 Jun 2019 12:27:43 +0000 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id f9b906e4-85fa-11e9-9fcf-336492711862; Mon, 03 Jun 2019 12:27:39 +0000 (UTC) X-Inumbo-ID: f9b906e4-85fa-11e9-9fcf-336492711862 Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=andrew.cooper3@citrix.com; spf=Pass smtp.mailfrom=Andrew.Cooper3@citrix.com; spf=None smtp.helo=postmaster@MIAPEX02MSOL02.citrite.net 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; Received-SPF: None (esa5.hc3370-68.iphmx.com: no sender authenticity information available from domain of andrew.cooper3@citrix.com) identity=pra; client-ip=23.29.105.83; receiver=esa5.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa5.hc3370-68.iphmx.com: domain of Andrew.Cooper3@citrix.com designates 23.29.105.83 as permitted sender) identity=mailfrom; client-ip=23.29.105.83; receiver=esa5.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="Andrew.Cooper3@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:23.29.105.83 ip4:162.221.156.50 ~all" Received-SPF: None (esa5.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@MIAPEX02MSOL02.citrite.net) identity=helo; client-ip=23.29.105.83; receiver=esa5.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@MIAPEX02MSOL02.citrite.net"; x-conformance=sidf_compatible IronPort-SDR: tfCXhO82ivCs1L11dQ7dQYzVyNJaZ7CUr48tS1CwPAPmtLWg7mO3Iaoqg1i+k/HZZG10+4/ePt A2HX7vNSyTi1nfN/kX+Q0YOmqIW9Dh3BUl1tlCS2axIMBB2YXeslucAztJXQpbaiAqAWXA/g5y RTn4DOgbc4eG6ccFJMpmzSd3rQRe8bDUKQ7v9zxESNvNVQvl4J8mFoFrwsmNLppGrKQXb07bhb kPPo4NErJG2/NlnluMQvZLbq68NX8RsDuI47jIST9pfJbwEcG44oGAsyFXHqsYQPa/YWInGp+W Dgo= X-SBRS: 2.7 X-MesageID: 1213218 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 23.29.105.83 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.60,546,1549947600"; d="scan'208";a="1213218" From: Andrew Cooper To: Xen-devel Date: Mon, 3 Jun 2019 13:25:26 +0100 Message-ID: <1559564728-17167-4-git-send-email-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1559564728-17167-1-git-send-email-andrew.cooper3@citrix.com> References: <1559564728-17167-1-git-send-email-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 3/5] xen/vm-event: Remove unnecessary vm_event_domain indirection 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: Petre Pircalabu , Andrew Cooper , Tamas K Lengyel , Razvan Cojocaru Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The use of (*ved)-> leads to poor code generation, as the compiler can't assume the pointer hasn't changed, and results in hard-to-follow code. For both vm_event_{en,dis}able(), rename the ved parameter to p_ved, and work primarily with a local ved pointer. This has a key advantage in vm_event_enable(), in that the partially constructed vm_event_domain only becomes globally visible once it is fully constructed. As a consequence, the spinlock doesn't need holding. Furthermore, rearrange the order of operations to be more sensible. Check for repeated enables and an bad HVM_PARAM before allocating memory, and gather the trivial setup into one place, dropping the redundant zeroing. No practical change that callers will notice. Signed-off-by: Andrew Cooper Acked-by: Razvan Cojocaru --- CC: Razvan Cojocaru CC: Tamas K Lengyel CC: Petre Pircalabu --- xen/common/vm_event.c | 90 +++++++++++++++++++++++------------------------= ---- 1 file changed, 40 insertions(+), 50 deletions(-) diff --git a/xen/common/vm_event.c b/xen/common/vm_event.c index db975e9..dcba98c 100644 --- a/xen/common/vm_event.c +++ b/xen/common/vm_event.c @@ -38,74 +38,63 @@ static int vm_event_enable( struct domain *d, struct xen_domctl_vm_event_op *vec, - struct vm_event_domain **ved, + struct vm_event_domain **p_ved, int pause_flag, int param, xen_event_channel_notification_t notification_fn) { int rc; unsigned long ring_gfn =3D d->arch.hvm.params[param]; + struct vm_event_domain *ved; =20 - if ( !*ved ) - *ved =3D xzalloc(struct vm_event_domain); - if ( !*ved ) - return -ENOMEM; - - /* Only one helper at a time. If the helper crashed, - * the ring is in an undefined state and so is the guest. + /* + * Only one connected agent at a time. If the helper crashed, the rin= g is + * in an undefined state, and the guest is most likely unrecoverable. */ - if ( (*ved)->ring_page ) - return -EBUSY;; + if ( *p_ved !=3D NULL ) + return -EBUSY; =20 - /* The parameter defaults to zero, and it should be - * set to something */ + /* No chosen ring GFN? Nothing we can do. */ if ( ring_gfn =3D=3D 0 ) return -EOPNOTSUPP; =20 - spin_lock_init(&(*ved)->lock); - spin_lock(&(*ved)->lock); + ved =3D xzalloc(struct vm_event_domain); + if ( !ved ) + return -ENOMEM; =20 - rc =3D vm_event_init_domain(d); + /* Trivial setup. */ + spin_lock_init(&ved->lock); + init_waitqueue_head(&ved->wq); + ved->pause_flag =3D pause_flag; =20 + rc =3D vm_event_init_domain(d); if ( rc < 0 ) goto err; =20 - rc =3D prepare_ring_for_helper(d, ring_gfn, &(*ved)->ring_pg_struct, - &(*ved)->ring_page); + rc =3D prepare_ring_for_helper(d, ring_gfn, &ved->ring_pg_struct, + &ved->ring_page); if ( rc < 0 ) goto err; =20 - /* Set the number of currently blocked vCPUs to 0. */ - (*ved)->blocked =3D 0; + FRONT_RING_INIT(&ved->front_ring, + (vm_event_sring_t *)ved->ring_page, + PAGE_SIZE); =20 - /* Allocate event channel */ rc =3D alloc_unbound_xen_event_channel(d, 0, current->domain->domain_i= d, notification_fn); if ( rc < 0 ) goto err; =20 - (*ved)->xen_port =3D vec->u.enable.port =3D rc; + ved->xen_port =3D vec->u.enable.port =3D rc; =20 - /* Prepare ring buffer */ - FRONT_RING_INIT(&(*ved)->front_ring, - (vm_event_sring_t *)(*ved)->ring_page, - PAGE_SIZE); - - /* Save the pause flag for this particular ring. */ - (*ved)->pause_flag =3D pause_flag; - - /* Initialize the last-chance wait queue. */ - init_waitqueue_head(&(*ved)->wq); + /* Success. Fill in the domain's appropriate ved. */ + *p_ved =3D ved; =20 - spin_unlock(&(*ved)->lock); return 0; =20 err: - destroy_ring_for_helper(&(*ved)->ring_page, - (*ved)->ring_pg_struct); - spin_unlock(&(*ved)->lock); - xfree(*ved); - *ved =3D NULL; + destroy_ring_for_helper(&ved->ring_page, ved->ring_pg_struct); + xfree(ved); =20 return rc; } @@ -190,43 +179,44 @@ void vm_event_wake(struct domain *d, struct vm_event_= domain *ved) vm_event_wake_blocked(d, ved); } =20 -static int vm_event_disable(struct domain *d, struct vm_event_domain **ved) +static int vm_event_disable(struct domain *d, struct vm_event_domain **p_v= ed) { - if ( vm_event_check_ring(*ved) ) + struct vm_event_domain *ved =3D *p_ved; + + if ( vm_event_check_ring(ved) ) { struct vcpu *v; =20 - spin_lock(&(*ved)->lock); + spin_lock(&ved->lock); =20 - if ( !list_empty(&(*ved)->wq.list) ) + if ( !list_empty(&ved->wq.list) ) { - spin_unlock(&(*ved)->lock); + spin_unlock(&ved->lock); return -EBUSY; } =20 /* Free domU's event channel and leave the other one unbound */ - free_xen_event_channel(d, (*ved)->xen_port); + free_xen_event_channel(d, ved->xen_port); =20 /* Unblock all vCPUs */ for_each_vcpu ( d, v ) { - if ( test_and_clear_bit((*ved)->pause_flag, &v->pause_flags) ) + if ( test_and_clear_bit(ved->pause_flag, &v->pause_flags) ) { vcpu_unpause(v); - (*ved)->blocked--; + ved->blocked--; } } =20 - destroy_ring_for_helper(&(*ved)->ring_page, - (*ved)->ring_pg_struct); + destroy_ring_for_helper(&ved->ring_page, ved->ring_pg_struct); =20 vm_event_cleanup_domain(d); =20 - spin_unlock(&(*ved)->lock); + spin_unlock(&ved->lock); } =20 - xfree(*ved); - *ved =3D NULL; + xfree(ved); + *p_ved =3D NULL; =20 return 0; } --=20 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Fri Apr 26 19:02:43 2024 Delivered-To: importer@patchew.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=1559564919; cv=none; d=zoho.com; s=zohoarc; b=Qj6hQg1fDiRVYdracFh+2izK/K2zjsIz2m5mG4R+iq/9V6lSisyB4JM75ZxipPCIeTLZkKDdZwUow29ZpVegmgzQ/YyHe1wOuzUDjvbs1a/FGgZBe+3nBL+w68JnC2MOJl3rw2MELG0U+/RZB/rNqwXrLMOKU61Hru+SCn0A38U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559564919; 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=2CV4wM1JDXZRnZ49uSPLtD+eUrRThU5ZlgezyriezYs=; b=k72zIGMvhf6Rh4RSBUGjchJVozdY9v9X4ub6+WGecGoeYXuyc8LbQYIPCPc7Qm/l/XAkhd3D2UYOEoqyUibfzmU+wUXXVs/x+CUI0ibJiF/C+WfIGn+UHOxROkQ5D8NH6bG4dFQPKM25Kbqo62cDMK77HNYt+jlxYzgF3DB0xZo= 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 1559564919229542.1271292001747; Mon, 3 Jun 2019 05:28:39 -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 1hXm3h-0002iT-5I; Mon, 03 Jun 2019 12:27:25 +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 1hXm3g-0002iO-Hb for xen-devel@lists.xenproject.org; Mon, 03 Jun 2019 12:27:24 +0000 Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id eed7ffe6-85fa-11e9-9be6-cfe6b1c824ea; Mon, 03 Jun 2019 12:27:21 +0000 (UTC) X-Inumbo-ID: eed7ffe6-85fa-11e9-9be6-cfe6b1c824ea Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=andrew.cooper3@citrix.com; spf=Pass smtp.mailfrom=Andrew.Cooper3@citrix.com; spf=None smtp.helo=postmaster@MIAPEX02MSOL01.citrite.net 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; Received-SPF: None (esa3.hc3370-68.iphmx.com: no sender authenticity information available from domain of andrew.cooper3@citrix.com) identity=pra; client-ip=23.29.105.83; receiver=esa3.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa3.hc3370-68.iphmx.com: domain of Andrew.Cooper3@citrix.com designates 23.29.105.83 as permitted sender) identity=mailfrom; client-ip=23.29.105.83; receiver=esa3.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="Andrew.Cooper3@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:23.29.105.83 ip4:162.221.156.50 ~all" Received-SPF: None (esa3.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@MIAPEX02MSOL01.citrite.net) identity=helo; client-ip=23.29.105.83; receiver=esa3.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@MIAPEX02MSOL01.citrite.net"; x-conformance=sidf_compatible IronPort-SDR: Ty6Phr2GVWEJclTFj3bkiAoX+IXq1C/E2PNA2X5FzranmkKpNahXp8EVnHB+2w1xlvBz6jDfTj 5tFIC+PCeg9iyNVYAOJV0CckG5f/RxfhUAn2K2SDpH8bPYcc8gH999DnQHZCc8X7KMCA2hiwvw YXqB5FWpwilYGEl0UwgNIr5PlXI2flawlvb5AEDUXNE4nLw6Qgm1jD5U9OSClyDDHhAwoJWqDN ArLIFanoqC3QBZxcndKGCj5E0cdAAYXk8O9C3mqzJfWUWffMusuvoyKna40GAyars+hJYX4HGn uzA= X-SBRS: 2.7 X-MesageID: 1239336 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 23.29.105.83 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.60,546,1549947600"; d="scan'208";a="1239336" From: Andrew Cooper To: Xen-devel Date: Mon, 3 Jun 2019 13:25:27 +0100 Message-ID: <1559564728-17167-5-git-send-email-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1559564728-17167-1-git-send-email-andrew.cooper3@citrix.com> References: <1559564728-17167-1-git-send-email-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 4/5] xen/vm-event: Fix interactions with the vcpu list 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: Petre Pircalabu , Andrew Cooper , Tamas K Lengyel , Razvan Cojocaru Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" vm_event_resume() should use domain_vcpu(), rather than opencoding it without its Spectre v1 safety. vm_event_wake_blocked() can't ever be invoked in a case where d->vcpu is NULL, so drop the outer if() and reindent, fixing up style issues. The comment, which is left alone, is false. This algorithm still has starvation issues when there is an asymetric rate of generated events. However, the existing logic is sufficiently complicated and fragile that I don't think I've followed it fully, and because we're trying to obsolete this interface, the safest course of action is to leave it alone, rather than to end up making things subtly different. Therefore, no practical change that callers would notice. Signed-off-by: Andrew Cooper Acked-by: Razvan Cojocaru --- CC: Razvan Cojocaru CC: Tamas K Lengyel CC: Petre Pircalabu --- xen/common/vm_event.c | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/xen/common/vm_event.c b/xen/common/vm_event.c index dcba98c..72f42b4 100644 --- a/xen/common/vm_event.c +++ b/xen/common/vm_event.c @@ -119,34 +119,29 @@ static unsigned int vm_event_ring_available(struct vm= _event_domain *ved) static void vm_event_wake_blocked(struct domain *d, struct vm_event_domain= *ved) { struct vcpu *v; - unsigned int avail_req =3D vm_event_ring_available(ved); + unsigned int i, j, k, avail_req =3D vm_event_ring_available(ved); =20 if ( avail_req =3D=3D 0 || ved->blocked =3D=3D 0 ) return; =20 /* We remember which vcpu last woke up to avoid scanning always linear= ly * from zero and starving higher-numbered vcpus under high load */ - if ( d->vcpu ) + for ( i =3D ved->last_vcpu_wake_up + 1, j =3D 0; j < d->max_vcpus; i++= , j++ ) { - int i, j, k; - - for (i =3D ved->last_vcpu_wake_up + 1, j =3D 0; j < d->max_vcpus; = i++, j++) - { - k =3D i % d->max_vcpus; - v =3D d->vcpu[k]; - if ( !v ) - continue; + k =3D i % d->max_vcpus; + v =3D d->vcpu[k]; + if ( !v ) + continue; =20 - if ( !(ved->blocked) || avail_req =3D=3D 0 ) - break; + if ( !ved->blocked || avail_req =3D=3D 0 ) + break; =20 - if ( test_and_clear_bit(ved->pause_flag, &v->pause_flags) ) - { - vcpu_unpause(v); - avail_req--; - ved->blocked--; - ved->last_vcpu_wake_up =3D k; - } + if ( test_and_clear_bit(ved->pause_flag, &v->pause_flags) ) + { + vcpu_unpause(v); + avail_req--; + ved->blocked--; + ved->last_vcpu_wake_up =3D k; } } } @@ -382,11 +377,10 @@ static int vm_event_resume(struct domain *d, struct v= m_event_domain *ved) } =20 /* Validate the vcpu_id in the response. */ - if ( (rsp.vcpu_id >=3D d->max_vcpus) || !d->vcpu[rsp.vcpu_id] ) + v =3D domain_vcpu(d, rsp.vcpu_id); + if ( !v ) continue; =20 - v =3D d->vcpu[rsp.vcpu_id]; - /* * In some cases the response type needs extra handling, so here * we call the appropriate handlers. --=20 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Fri Apr 26 19:02:43 2024 Delivered-To: importer@patchew.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=1559564946; cv=none; d=zoho.com; s=zohoarc; b=K8EvV+MlUt3fycdAYfa4IDNm5Q6LkbaWD50SexZOe4ehHqnjU86aIqRNxnPnWW6/ZhC6D6WNV0kwWZyOAPp1duyYrBYHdz4GD3x5e65wMH3UAuiHPqarqZLUEiKgwMoL4/xv9bqtMsGtHEUiJBRguBblv9GMzELg9mKyMnlhaQQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559564946; 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=o8lHBpuSRNDE8GOJEcm0qzXr9lrwurU3B6TeJaZtS0g=; b=nCln7SgNtB3tSKwtJivseZrgSIM4+UCmr13f8f86PS3KTTn+PvBFu32a9qbbcBhYHG5BBCdk7mZDKxdR3NViFaynkvevhsbxqeEBBiwaq9XNUBP+70065PFOvu0LQP5jb6H+9rckFFeELiNIZkp+gWv2rO09S6CQWWrdaShYq1A= 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 1559564946416788.7136221477754; Mon, 3 Jun 2019 05:29:06 -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 1hXm42-0002pO-CX; Mon, 03 Jun 2019 12:27:46 +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 1hXm41-0002p0-P7 for xen-devel@lists.xenproject.org; Mon, 03 Jun 2019 12:27:45 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id fb22be3a-85fa-11e9-ba71-1f5b6f9313ca; Mon, 03 Jun 2019 12:27:41 +0000 (UTC) X-Inumbo-ID: fb22be3a-85fa-11e9-ba71-1f5b6f9313ca Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=andrew.cooper3@citrix.com; spf=Pass smtp.mailfrom=Andrew.Cooper3@citrix.com; spf=None smtp.helo=postmaster@MIAPEX02MSOL02.citrite.net 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; Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of andrew.cooper3@citrix.com) identity=pra; client-ip=23.29.105.83; receiver=esa1.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.hc3370-68.iphmx.com: domain of Andrew.Cooper3@citrix.com designates 23.29.105.83 as permitted sender) identity=mailfrom; client-ip=23.29.105.83; receiver=esa1.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="Andrew.Cooper3@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:23.29.105.83 ip4:162.221.156.50 ~all" Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@MIAPEX02MSOL02.citrite.net) identity=helo; client-ip=23.29.105.83; receiver=esa1.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@MIAPEX02MSOL02.citrite.net"; x-conformance=sidf_compatible IronPort-SDR: DweiCrYQeE4cT185dbySV23iWYvyc3jibeFufp59nS06RT/tV4GtkyzaJ+M4WcNdFnKlKBe2fM D+ggoHYh/8Mdp6pqpKVs9Uc9brn+QwVcrkBITcHJLSXv9iQcdrcQC3VS2JBymRdfCDF/GMTDtp JkViCywafm0bmN0Jz6hJBqTTb5SFLzB3YZoynwSKbYTHZimvtdK3RYHkok2fv3IL7uQLjsXN1a Vpy2nUw05VUJxaHQJeGSFup5+uW3VTF86rkQ0Q2Ij7w1GsecYNhzeeI3om9Mwd78XoyVGaHdxU n5g= X-SBRS: 2.7 X-MesageID: 1239386 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 23.29.105.83 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.60,546,1549947600"; d="scan'208";a="1239386" From: Andrew Cooper To: Xen-devel Date: Mon, 3 Jun 2019 13:25:28 +0100 Message-ID: <1559564728-17167-6-git-send-email-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1559564728-17167-1-git-send-email-andrew.cooper3@citrix.com> References: <1559564728-17167-1-git-send-email-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 5/5] xen/vm-event: Misc fixups 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: Petre Pircalabu , Andrew Cooper , Tamas K Lengyel , Razvan Cojocaru Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" * Drop redundant brackes, and inline qualifiers. * Insert newlines and spaces where appropriate. * Drop redundant NDEBUG - gdprint() is already conditional. Fix the logging level, as gdprintk() already prefixes the guest marker. No functional change. Signed-off-by: Andrew Cooper Acked-by: Razvan Cojocaru --- CC: Razvan Cojocaru CC: Tamas K Lengyel CC: Petre Pircalabu --- xen/common/vm_event.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/xen/common/vm_event.c b/xen/common/vm_event.c index 72f42b4..e872680 100644 --- a/xen/common/vm_event.c +++ b/xen/common/vm_event.c @@ -102,6 +102,7 @@ static int vm_event_enable( static unsigned int vm_event_ring_available(struct vm_event_domain *ved) { int avail_req =3D RING_FREE_REQUESTS(&ved->front_ring); + avail_req -=3D ved->target_producers; avail_req -=3D ved->foreign_producers; =20 @@ -168,7 +169,7 @@ static void vm_event_wake_queued(struct domain *d, stru= ct vm_event_domain *ved) */ void vm_event_wake(struct domain *d, struct vm_event_domain *ved) { - if (!list_empty(&ved->wq.list)) + if ( !list_empty(&ved->wq.list) ) vm_event_wake_queued(d, ved); else vm_event_wake_blocked(d, ved); @@ -216,8 +217,8 @@ static int vm_event_disable(struct domain *d, struct vm= _event_domain **p_ved) return 0; } =20 -static inline void vm_event_release_slot(struct domain *d, - struct vm_event_domain *ved) +static void vm_event_release_slot(struct domain *d, + struct vm_event_domain *ved) { /* Update the accounting */ if ( current->domain =3D=3D d ) @@ -258,17 +259,16 @@ void vm_event_put_request(struct domain *d, RING_IDX req_prod; struct vcpu *curr =3D current; =20 - if( !vm_event_check_ring(ved)) + if( !vm_event_check_ring(ved) ) return; =20 if ( curr->domain !=3D d ) { req->flags |=3D VM_EVENT_FLAG_FOREIGN; -#ifndef NDEBUG + if ( !(req->flags & VM_EVENT_FLAG_VCPU_PAUSED) ) - gdprintk(XENLOG_G_WARNING, "d%dv%d was not paused.\n", + gdprintk(XENLOG_WARNING, "d%dv%d was not paused.\n", d->domain_id, req->vcpu_id); -#endif } =20 req->version =3D VM_EVENT_INTERFACE_VERSION; @@ -474,6 +474,7 @@ static int vm_event_grab_slot(struct vm_event_domain *v= ed, int foreign) static int vm_event_wait_try_grab(struct vm_event_domain *ved, int *rc) { *rc =3D vm_event_grab_slot(ved, 0); + return *rc; } =20 @@ -481,13 +482,15 @@ static int vm_event_wait_try_grab(struct vm_event_dom= ain *ved, int *rc) static int vm_event_wait_slot(struct vm_event_domain *ved) { int rc =3D -EBUSY; + wait_event(ved->wq, vm_event_wait_try_grab(ved, &rc) !=3D -EBUSY); + return rc; } =20 bool vm_event_check_ring(struct vm_event_domain *ved) { - return (ved && ved->ring_page); + return ved && ved->ring_page; } =20 /* @@ -511,7 +514,7 @@ int __vm_event_claim_slot(struct domain *d, struct vm_e= vent_domain *ved, if ( (current->domain =3D=3D d) && allow_sleep ) return vm_event_wait_slot(ved); else - return vm_event_grab_slot(ved, (current->domain !=3D d)); + return vm_event_grab_slot(ved, current->domain !=3D d); } =20 #ifdef CONFIG_HAS_MEM_PAGING --=20 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel