From patchwork Fri Jan 10 13:28:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Jackson X-Patchwork-Id: 11327399 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 5356013A0 for ; Fri, 10 Jan 2020 13:30:22 +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 2FD952077C for ; Fri, 10 Jan 2020 13:30:22 +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="CoOxXmgy" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2FD952077C 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 1ipuM7-0002Fr-Tu; Fri, 10 Jan 2020 13:29:39 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ipuM5-0002EJ-Uf for xen-devel@lists.xenproject.org; Fri, 10 Jan 2020 13:29:37 +0000 X-Inumbo-ID: 34809728-33ad-11ea-b89f-bc764e2007e4 Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 34809728-33ad-11ea-b89f-bc764e2007e4; Fri, 10 Jan 2020 13:29:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1578662959; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=P6HFqP1Bjv37yEk837tA9BxuNXZT5/Uewndbv9FiUBA=; b=CoOxXmgy3N+GVsjQefNZaru6CckksUWhAqfRpZ9Cm5vIn+7opsZDH5uU EMtkLn/V0xjZOgFX5HxwIjKunLHq84Kwf27Yy4M0ofQ3466rshrrLRrIt baEvLJp7AWf+aPCGzB/6rel2cvdVm/oc9JQYwJMcsBCUrw5ezEOzDzBBQ A=; Authentication-Results: esa3.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 (esa3.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=esa3.hc3370-68.iphmx.com; envelope-from="Ian.Jackson@citrix.com"; x-sender="ian.jackson@eu.citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa3.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=esa3.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 (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="Ian.Jackson@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: 6yvIYErgDqYk+bCXVG9HVDbE0PX44AWuDemAkyHO3KUcPuPyAF6H1zyDOnoVwV3nmLWcLTQCsR U9YFXIGzjNkl8NykNFZEy9dbOBbEG7XuJgJwdz2ghRHggH6TyQuiem0xcvfILBX1FWd8/py9I5 S1VHybxqy1FauJStlzqwzhpMVcIaIkOCurnoeh4GMWdtAUO/zFx8flk8PhQzPosyE8m2NS0VZ+ Eb3V5YkLHk1PCDeiv8yGcSP0R7qblwXnvA8QwueIKnKtVXn8vWz/FrUJaQH1JqOsQge3tUM743 avo= X-SBRS: 2.7 X-MesageID: 10724856 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.69,417,1571716800"; d="scan'208";a="10724856" From: Ian Jackson To: Date: Fri, 10 Jan 2020 13:28:59 +0000 Message-ID: <20200110132902.29295-6-ian.jackson@eu.citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200110132902.29295-1-ian.jackson@eu.citrix.com> References: <20200110132902.29295-1-ian.jackson@eu.citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 5/8] libxl: event: poller pipe optimisation 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 , Ian Jackson , George Dunlap , Wei Liu Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Track in userland whether the poller pipe is nonempty. This saves us writing many many bytes to the pipe if nothing ever reads them. This is going to be relevant in a moment, where we are going to create a situation where this will happen quite a lot. Signed-off-by: Ian Jackson --- tools/libxl/libxl_event.c | 2 ++ tools/libxl/libxl_internal.h | 1 + 2 files changed, 3 insertions(+) diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c index 18db091a6e..05559cad9a 100644 --- a/tools/libxl/libxl_event.c +++ b/tools/libxl/libxl_event.c @@ -1319,6 +1319,7 @@ static void afterpoll_internal(libxl__egc *egc, libxl__poller *poller, } 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(egc, "read wakeup", e, 0); } @@ -1713,6 +1714,7 @@ void libxl__poller_put(libxl_ctx *ctx, libxl__poller *p) void libxl__poller_wakeup(libxl__egc *egc, libxl__poller *p) { + if (p->pipe_nonempty++) return; int e = libxl__self_pipe_wakeup(p->wakeup_pipe[1]); if (e) LIBXL__EVENT_DISASTER(egc, "cannot poke watch pipe", e, 0); } diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index b9c4031863..baf7509b1e 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -625,6 +625,7 @@ struct libxl__poller { int (*fd_rindices)[3]; /* see libxl_event.c:beforepoll_internal */ int wakeup_pipe[2]; /* 0 means no fd allocated */ + bool pipe_nonempty; /* * We also use the poller to record whether any fds have been