From patchwork Mon Jan 13 17:08:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Jackson X-Patchwork-Id: 11330629 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A558392A for ; Mon, 13 Jan 2020 17:10:14 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 80ACD2084D for ; Mon, 13 Jan 2020 17:10:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="KscGE48U" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 80ACD2084D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=eu.citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ir3DF-0008R1-A2; Mon, 13 Jan 2020 17:09:13 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ir3DD-0008PL-GA for xen-devel@lists.xenproject.org; Mon, 13 Jan 2020 17:09:11 +0000 X-Inumbo-ID: 6270cbae-3627-11ea-a985-bc764e2007e4 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 6270cbae-3627-11ea-a985-bc764e2007e4; Mon, 13 Jan 2020 17:08:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1578935337; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=sLDqHTClNnROCHsi6O1BZrcsQlEL0fvL+A+EWmDwQbI=; b=KscGE48UDKx9fM/9apGU/Uj9ZEuSVJU2j5pXiibt3uHEA8nRAF20PzVR NrjuEfgd+yUHXuhJKUjBouXmoWqYyd8rAym2XneZhxcbCmVtPlx+lhGn5 G2qHEk/s6nEzMyVhFHRlJZLt772mVTI6zK9fdMUCcsUeYz+cgUFuVszgw E=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=ian.jackson@eu.citrix.com; spf=Pass smtp.mailfrom=Ian.Jackson@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa2.hc3370-68.iphmx.com: no sender authenticity information available from domain of ian.jackson@eu.citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa2.hc3370-68.iphmx.com; envelope-from="Ian.Jackson@citrix.com"; x-sender="ian.jackson@eu.citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa2.hc3370-68.iphmx.com: domain of Ian.Jackson@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa2.hc3370-68.iphmx.com; envelope-from="Ian.Jackson@citrix.com"; x-sender="Ian.Jackson@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 ip4:168.245.78.127 ~all" Received-SPF: None (esa2.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=esa2.hc3370-68.iphmx.com; envelope-from="Ian.Jackson@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: Rl4YGquM1J4Ujo5fINEUxwlpexIL6DmoQmgYJHUgKas0SiJi4iZMQTw9/ZlxNTQr3TT3VZHVwe 5axQjJ+VGRvVV42HAdWEh69IGnajboy0ISxkY3U8qz1egOYEDgmH7mdVmexaFrS106FjUp8qpN EMrrKRcNQPKq2AKAR6nNHqs7JOD00yZNsP7clayVzaWmCzcgiiAYoWv7h9XMZ+0ZAFprRGrrfe 6V4/24FsyKa29PJ0p/kk7kZdOR/dQbhjpe3Ldlj0iJsbcBWrhev6Kxbhh56i9SYZwlKTT9U3pB oD8= X-SBRS: 2.7 X-MesageID: 10859017 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.69,429,1571716800"; d="scan'208";a="10859017" From: Ian Jackson To: Date: Mon, 13 Jan 2020 17:08:43 +0000 Message-ID: <20200113170843.21332-11-ian.jackson@eu.citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200113170843.21332-1-ian.jackson@eu.citrix.com> References: <20200113170843.21332-1-ian.jackson@eu.citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v2 10/10] libxl: event: Move poller pipe emptying to the end of afterpoll 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: Ian Jackson , George Dunlap Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" If a timer event callback causes this poller to be woken (not very unlikely) we would go round the poll loop twice rather than once. Do the poller pipe emptying at the end; this is slightly more efficient because it can't cause any callbacks, so it happens after all the callbacks have been run. (This pipe-emptying has to happen in afterpoll rather than the apparently more logical beforepoll, because the application calling beforepoll doesn't constitute a promise to actually do anything.) Signed-off-by: Ian Jackson Signed-off-by: Ian Jackson Tested-by: George Dunlap Reviewed-by: George Dunlap --- tools/libxl/libxl_event.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c index 5f6a607d80..7c5387e94f 100644 --- a/tools/libxl/libxl_event.c +++ b/tools/libxl/libxl_event.c @@ -1453,12 +1453,6 @@ static void afterpoll_internal(libxl__egc *egc, libxl__poller *poller, fd_occurs(egc, efd, revents); } - if (afterpoll_check_fd(poller,fds,nfds, poller->wakeup_pipe[0],POLLIN)) { - poller->pipe_nonempty = 0; - int e = libxl__self_pipe_eatall(poller->wakeup_pipe[0]); - if (e) LIBXL__EVENT_DISASTER(gc, "read wakeup", e, 0); - } - for (;;) { libxl__ev_time *etime = LIBXL_TAILQ_FIRST(&CTX->etimes); if (!etime) @@ -1473,6 +1467,12 @@ static void afterpoll_internal(libxl__egc *egc, libxl__poller *poller, time_occurs(egc, etime, ERROR_TIMEDOUT); } + + if (afterpoll_check_fd(poller,fds,nfds, poller->wakeup_pipe[0],POLLIN)) { + poller->pipe_nonempty = 0; + int e = libxl__self_pipe_eatall(poller->wakeup_pipe[0]); + if (e) LIBXL__EVENT_DISASTER(gc, "read wakeup", e, 0); + } } void libxl_osevent_afterpoll(libxl_ctx *ctx, int nfds, const struct pollfd *fds,