From nobody Mon Oct 6 22:07:07 2025 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=1561390473; cv=none; d=zoho.com; s=zohoarc; b=eC+PmvxNrcESPX66/o7qU/UXEebcDqW042l59cM9XC+mUZehQxfgZ9c2/1a1YTqsIwDqt2U3rD0M6dq8/sgNvJOgzCcMI/i9ydJ43fBBdQVuY0wQUAV7BERRxU6m3AFsqXMTEqKuDHASl9J6SQZ/laQZr+UvAfdoyQZlCaTU6bE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561390473; 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=DRPXgoCRdZwDabey9MzALTd9OmkOf+AN0PwV8m5oFgs=; b=NPt8I7BLAowqHi9y5elkKPLFekG+yDrECt8q1Y/EJe63dRMcIOeGATVprdjAe7jtJYHVXG6FCl5QWSUCQYMtXB4+/+VzVaDGranWwSYOPpnY/L/OiCkSzoqIJZfkB4m+ABdx41SOrCwMcFu+7+hgOeYk4cptseR7bUwgtPg/fB8= 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 1561390473595554.5235723324764; Mon, 24 Jun 2019 08:34:33 -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 1hfQy1-00025E-6X; Mon, 24 Jun 2019 15:33: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 1hfQxz-00024S-LI for xen-devel@lists.xenproject.org; Mon, 24 Jun 2019 15:33:11 +0000 Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 5f66962f-9695-11e9-8980-bc764e045a96; Mon, 24 Jun 2019 15:33:10 +0000 (UTC) X-Inumbo-ID: 5f66962f-9695-11e9-8980-bc764e045a96 Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=anthony.perard@citrix.com; spf=Pass smtp.mailfrom=anthony.perard@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com 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 anthony.perard@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa3.hc3370-68.iphmx.com: domain of anthony.perard@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@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:162.221.158.21 ip4:162.221.156.83 ~all" Received-SPF: None (esa3.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: 6XlC+kfUtMxsI8oTe0+5atL7DmyD1sz2vK1kvMokSAcBeJ9YpKBeTXj7eWQaYqeRNdbo2oVFc6 g/IKHty2USXEUYbu+b/4rSFnAM02FMZXjtotfE+heHswqbdgtcVhggVxETPd/V60KyvuwSkoAY YfijP97pVCWU4VfN0dtQF/9kSI70yqls3WQbdt6ax7d8MkhMDT4oBMrgEDEoRgtX+sd2EOFTic TKdSOjLQteeW8/G6N9mv2I+6AsMdOb5P7am9sHO7rL0RFoyKcjLcOtLjVSnTnFlmwgDH6tt/TS Snk= X-SBRS: 2.7 X-MesageID: 2148099 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.63,412,1557201600"; d="scan'208";a="2148099" From: Anthony PERARD To: Date: Mon, 24 Jun 2019 16:32:53 +0100 Message-ID: <20190624153257.20163-5-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190624153257.20163-1-anthony.perard@citrix.com> References: <20190624153257.20163-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PULL 4/8] xen-bus / xen-block: add support for event channel polling 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: Anthony PERARD , xen-devel@lists.xenproject.org, Peter Maydell Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Paul Durrant This patch introduces a poll callback for event channel fd-s and uses this to invoke the channel callback function. To properly support polling, it is necessary for the event channel callback function to return a boolean saying whether it has done any useful work or not. Thus xen_block_dataplane_event() is modified to directly invoke xen_block_handle_requests() and the latter only returns true if it actually processes any requests. This also means that the call to qemu_bh_schedule() is moved into xen_block_complete_aio(), which is more intuitive since the only reason for doing a deferred poll of the shared ring should be because there were previously insufficient resources to fully complete a previous poll. Signed-off-by: Paul Durrant Reviewed-by: Anthony PERARD Message-Id: <20190408151617.13025-4-paul.durrant@citrix.com> Signed-off-by: Anthony PERARD --- hw/block/dataplane/xen-block.c | 17 +++++++++-------- hw/xen/xen-bus.c | 11 +++++++++-- include/hw/xen/xen-bus.h | 2 +- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/hw/block/dataplane/xen-block.c b/hw/block/dataplane/xen-block.c index aadca75644..0f200c5fb0 100644 --- a/hw/block/dataplane/xen-block.c +++ b/hw/block/dataplane/xen-block.c @@ -318,7 +318,9 @@ static void xen_block_complete_aio(void *opaque, int re= t) } xen_block_release_request(request); =20 - qemu_bh_schedule(dataplane->bh); + if (dataplane->more_work) { + qemu_bh_schedule(dataplane->bh); + } =20 done: aio_context_release(dataplane->ctx); @@ -515,12 +517,13 @@ static int xen_block_get_request(XenBlockDataPlane *d= ataplane, */ #define IO_PLUG_THRESHOLD 1 =20 -static void xen_block_handle_requests(XenBlockDataPlane *dataplane) +static bool xen_block_handle_requests(XenBlockDataPlane *dataplane) { RING_IDX rc, rp; XenBlockRequest *request; int inflight_atstart =3D dataplane->requests_inflight; int batched =3D 0; + bool done_something =3D false; =20 dataplane->more_work =3D 0; =20 @@ -552,6 +555,7 @@ static void xen_block_handle_requests(XenBlockDataPlane= *dataplane) } xen_block_get_request(dataplane, request, rc); dataplane->rings.common.req_cons =3D ++rc; + done_something =3D true; =20 /* parse them */ if (xen_block_parse_request(request) !=3D 0) { @@ -603,10 +607,7 @@ static void xen_block_handle_requests(XenBlockDataPlan= e *dataplane) blk_io_unplug(dataplane->blk); } =20 - if (dataplane->more_work && - dataplane->requests_inflight < dataplane->max_requests) { - qemu_bh_schedule(dataplane->bh); - } + return done_something; } =20 static void xen_block_dataplane_bh(void *opaque) @@ -618,11 +619,11 @@ static void xen_block_dataplane_bh(void *opaque) aio_context_release(dataplane->ctx); } =20 -static void xen_block_dataplane_event(void *opaque) +static bool xen_block_dataplane_event(void *opaque) { XenBlockDataPlane *dataplane =3D opaque; =20 - qemu_bh_schedule(dataplane->bh); + return xen_block_handle_requests(dataplane); } =20 XenBlockDataPlane *xen_block_dataplane_create(XenDevice *xendev, diff --git a/hw/xen/xen-bus.c b/hw/xen/xen-bus.c index 2210526490..7503eea9e9 100644 --- a/hw/xen/xen-bus.c +++ b/hw/xen/xen-bus.c @@ -932,13 +932,20 @@ struct XenEventChannel { void *opaque; }; =20 +static bool xen_device_poll(void *opaque) +{ + XenEventChannel *channel =3D opaque; + + return channel->handler(channel->opaque); +} + static void xen_device_event(void *opaque) { XenEventChannel *channel =3D opaque; unsigned long port =3D xenevtchn_pending(channel->xeh); =20 if (port =3D=3D channel->local_port) { - channel->handler(channel->opaque); + xen_device_poll(channel); =20 xenevtchn_unmask(channel->xeh, port); } @@ -973,7 +980,7 @@ XenEventChannel *xen_device_bind_event_channel(XenDevic= e *xendev, =20 channel->ctx =3D ctx; aio_set_fd_handler(channel->ctx, xenevtchn_fd(channel->xeh), true, - xen_device_event, NULL, NULL, channel); + xen_device_event, NULL, xen_device_poll, channel); =20 QLIST_INSERT_HEAD(&xendev->event_channels, channel, list); =20 diff --git a/include/hw/xen/xen-bus.h b/include/hw/xen/xen-bus.h index 8183b98c7d..1c2d9dfdb8 100644 --- a/include/hw/xen/xen-bus.h +++ b/include/hw/xen/xen-bus.h @@ -119,7 +119,7 @@ void xen_device_copy_grant_refs(XenDevice *xendev, bool= to_domain, XenDeviceGrantCopySegment segs[], unsigned int nr_segs, Error **errp); =20 -typedef void (*XenEventHandler)(void *opaque); +typedef bool (*XenEventHandler)(void *opaque); =20 XenEventChannel *xen_device_bind_event_channel(XenDevice *xendev, AioContext *ctx, --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel