From patchwork Mon Jan 13 17:08:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Jackson X-Patchwork-Id: 11330619 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 D54E214B4 for ; Mon, 13 Jan 2020 17:09:59 +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 B20A02084D for ; Mon, 13 Jan 2020 17:09:59 +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="gg6PERGG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B20A02084D 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 1ir3D7-0008JM-Ov; Mon, 13 Jan 2020 17:09:05 +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 1ir3D6-0008IT-0y for xen-devel@lists.xenproject.org; Mon, 13 Jan 2020 17:09:04 +0000 X-Inumbo-ID: 5df7fffd-3627-11ea-82b0-12813bfff9fa Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 5df7fffd-3627-11ea-82b0-12813bfff9fa; Mon, 13 Jan 2020 17:08:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1578935330; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=+J9GuTt2M+UMMzf8khubRAFfD5zoqvoWEyP+n25dPNU=; b=gg6PERGGjJiKvC04XM9+vNauAXhtdnht3YPIYfuH5TvIJfetuV5IU4pX U5t/GmBjZpRiURFeuqXZsK30nPBXV1YmxGZjwXnG45WhR8fUvO23CgaVM BwW6QjuQMD3UdJRsp/Hbqly0sWxUsz0xsvT7csX9r7vK6wHq6WqfPy4P9 g=; Authentication-Results: esa1.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 (esa1.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=esa1.hc3370-68.iphmx.com; envelope-from="Ian.Jackson@citrix.com"; x-sender="ian.jackson@eu.citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.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=esa1.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 (esa1.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=esa1.hc3370-68.iphmx.com; envelope-from="Ian.Jackson@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: mXuvZIwiT4tGYCMMLpJ+w8JR1aWZVQ/qWCxxxSLrr5Uy8Jx+8BvhqiSaC0M3rj7TTwbSh2hvk5 iXQMdwTOrZ7HGsNVc2LorHHDZ4BUWSwse2DX+8vHk8ReP69eqv6HSuankLqEsOv09k15Str2Ss G6pi0kKnBxIHVALDwQB3s/IH1Y94lxvB5pBYMxlEz01N+cGnHs851DnfiJHo4u+TD6VrGN7bN9 kFWgQAJbWLYldLi9+5hLNeEITnPNsifwhScidfY1A+Crsgw8HWTdjhq0SrXYgyApDKuR1R1mnF 81w= X-SBRS: 2.7 X-MesageID: 11009476 X-Ironport-Server: esa1.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="11009476" From: Ian Jackson To: Date: Mon, 13 Jan 2020 17:08:40 +0000 Message-ID: <20200113170843.21332-8-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 07/10] 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: Ian Jackson , George Dunlap 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 squash! libxl: event: poller pipe optimisation Reviewed-by: George Dunlap --- tools/libxl/libxl_event.c | 3 +++ tools/libxl/libxl_internal.h | 1 + 2 files changed, 4 insertions(+) diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c index b50d4e5074..3e76fa5af5 100644 --- a/tools/libxl/libxl_event.c +++ b/tools/libxl/libxl_event.c @@ -1417,6 +1417,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(gc, "read wakeup", e, 0); } @@ -1809,6 +1810,8 @@ void libxl__poller_put(libxl_ctx *ctx, libxl__poller *p) void libxl__poller_wakeup(libxl__gc *gc, libxl__poller *p) { + if (p->pipe_nonempty) return; + p->pipe_nonempty = 1; int e = libxl__self_pipe_wakeup(p->wakeup_pipe[1]); if (e) LIBXL__EVENT_DISASTER(gc, "cannot poke watch pipe", e, 0); } diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index eec4bf767d..0ab324102b 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