From nobody Tue May 7 03:33:23 2024 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=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1606895360; cv=none; d=zohomail.com; s=zohoarc; b=FqJxuRvZzdZwpcjD9dc2rDD9ZGKxPW79x4BZZRuSUZfxM5R0zTfShwUiqrASl4KdLvo82dJP+8D2jZK5aXOoOkJ6EaNHIqBtpt6ZIhU9NrU2OW7NjZNtrdgGVsrXaLorBd1e/8IGinStZ3ljN6l3s19oyJTZ3PgYQcI5bTSTNGw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606895360; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=q1Dze1pG8rgwLtTU9aw5X1Gw1LFcmWyazwJ7hYALEbs=; b=ISBTKOWK068xq3KYa2TCcpl4aRM3fkzjZjBGrPNef572ndzRQy+csDaeJka3wx3aRqkt3KvQR4CQ6GL3/OBnb6Em8T26u7H8bDiaeKbcC6EMcpted+Mf2ejO18FyZhn/XfdAOVzMPrmUACuL1+WQ+H3EksU4xrt0L9hCTMUFoA0= 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=quarantine dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1606895360858913.6488838437344; Tue, 1 Dec 2020 23:49:20 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.42447.76320 (Exim 4.92) (envelope-from ) id 1kkMsi-00014Y-QR; Wed, 02 Dec 2020 07:48:56 +0000 Received: by outflank-mailman (output) from mailman id 42447.76320; Wed, 02 Dec 2020 07:48:56 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kkMsi-00014R-NL; Wed, 02 Dec 2020 07:48:56 +0000 Received: by outflank-mailman (input) for mailman id 42447; Wed, 02 Dec 2020 07:48:55 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kkMsh-00014M-Kl for xen-devel@lists.xenproject.org; Wed, 02 Dec 2020 07:48:55 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id a8c4eed8-3b31-459f-825d-5a256df6ba8b; Wed, 02 Dec 2020 07:48:54 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id F383CAC2D; Wed, 2 Dec 2020 07:48:53 +0000 (UTC) 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: a8c4eed8-3b31-459f-825d-5a256df6ba8b X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1606895334; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=q1Dze1pG8rgwLtTU9aw5X1Gw1LFcmWyazwJ7hYALEbs=; b=QitdUtl3wYEt1I99ljM8l5g31HPq6AdnyKgUiNgghRIoNniaM6oJCjRv8UYt+H5OJ0Sx5/ LwzcEX6WYr/Rc/bT8H5lR8WoZ18KcznB0SMWisF4W3Xziv2TxTsyS0GkxbC3nudGbqOCO+ Rjj5yfKYldc1qjjGaRNuW6T7jeM244A= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Andrew Cooper , George Dunlap , Ian Jackson , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu Subject: [PATCH v9] xen/events: do some cleanups in evtchn_fifo_set_pending() Date: Wed, 2 Dec 2020 08:48:52 +0100 Message-Id: <20201202074852.30473-1-jgross@suse.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) Content-Type: text/plain; charset="utf-8" evtchn_fifo_set_pending() can be simplified a little bit. Especially testing for the fifo control block to exist can be moved out of the main if clause of the function enabling to avoid testing the LINKED bit twice. Suggested-by: Jan Beulich Signed-off-by: Juergen Gross Reviewed-by: Jan Beulich --- V8: - new patch V9: - move test for control_block existing to after setting PENDING bit (Jan Beulich) Signed-off-by: Juergen Gross --- xen/common/event_fifo.c | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/xen/common/event_fifo.c b/xen/common/event_fifo.c index a6cca4798d..d508d57219 100644 --- a/xen/common/event_fifo.c +++ b/xen/common/event_fifo.c @@ -229,29 +229,24 @@ static void evtchn_fifo_set_pending(struct vcpu *v, s= truct evtchn *evtchn) goto done; } =20 + /* + * Control block not mapped. The guest must not unmask an + * event until the control block is initialized, so we can + * just drop the event. + */ + if ( unlikely(!v->evtchn_fifo->control_block) ) + { + printk(XENLOG_G_WARNING + "%pv has no FIFO event channel control block\n", v); + goto unlock; + } + /* * Link the event if it unmasked and not already linked. */ if ( !guest_test_bit(d, EVTCHN_FIFO_MASKED, word) && - !guest_test_bit(d, EVTCHN_FIFO_LINKED, word) ) + !guest_test_and_set_bit(d, EVTCHN_FIFO_LINKED, word) ) { - event_word_t *tail_word; - - /* - * Control block not mapped. The guest must not unmask an - * event until the control block is initialized, so we can - * just drop the event. - */ - if ( unlikely(!v->evtchn_fifo->control_block) ) - { - printk(XENLOG_G_WARNING - "%pv has no FIFO event channel control block\n", v); - goto unlock; - } - - if ( guest_test_and_set_bit(d, EVTCHN_FIFO_LINKED, word) ) - goto unlock; - /* * If this event was a tail, the old queue is now empty and * its tail must be invalidated to prevent adding an event to @@ -286,6 +281,8 @@ static void evtchn_fifo_set_pending(struct vcpu *v, str= uct evtchn *evtchn) linked =3D false; if ( q->tail ) { + event_word_t *tail_word; + tail_word =3D evtchn_fifo_word_from_port(d, q->tail); linked =3D evtchn_fifo_set_link(d, tail_word, port); } --=20 2.26.2