From nobody Fri Apr 26 05:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=eu.citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1578935374; cv=none; d=zohomail.com; s=zohoarc; b=fVVkO1XHGQoTb2mODHU+uV3hkqF1d3bvoDK9XGLjfMffGDhPLvagoYb8EcMuCRmMoenraIhnCLkc2lqaFqLIQxjeRVUqpKL43N8HEPvBfzhic6da0puCn4wdwPpDWMX0vpEMV0HiVfbr8P1BOJaT27AzuKVP+/L39eAqd0bl0QI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578935374; 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; bh=oF9HSi/wErUPS9iJzowXf8NBtKTj23pEyJ5kOO+OR4c=; b=CZkV7/QEhKKxcTqgXUZKU4gZg7kAPPrCTc6mzaSSagJBXCpnHn3dbnEDbGIK2Api8OZa2rIBsgdqX4j89izfN70d8Sy2TSipx4Ujy71Aci0n3jrUGf1HoGdVdI4oTCudIYJu9NdF08IHzbRPjlT59uAJoEWJAXUQKPyLUaKBfrI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none 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 1578935374129596.0099088520511; Mon, 13 Jan 2020 09:09:34 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ir3Cz-0008Eq-Ex; Mon, 13 Jan 2020 17:08:57 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ir3Cy-0008EJ-Ih for xen-devel@lists.xenproject.org; Mon, 13 Jan 2020 17:08:56 +0000 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 5c9ee418-3627-11ea-a2eb-bc764e2007e4; Mon, 13 Jan 2020 17:08:47 +0000 (UTC) X-Inumbo-ID: 5c9ee418-3627-11ea-a2eb-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1578935327; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=QeHPkOUBfk70JdbVTXptof0PmHLZHWYWptt6avVA7Sg=; b=fIlhzGao/DR48mEzXi0QPXGRtN5+ieIA0ordaVrzQonQYB7MA19ZuklP aTHRVZeoc6ZMoJWtZpE9om9PeQXdM6tNPrXn2xp7/Wr/b665NoBtwkblb XwpiDzaBC+BBrflJAkmSb75oqX5ZQLvSZYLwokTDtofn6HlmUITgThkPl A=; Authentication-Results: esa6.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 (zohomail.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 (esa6.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=esa6.hc3370-68.iphmx.com; envelope-from="Ian.Jackson@citrix.com"; x-sender="ian.jackson@eu.citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa6.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=esa6.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 (esa6.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=esa6.hc3370-68.iphmx.com; envelope-from="Ian.Jackson@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: FICjr7eLRS4XokLeFEdE6asDfkAHVzHp7LH1ajveyJTdB0hnhlfk40RhCO2b1a1jLGsaoKsqop L1aMzbs3OaCD3mPuEANeRG7xvT2EplVN016hFT8pRgep3c3y4vCbjnEu90AklQQDnqPiWagKQi Pvyzw50J5GzxQ1qpa0Js/hUbqSEEPXWzmZRI6xMLlpOOsdAIjXO9Ld+pi8qnJW18xy89p8wIKb uM0+B/C937WGGu1x4y6o+pNhvGp0/x4ZCyV3qn3Dw2VGm7ZG1n+hz4exnm4sbRniyxq3mCkCpm CTk= X-SBRS: 2.7 X-MesageID: 11275255 X-Ironport-Server: esa6.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="11275255" From: Ian Jackson To: Date: Mon, 13 Jan 2020 17:08:34 +0000 Message-ID: <20200113170843.21332-2-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 01/10] libxl: event: Rename poller.fds_changed to .fds_deregistered 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This is only for deregistration. We are going to add another variable for new events, with different semantics, and this overly-general name will become confusing. Signed-off-by: Ian Jackson Reviewed-by: George Dunlap Tested-by: George Dunlap --- tools/libxl/libxl_event.c | 8 ++++---- tools/libxl/libxl_internal.h | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c index aa8b7d1945..1210c1bfb3 100644 --- a/tools/libxl/libxl_event.c +++ b/tools/libxl/libxl_event.c @@ -239,7 +239,7 @@ void libxl__ev_fd_deregister(libxl__gc *gc, libxl__ev_f= d *ev) ev->fd =3D -1; =20 LIBXL_LIST_FOREACH(poller, &CTX->pollers_fds_changed, fds_changed_entr= y) - poller->fds_changed =3D 1; + poller->fds_deregistered =3D 1; =20 out: CTX_UNLOCK; @@ -1120,7 +1120,7 @@ static int beforepoll_internal(libxl__gc *gc, libxl__= poller *poller, =20 *nfds_io =3D used; =20 - poller->fds_changed =3D 0; + poller->fds_deregistered =3D 0; =20 libxl__ev_time *etime =3D LIBXL_TAILQ_FIRST(&CTX->etimes); if (etime) { @@ -1186,7 +1186,7 @@ static int afterpoll_check_fd(libxl__poller *poller, /* again, stale slot entry */ continue; =20 - assert(poller->fds_changed || !(fds[slot].revents & POLLNVAL)); + assert(poller->fds_deregistered || !(fds[slot].revents & POLLNVAL)= ); =20 /* we mask in case requested events have changed */ int slot_revents =3D fds[slot].revents & events; @@ -1626,7 +1626,7 @@ int libxl__poller_init(libxl__gc *gc, libxl__poller *= p) int rc; p->fd_polls =3D 0; p->fd_rindices =3D 0; - p->fds_changed =3D 0; + p->fds_deregistered =3D 0; =20 rc =3D libxl__pipe_nonblock(CTX, p->wakeup_pipe); if (rc) goto out; diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index ba8c9b41ab..c5b71d15f0 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -629,14 +629,14 @@ struct libxl__poller { /* * We also use the poller to record whether any fds have been * deregistered since we entered poll. Each poller which is not - * idle is on the list pollers_fds_changed. fds_changed is + * idle is on the list pollers_fds_changed. fds_deregistered is * cleared by beforepoll, and tested by afterpoll. Whenever an fd - * event is deregistered, we set the fds_changed of all non-idle + * event is deregistered, we set the fds_deregistered of all non-idle * pollers. So afterpoll can tell whether any POLLNVAL is * plausibly due to an fd being closed and reopened. */ LIBXL_LIST_ENTRY(libxl__poller) fds_changed_entry; - bool fds_changed; + bool fds_deregistered; }; =20 struct libxl__gc { --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Fri Apr 26 05:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=eu.citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1578935374; cv=none; d=zohomail.com; s=zohoarc; b=IeSsWKU/opwii6mmzcxNXfeiMLlTzD24NmRE4nJMjqu9qHn1BNEXPDFWXSZ2rTEGDUBKHL457uxQ2BYv5mU3OoZQoT2cpzSfP4l3xEG6/zY67CmtF5AhaCdDIHdVV/h1YMNOQZ3hJzuNzodLVPK8VWXCFKWbS+bAP+Rzg+pDMpY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578935374; 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; bh=vXqlubajj7lYwkU6skp/8zCbJzGzvG1RCTxfamXj2zU=; b=gIqmD3uMVd1iCn5SCJWmdU1ZZmZy0iX2pYFxmJL7zltMz+Idf+6KZ6GvsllDShUqouH5oHkUhUlw2nYqVujQFH1U4xzKjCIuyXBxRlNS/oH9yKDbiXjNbraVgZwY26wg84o1fl4E9NkSYteMa2GGJ8cbOBlo0q1mazOdUV0G57w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none 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 1578935374005205.68305017440161; Mon, 13 Jan 2020 09:09:34 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ir3D4-0008HP-C9; Mon, 13 Jan 2020 17:09:02 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ir3D3-0008Gy-G5 for xen-devel@lists.xenproject.org; Mon, 13 Jan 2020 17:09:01 +0000 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 5cf0b54a-3627-11ea-a985-bc764e2007e4; Mon, 13 Jan 2020 17:08:48 +0000 (UTC) X-Inumbo-ID: 5cf0b54a-3627-11ea-a985-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1578935328; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=/5wulVWsdwFhm+h/O97CX626cu5GEU2I6i0AP03/ttE=; b=RN5MrMcN/opYZoSk6RmOMeRCMWvsKBWKLxum7uPIzijUk+rZ9Bh8Nu6r H0e29BiHrVMO66WJz4bBEjuhKLep5pv5ZiqFYEsaoY1UnkL8h6dwDJZHx UYfetF+zeP9RnHjzjuW78W1yzVdXNAP8HGHLb7vGKZtGJS7U5UwFOFkEF M=; 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 (zohomail.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 (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: 8vpakQDzgTYjdI6sgOaQzkhS0mNiidFH3GC5iZWiffOqv4VTm5K7akuZpTP4rIRlkoeaEs07J4 Q8IChD4IlCwWWoCLSLH5J7wVvmkzIG3Qs/Bh9TCOXHS28VvNbEcc69Ak5ZL1rqmrsNjegpCVWk tueRfMHXe+nVAp3uJHhxG2rQnCLgrpEVs0eevooPtT3EXryYUc04h5U6WJo5wkeBjupzMDD97t 7svlv+nx0VBDz+ixqLc7tKKzdtFgEM7q0UTFyvQ68yBkYFAu2R5xmcQZm0id7ysxMssDxAvT4Y 74Y= X-SBRS: 2.7 X-MesageID: 10859012 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="10859012" From: Ian Jackson To: Date: Mon, 13 Jan 2020 17:08:35 +0000 Message-ID: <20200113170843.21332-3-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 02/10] libxl: event: Rename ctx.pollers_fd_changed to .pollers_active 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) We are going to use this a bit more widely. Make the name more general. Signed-off-by: Ian Jackson Reviewed-by: George Dunlap Tested-by: George Dunlap --- tools/libxl/libxl.c | 4 ++-- tools/libxl/libxl_event.c | 8 ++++---- tools/libxl/libxl_internal.h | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index a0d84281d0..f60fd3e4fd 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -48,7 +48,7 @@ int libxl_ctx_alloc(libxl_ctx **pctx, int version, ctx->poller_app =3D 0; LIBXL_LIST_INIT(&ctx->pollers_event); LIBXL_LIST_INIT(&ctx->pollers_idle); - LIBXL_LIST_INIT(&ctx->pollers_fds_changed); + LIBXL_LIST_INIT(&ctx->pollers_active); =20 LIBXL_LIST_INIT(&ctx->efds); LIBXL_TAILQ_INIT(&ctx->etimes); @@ -177,7 +177,7 @@ int libxl_ctx_free(libxl_ctx *ctx) libxl__poller_put(ctx, ctx->poller_app); ctx->poller_app =3D NULL; assert(LIBXL_LIST_EMPTY(&ctx->pollers_event)); - assert(LIBXL_LIST_EMPTY(&ctx->pollers_fds_changed)); + assert(LIBXL_LIST_EMPTY(&ctx->pollers_active)); libxl__poller *poller, *poller_tmp; LIBXL_LIST_FOREACH_SAFE(poller, &ctx->pollers_idle, entry, poller_tmp)= { libxl__poller_dispose(poller); diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c index 1210c1bfb3..5b12a45e70 100644 --- a/tools/libxl/libxl_event.c +++ b/tools/libxl/libxl_event.c @@ -238,7 +238,7 @@ void libxl__ev_fd_deregister(libxl__gc *gc, libxl__ev_f= d *ev) LIBXL_LIST_REMOVE(ev, entry); ev->fd =3D -1; =20 - LIBXL_LIST_FOREACH(poller, &CTX->pollers_fds_changed, fds_changed_entr= y) + LIBXL_LIST_FOREACH(poller, &CTX->pollers_active, active_entry) poller->fds_deregistered =3D 1; =20 out: @@ -1663,15 +1663,15 @@ libxl__poller *libxl__poller_get(libxl__gc *gc) } } =20 - LIBXL_LIST_INSERT_HEAD(&CTX->pollers_fds_changed, p, - fds_changed_entry); + LIBXL_LIST_INSERT_HEAD(&CTX->pollers_active, p, + active_entry); return p; } =20 void libxl__poller_put(libxl_ctx *ctx, libxl__poller *p) { if (!p) return; - LIBXL_LIST_REMOVE(p, fds_changed_entry); + LIBXL_LIST_REMOVE(p, active_entry); LIBXL_LIST_INSERT_HEAD(&ctx->pollers_idle, p, entry); } =20 diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index c5b71d15f0..581d64b99c 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -629,13 +629,13 @@ struct libxl__poller { /* * We also use the poller to record whether any fds have been * deregistered since we entered poll. Each poller which is not - * idle is on the list pollers_fds_changed. fds_deregistered is + * idle is on the list pollers_active. fds_deregistered is * cleared by beforepoll, and tested by afterpoll. Whenever an fd * event is deregistered, we set the fds_deregistered of all non-idle * pollers. So afterpoll can tell whether any POLLNVAL is * plausibly due to an fd being closed and reopened. */ - LIBXL_LIST_ENTRY(libxl__poller) fds_changed_entry; + LIBXL_LIST_ENTRY(libxl__poller) active_entry; bool fds_deregistered; }; =20 @@ -678,7 +678,7 @@ struct libxl__ctx { =20 libxl__poller *poller_app; /* libxl_osevent_beforepoll and _afterpoll = */ LIBXL_LIST_HEAD(, libxl__poller) pollers_event, pollers_idle; - LIBXL_LIST_HEAD(, libxl__poller) pollers_fds_changed; + LIBXL_LIST_HEAD(, libxl__poller) pollers_active; =20 LIBXL_SLIST_HEAD(libxl__osevent_hook_nexi, libxl__osevent_hook_nexus) hook_fd_nexi_idle, hook_timeout_nexi_idle; --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Fri Apr 26 05:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=eu.citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1578935380; cv=none; d=zohomail.com; s=zohoarc; b=Q5JZePzHcNuCkojeDV7U7vGiqkQUxmAJzmpL/7CkWOLKYVKA5D/OuIULdEvek+uDtkV42xTYr09sgAkE99OvZ5DJTgV1xOLpvrNOpAJhyT0tgW9LRUwCwrArylX3dshQcGhuEhrZ0y8hZ/+JcjRcejmY/Z5vBy5XDAyTmi4wrcQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578935380; 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; bh=sFDUZ3ygsqVbcL0eELXXO0gj0pTx5IZPYIKbPxxHygs=; b=SpTaEcE5GJh7fKSFNtxdusd2LQgk78hs//rhS2dZKQ5/ehH7s1wGgN7vkjBwVghkSnnlC1+4awHkT3HulSQbK0WqEc3hrrX8+gPSOgDHCe2QTY1hsjq8RWiFo7G9bC0OkoxxlBImTA/ewJzhdjwp2TkYgpTFmJF95wNu46iN78w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none 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 1578935380334848.9740680399981; Mon, 13 Jan 2020 09:09:40 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ir3DA-0008Lm-48; Mon, 13 Jan 2020 17:09:08 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ir3D8-0008KF-Fy for xen-devel@lists.xenproject.org; Mon, 13 Jan 2020 17:09:06 +0000 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 5e394bf6-3627-11ea-b89f-bc764e2007e4; Mon, 13 Jan 2020 17:08:50 +0000 (UTC) X-Inumbo-ID: 5e394bf6-3627-11ea-b89f-bc764e2007e4 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=aG8+e2m6AN5IfUjMx9VppTrvS/t/KQQmarqMBDQ8J/I=; b=WPxjf8ces8Lfll/puWv15JQXCth2OSog53gdwPYwr7mrn5W6G/XZHtzB N89UGI5KxzYW74M5LPvoFFrmCoUCLGFT+akqCEckCa0HNQWrrLqSCaQ72 iuEdg9Em+ukQm+eHEB/0f5JoOB9IGMWuaRpzk4FwoSYkBU2J4e/d5NdZn c=; 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 (zohomail.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 (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: NAXvxowJCLE4BgHLZfFansqy/MKxKqgjMZQPOmPUAHzEtf6PWaLQcMELnZL7w4RqaLeFrZNE5U 0rA2KGgPbXYAQy/r1g6jTI7FAMA7D3S58Tq8XexOjZmQhG+yOumdl8xpYBF4XPaRYU3KB6zFwk zWTionT8vccyGbFB4fCwiaJeg7NxVe8DWf+Zlp5fGx0IDPmGXAUe5NZY91m5PxnuBDsFnrSHFJ atwGftcRzREa/8OLoYzmi0J13VYNFZ2t8+m5+llbT17vrlyeunEyX1tNZpPcFTitFMj3qTyKwJ RW8= X-SBRS: 2.7 X-MesageID: 10859014 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="10859014" From: Ian Jackson To: Date: Mon, 13 Jan 2020 17:08:36 +0000 Message-ID: <20200113170843.21332-4-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 03/10] libxl: event: Introduce CTX_UNLOCK_EGC_FREE 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This is a very common exit pattern. We are going to want to change this pattern. So we should make it into a macro of its own. No functional change. Signed-off-by: Ian Jackson Reviewed-by: George Dunlap Tested-by: George Dunlap --- tools/libxl/libxl_event.c | 18 ++++++------------ tools/libxl/libxl_fork.c | 6 ++---- tools/libxl/libxl_internal.h | 2 ++ 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c index 5b12a45e70..be37e12bb0 100644 --- a/tools/libxl/libxl_event.c +++ b/tools/libxl/libxl_event.c @@ -1152,8 +1152,7 @@ int libxl_osevent_beforepoll(libxl_ctx *ctx, int *nfd= s_io, CTX_LOCK; int rc =3D beforepoll_internal(gc, ctx->poller_app, nfds_io, fds, timeout_upd, now); - CTX_UNLOCK; - EGC_FREE; + CTX_UNLOCK_EGC_FREE; return rc; } =20 @@ -1305,8 +1304,7 @@ void libxl_osevent_afterpoll(libxl_ctx *ctx, int nfds= , const struct pollfd *fds, EGC_INIT(ctx); CTX_LOCK; afterpoll_internal(egc, ctx->poller_app, nfds, fds, now); - CTX_UNLOCK; - EGC_FREE; + CTX_UNLOCK_EGC_FREE; } =20 /* @@ -1342,8 +1340,7 @@ void libxl_osevent_occurred_fd(libxl_ctx *ctx, void *= for_libxl, fd_occurs(egc, ev, revents_ign); =20 out: - CTX_UNLOCK; - EGC_FREE; + CTX_UNLOCK_EGC_FREE; } =20 void libxl_osevent_occurred_timeout(libxl_ctx *ctx, void *for_libxl) @@ -1365,8 +1362,7 @@ void libxl_osevent_occurred_timeout(libxl_ctx *ctx, v= oid *for_libxl) time_occurs(egc, ev, ERROR_TIMEDOUT); =20 out: - CTX_UNLOCK; - EGC_FREE; + CTX_UNLOCK_EGC_FREE; } =20 void libxl__event_disaster(libxl__egc *egc, const char *msg, int errnoval, @@ -1546,8 +1542,7 @@ int libxl_event_check(libxl_ctx *ctx, libxl_event **e= vent_r, EGC_INIT(ctx); CTX_LOCK; int rc =3D event_check_internal(egc, event_r, typemask, pred, pred_use= r); - CTX_UNLOCK; - EGC_FREE; + CTX_UNLOCK_EGC_FREE; return rc; } =20 @@ -1772,8 +1767,7 @@ int libxl_event_wait(libxl_ctx *ctx, libxl_event **ev= ent_r, out: libxl__poller_put(ctx, poller); =20 - CTX_UNLOCK; - EGC_FREE; + CTX_UNLOCK_EGC_FREE; return rc; } =20 diff --git a/tools/libxl/libxl_fork.c b/tools/libxl/libxl_fork.c index 0f1b6b518c..cf170b9085 100644 --- a/tools/libxl/libxl_fork.c +++ b/tools/libxl/libxl_fork.c @@ -483,8 +483,7 @@ int libxl_childproc_reaped(libxl_ctx *ctx, pid_t pid, i= nt status) assert(CTX->childproc_hooks->chldowner =3D=3D libxl_sigchld_owner_mainloop); int rc =3D childproc_reaped(egc, pid, status); - CTX_UNLOCK; - EGC_FREE; + CTX_UNLOCK_EGC_FREE; return rc; } =20 @@ -529,8 +528,7 @@ void libxl_childproc_sigchld_occurred(libxl_ctx *ctx) assert(CTX->childproc_hooks->chldowner =3D=3D libxl_sigchld_owner_mainloop); childproc_checkall(egc); - CTX_UNLOCK; - EGC_FREE; + CTX_UNLOCK_EGC_FREE; } =20 static void sigchld_selfpipe_handler(libxl__egc *egc, libxl__ev_fd *ev, diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 581d64b99c..983fffac7a 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -2363,6 +2363,8 @@ _hidden void libxl__egc_cleanup(libxl__egc *egc); =20 #define EGC_FREE libxl__egc_cleanup(egc) =20 +#define CTX_UNLOCK_EGC_FREE do{ CTX_UNLOCK; EGC_FREE; }while(0) + =20 /* * Machinery for asynchronous operations ("ao") --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Fri Apr 26 05:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=eu.citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1578935376; cv=none; d=zohomail.com; s=zohoarc; b=E7lYEr0lDUaIsSVyHJCGHXKAzKiC2cSfijY4FAa1ahx5EYUTtYMLxVK1+XIcAAEgFV1e3RVQVqLBnOUZRkHP0b7J8LRFsyev9nv2Qu3uT5B4FUzTfxFxmYiaC93h7p5I3TplMCmKym4rDKu3vIZiDTUvzXSRtkTPrEAa6BlNbP8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578935376; 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; bh=qbsajaceitlf/m941VnUWje/RM/oUco88xLmzAI92KU=; b=hKLoVyy14fIE1kOfMC9kc2S0DPl3vu8SiTFg6C36rB7FULlzeYRM3A4+LVennzHyNFjX7zmJ5M+mAhdrI45UO5xV3h+wQemgKiSAzKcN9xUpxhn8WPriCUZLNwP2ovJ9pePnqKNJWVwCsxIqAZOX4j+OD4HgkqOORN/pHSKIRcI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none 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 1578935376429829.3203023128555; Mon, 13 Jan 2020 09:09:36 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ir3D3-0008GX-0a; Mon, 13 Jan 2020 17:09:01 +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 1ir3D1-0008Fx-10 for xen-devel@lists.xenproject.org; Mon, 13 Jan 2020 17:08:59 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 5cb7a0ba-3627-11ea-82b0-12813bfff9fa; Mon, 13 Jan 2020 17:08:49 +0000 (UTC) X-Inumbo-ID: 5cb7a0ba-3627-11ea-82b0-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1578935329; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=m1yRb5jQ56G/OQcEfthUtHTUXxyE7lRmULwxO7tjDg4=; b=ABoD+zqb0+rVX6rbVPvHHxmGlvdaiaY1yTAK52dVp85ArJMb1tTYVRCy F9ulR2YF5TNiKS+s8aTxbu/g4xVQ3ZzNawS8WRSpJJMkwvd9j6TcTI88w Tc7MchTA+/TwwnwV3Hz2OuXDngXHswnlXctGuGy1yVVSWRHEVqM0wU+Vk w=; 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 (zohomail.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 (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: mf/vZrV+u695vuMPW6pdV+OMstiLCUQohAY5jL2i0i0kpj4V4adJCTkoDaeAaXk36VbvUzrRFo 5iUyb0l39Zosu/ie9nLoYV8MWZCurGSp2IS3IIw3n9NK+MtoDjwALpDKuJuXfVEmF0JdUfKSVz D9rR4F1hCehrjRkyOLd5mUcfhyZMm91ipwMw2sFZGIAAuMRpnHvu9+4w6rGiC/g3g1okq3XxcM A3tYIs7CFfaqZY/1+xvY1hwIc0pwJDQgVnqGZpYu3zN0liot7aq1czqFApzknIG2k3PHHDpvCz vzI= X-SBRS: 2.7 X-MesageID: 11009470 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="11009470" From: Ian Jackson To: Date: Mon, 13 Jan 2020 17:08:37 +0000 Message-ID: <20200113170843.21332-5-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 04/10] libxl: event: Make LIBXL__EVENT_DISASTER take a gc, not an egc 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) We are going to want to change libxl__poller_wakeup to take a gc. In theory there is a risk here that it would be called inappropriately in a future patch but this seems unlikely. Signed-off-by: Ian Jackson Tested-by: George Dunlap --- v2: New patch --- tools/libxl/libxl_aoutils.c | 2 +- tools/libxl/libxl_disk.c | 4 ++-- tools/libxl/libxl_domain.c | 2 +- tools/libxl/libxl_event.c | 21 ++++++++++----------- tools/libxl/libxl_fork.c | 11 ++++++----- tools/libxl/libxl_internal.h | 10 +++++----- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/tools/libxl/libxl_aoutils.c b/tools/libxl/libxl_aoutils.c index e24e4eed53..1be858c93c 100644 --- a/tools/libxl/libxl_aoutils.c +++ b/tools/libxl/libxl_aoutils.c @@ -282,7 +282,7 @@ static void datacopier_readable(libxl__egc *egc, libxl_= _ev_fd *ev, hupchk.revents =3D 0; r =3D poll(&hupchk, 1, 0); if (r < 0) - LIBXL__EVENT_DISASTER(egc, + LIBXL__EVENT_DISASTER(gc, "unexpected failure polling fd for datacopier eof hup check", errno, 0); if (datacopier_pollhup_handled(egc, dc, fd, hupchk.revents= , 0)) diff --git a/tools/libxl/libxl_disk.c b/tools/libxl/libxl_disk.c index 64a6691424..a463334130 100644 --- a/tools/libxl/libxl_disk.c +++ b/tools/libxl/libxl_disk.c @@ -33,7 +33,7 @@ static void disk_eject_xswatch_callback(libxl__egc *egc, = libxl__ev_xswatch *w, return; =20 if (libxl__xs_printf(gc, XBT_NULL, wpath, "")) { - LIBXL__EVENT_DISASTER(egc, "xs_write failed acknowledging eject", + LIBXL__EVENT_DISASTER(gc, "xs_write failed acknowledging eject", errno, LIBXL_EVENT_TYPE_DISK_EJECT); return; } @@ -43,7 +43,7 @@ static void disk_eject_xswatch_callback(libxl__egc *egc, = libxl__ev_xswatch *w, =20 rc =3D libxl__xs_read_checked(gc, XBT_NULL, evg->be_ptr_path, &backend= ); if (rc) { - LIBXL__EVENT_DISASTER(egc, "xs_read failed reading be_ptr_path", + LIBXL__EVENT_DISASTER(gc, "xs_read failed reading be_ptr_path", errno, LIBXL_EVENT_TYPE_DISK_EJECT); return; } diff --git a/tools/libxl/libxl_domain.c b/tools/libxl/libxl_domain.c index 5714501778..b59cc65750 100644 --- a/tools/libxl/libxl_domain.c +++ b/tools/libxl/libxl_domain.c @@ -892,7 +892,7 @@ static void domain_death_xswatch_callback(libxl__egc *e= gc, libxl__ev_xswatch *w, =20 rc =3D xc_domain_getinfolist(CTX->xch, evg->domid, nentries, domai= ninfos); if (rc =3D=3D -1) { - LIBXL__EVENT_DISASTER(egc, "xc_domain_getinfolist failed while" + LIBXL__EVENT_DISASTER(gc, "xc_domain_getinfolist failed while" " processing @releaseDomain watch event", errno, 0); goto out; diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c index be37e12bb0..16e6786889 100644 --- a/tools/libxl/libxl_event.c +++ b/tools/libxl/libxl_event.c @@ -261,7 +261,7 @@ short libxl__fd_poll_recheck(libxl__egc *egc, int fd, s= hort events) { break; assert(r<0); if (errno !=3D EINTR) { - LIBXL__EVENT_DISASTER(egc, "failed poll to check for fd", errn= o, 0); + LIBXL__EVENT_DISASTER(gc, "failed poll to check for fd", errno= , 0); return 0; } } @@ -509,14 +509,14 @@ static void watchfd_callback(libxl__egc *egc, libxl__= ev_fd *ev, EGC_GC; =20 if (revents & (POLLERR|POLLHUP)) - LIBXL__EVENT_DISASTER(egc, "unexpected poll event on watch fd", 0,= 0); + LIBXL__EVENT_DISASTER(gc, "unexpected poll event on watch fd", 0, = 0); =20 for (;;) { char **event =3D xs_check_watch(CTX->xsh); if (!event) { if (errno =3D=3D EAGAIN) break; if (errno =3D=3D EINTR) continue; - LIBXL__EVENT_DISASTER(egc, "cannot check/read watches", errno,= 0); + LIBXL__EVENT_DISASTER(gc, "cannot check/read watches", errno, = 0); return; } =20 @@ -705,7 +705,7 @@ static int evtchn_revents_check(libxl__egc *egc, int re= vents) =20 if (revents & ~POLLIN) { LOG(ERROR, "unexpected poll event on event channel fd: %x", revent= s); - LIBXL__EVENT_DISASTER(egc, + LIBXL__EVENT_DISASTER(gc, "unexpected poll event on event channel fd", 0, 0); libxl__ev_fd_deregister(gc, &CTX->evtchn_efd); return ERROR_FAIL; @@ -746,7 +746,7 @@ static void evtchn_fd_callback(libxl__egc *egc, libxl__= ev_fd *ev, if (port < 0) { if (errno =3D=3D EAGAIN) break; - LIBXL__EVENT_DISASTER(egc, + LIBXL__EVENT_DISASTER(gc, "unexpected failure fetching occurring event port number from evtchn", errno, 0); return; @@ -966,7 +966,7 @@ static void domaindeathcheck_callback(libxl__egc *egc, = libxl__ev_xswatch *w, libxl__domaindeathcheck_stop(gc,dc); =20 if (errno!=3DENOENT) { - LIBXL__EVENT_DISASTER(egc,"failed to read xenstore" + LIBXL__EVENT_DISASTER(gc,"failed to read xenstore" " for domain detach check", errno, 0); return; } @@ -1279,7 +1279,7 @@ static void afterpoll_internal(libxl__egc *egc, libxl= __poller *poller, =20 if (afterpoll_check_fd(poller,fds,nfds, poller->wakeup_pipe[0],POLLIN)= ) { int e =3D libxl__self_pipe_eatall(poller->wakeup_pipe[0]); - if (e) LIBXL__EVENT_DISASTER(egc, "read wakeup", e, 0); + if (e) LIBXL__EVENT_DISASTER(gc, "read wakeup", e, 0); } =20 for (;;) { @@ -1365,12 +1365,10 @@ void libxl_osevent_occurred_timeout(libxl_ctx *ctx,= void *for_libxl) CTX_UNLOCK_EGC_FREE; } =20 -void libxl__event_disaster(libxl__egc *egc, const char *msg, int errnoval, +void libxl__event_disaster(libxl__gc *gc, const char *msg, int errnoval, libxl_event_type type /* may be 0 */, const char *file, int line, const char *func) { - EGC_GC; - libxl__log(CTX, XTL_CRITICAL, errnoval, file, line, func, INVALID_DOMI= D, "DISASTER in event loop: %s%s%s%s", msg, @@ -1672,8 +1670,9 @@ void libxl__poller_put(libxl_ctx *ctx, libxl__poller = *p) =20 void libxl__poller_wakeup(libxl__egc *egc, libxl__poller *p) { + EGC_GC; int e =3D libxl__self_pipe_wakeup(p->wakeup_pipe[1]); - if (e) LIBXL__EVENT_DISASTER(egc, "cannot poke watch pipe", e, 0); + if (e) LIBXL__EVENT_DISASTER(gc, "cannot poke watch pipe", e, 0); } =20 /* diff --git a/tools/libxl/libxl_fork.c b/tools/libxl/libxl_fork.c index cf170b9085..9a4709b9a4 100644 --- a/tools/libxl/libxl_fork.c +++ b/tools/libxl/libxl_fork.c @@ -211,6 +211,7 @@ int libxl__carefd_fd(const libxl__carefd *cf) /* Like waitpid(,,WNOHANG) but handles all errors except ECHILD. */ static pid_t checked_waitpid(libxl__egc *egc, pid_t want, int *status) { + EGC_GC; for (;;) { pid_t got =3D waitpid(want, status, WNOHANG); if (got !=3D -1) @@ -219,7 +220,7 @@ static pid_t checked_waitpid(libxl__egc *egc, pid_t wan= t, int *status) return got; if (errno =3D=3D EINTR) continue; - LIBXL__EVENT_DISASTER(egc, "waitpid() failed", errno, 0); + LIBXL__EVENT_DISASTER(gc, "waitpid() failed", errno, 0); return 0; } } @@ -507,7 +508,7 @@ static void childproc_checkall(libxl__egc *egc) found: if (got =3D=3D -1) { LIBXL__EVENT_DISASTER - (egc, "waitpid() gave ECHILD but we have a child", + (gc, "waitpid() gave ECHILD but we have a child", ECHILD, 0); /* it must have finished but we don't know its status */ status =3D 255<<8; /* no wait.h macro for this! */ @@ -545,14 +546,14 @@ static void sigchld_selfpipe_handler(libxl__egc *egc,= libxl__ev_fd *ev, =20 if (revents & ~POLLIN) { LOG(ERROR, "unexpected poll event 0x%x on SIGCHLD self pipe", reve= nts); - LIBXL__EVENT_DISASTER(egc, + LIBXL__EVENT_DISASTER(gc, "unexpected poll event on SIGCHLD self pipe", 0, 0); } assert(revents & POLLIN); =20 int e =3D libxl__self_pipe_eatall(selfpipe); - if (e) LIBXL__EVENT_DISASTER(egc, "read sigchld pipe", e, 0); + if (e) LIBXL__EVENT_DISASTER(gc, "read sigchld pipe", e, 0); =20 if (CTX->childproc_hooks->chldowner =3D=3D libxl_sigchld_owner_libxl_always_selective_reap) { @@ -581,7 +582,7 @@ static void sigchld_selfpipe_handler(libxl__egc *egc, l= ibxl__ev_fd *ev, " libxl_childproc_hooks->reaped_callback" " (for pid=3D%lu, status=3D%d; error code %d)= ", (unsigned long)pid, status, rc); - LIBXL__EVENT_DISASTER(egc, disasterbuf, 0, 0); + LIBXL__EVENT_DISASTER(gc, disasterbuf, 0, 0); return; } } else { diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 983fffac7a..328ecf3e1e 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1281,8 +1281,8 @@ _hidden libxl_event *libxl__event_new(libxl__egc*, li= bxl_event_type, /* * In general, call this via the macro LIBXL__EVENT_DISASTER. * - * Event-generating functions may call this if they might have wanted - * to generate an event (either an internal one ie a + * Event-generating functions, or ao machinery, may call this if they + * might have wanted to generate an event (either an internal one ie a * libxl__ev_FOO_callback or an application event), but are prevented * from doing so due to eg lack of memory. * @@ -1290,12 +1290,12 @@ _hidden libxl_event *libxl__event_new(libxl__egc*, = libxl_event_type, * then crash, although it may fail (and henceforth leave things in a * state where many or all calls fail). */ -_hidden void libxl__event_disaster(libxl__egc*, const char *msg, int errno= val, +_hidden void libxl__event_disaster(libxl__gc*, const char *msg, int errnov= al, libxl_event_type type /* may be 0 */, const char *file, int line, const char *func); -#define LIBXL__EVENT_DISASTER(egc, msg, errnoval, type) \ - libxl__event_disaster(egc, msg, errnoval, type, __FILE__,__LINE__,__fu= nc__) +#define LIBXL__EVENT_DISASTER(gc, msg, errnoval, type) \ + libxl__event_disaster(gc, msg, errnoval, type, __FILE__,__LINE__,__fun= c__) =20 =20 /* Fills in, or disposes of, the resources held by, a poller whose --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Fri Apr 26 05:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=eu.citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1578935374; cv=none; d=zohomail.com; s=zohoarc; b=dRRRh1RqGjh8XdB4fkEDxaScsynuxQoLjUbao1nduSkQczh3j6ZvgKh+7pcdfhnE4bUdr0YK182D+by3O4hvbMzykHLwihZ6hVQRX9iFKKwsacMP4Y7wVsXqsB6LFoutJXM4CufAktNZ9TFVOXsWQZQ13XcJRJBlxoS+hA0OEzw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578935374; 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; bh=2UHWi20Am+cgb5zbFM/fH/0X+oUk5XD7uin7Ac80FiI=; b=Hsr0PoANEGl6BJ9FD5IcjFTW/sgnXLZRyMQhB1TrBhM6+cjubwqSeE6xmPEMIDnJv2jpSv8JOvC69NlIMin7MqZG5BJwadHgVsnNAtDIn1J7Wbfob9Uxl3WWGLEe2n7mhamNNHt9AWFm6hietYw85Cn98/59vXvwgMPH+bnYLdA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none 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 1578935374627836.643192335121; Mon, 13 Jan 2020 09:09:34 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ir3Cx-0008E0-3F; Mon, 13 Jan 2020 17:08:55 +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 1ir3Cw-0008Dv-0U for xen-devel@lists.xenproject.org; Mon, 13 Jan 2020 17:08:54 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 5cb7a0bb-3627-11ea-82b0-12813bfff9fa; Mon, 13 Jan 2020 17:08:49 +0000 (UTC) X-Inumbo-ID: 5cb7a0bb-3627-11ea-82b0-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1578935329; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=nz0uEznrsUjKsRIHJXu4bZ82O1eb9Hd8Ns9bcPj8spQ=; b=g+m0TFJpEZs4cYrzcywBItRGsR9YCxnLM3a/G05i+3xyiDzes8XTGptO JRb4ZC3RTQwQCYs/ZdZ3EDGGFTmCqKELoJ/y4M4sW5SpmVa5SQksm17wG SwPOqh8X72u+nI3q7eBhirAVOPS9diUkByP7LB6YQRzEqhpTzklK7dTCa A=; 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 (zohomail.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 (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: wQhkiBW0GpXCP44SpTvUjTYdSRn0X6dlStCZFJ5kmqrWQ5qxjzkG+Sr7CTFtP0fYGkWZXDDGTn +o+mPqt9RbxYjgZhog6mLCIb3U1TH+q2I+625uVt5DZSZTq90iWXn9CFIKzDezHEeXtJqpPMT9 Yr80no8QH17nzN2FUgeqFMvPtAIVvhPRxa+WeQDs+OvB3TKSPvpScOzJ4WnYsQ9Pe10Cwa+Lyw Sp/NCU66AwcK06UKQxaJ6eNjcoLNqoAMq5tTBctttw9b8XxSM5g1k+nvJpOXYIYkYytEo5pbKB tZI= X-SBRS: 2.7 X-MesageID: 11009471 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="11009471" From: Ian Jackson To: Date: Mon, 13 Jan 2020 17:08:38 +0000 Message-ID: <20200113170843.21332-6-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 05/10] libxl: event: Make libxl__poller_wakeup take a gc, not an egc 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) We are going to want to call this in the following situation: * We have just set up an ao, which is to call back - so a non-synchronous one. It ought not to call the application back right away, so no egc. * There is a libxl thread blocking somewhere but it is using using an out of date fd or timeout set, which does not take into account the ao we have just started. * We try to wake that thread up, but libxl__poller_wakeup fails. Signed-off-by: Ian Jackson Reviewed-by: George Dunlap Tested-by: George Dunlap --- v2: New patch --- tools/libxl/libxl_event.c | 7 +++---- tools/libxl/libxl_internal.h | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c index 16e6786889..268a5da120 100644 --- a/tools/libxl/libxl_event.c +++ b/tools/libxl/libxl_event.c @@ -1477,7 +1477,7 @@ void libxl__event_occurred(libxl__egc *egc, libxl_eve= nt *event) libxl__poller *poller; LIBXL_TAILQ_INSERT_TAIL(&CTX->occurred, event, link); LIBXL_LIST_FOREACH(poller, &CTX->pollers_event, entry) - libxl__poller_wakeup(egc, poller); + libxl__poller_wakeup(gc, poller); } } =20 @@ -1668,9 +1668,8 @@ void libxl__poller_put(libxl_ctx *ctx, libxl__poller = *p) LIBXL_LIST_INSERT_HEAD(&ctx->pollers_idle, p, entry); } =20 -void libxl__poller_wakeup(libxl__egc *egc, libxl__poller *p) +void libxl__poller_wakeup(libxl__gc *gc, libxl__poller *p) { - EGC_GC; int e =3D libxl__self_pipe_wakeup(p->wakeup_pipe[1]); if (e) LIBXL__EVENT_DISASTER(gc, "cannot poke watch pipe", e, 0); } @@ -1924,7 +1923,7 @@ void libxl__ao_complete_check_progress_reports(libxl_= _egc *egc, libxl__ao *ao) assert(ao->in_initiator); if (!ao->constructing) /* don't bother with this if we're not in the event loop */ - libxl__poller_wakeup(egc, ao->poller); + libxl__poller_wakeup(gc, ao->poller); } else if (ao->how.callback) { LOG(DEBUG, "ao %p: complete for callback", ao); LIBXL_TAILQ_INSERT_TAIL(&egc->aos_for_callback, ao, entry_for_call= back); diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 328ecf3e1e..b68ab218b6 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1311,7 +1311,7 @@ _hidden void libxl__poller_put(libxl_ctx*, libxl__pol= ler *p /* may be NULL */); =20 /* Notifies whoever is polling using p that they should wake up. * ctx must be locked. */ -_hidden void libxl__poller_wakeup(libxl__egc *egc, libxl__poller *p); +_hidden void libxl__poller_wakeup(libxl__gc *egc, libxl__poller *p); =20 /* Internal to fork and child reaping machinery */ extern const libxl_childproc_hooks libxl__childproc_default_hooks; --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Fri Apr 26 05:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=eu.citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1578935464; cv=none; d=zohomail.com; s=zohoarc; b=B/7HTQmRGfycvf7gYDIr4IWlf9Kn19b7A7mcctWTLWJGpaKOtz/xALAxlqBtEgD+9RVwIaozlODzS23cqRE+AmU2hrnBPCbJsyBqwKoHtJujvJhPD/BiCfu4M4+DQGCph4JHCSOPDvoQ+nLEnRVqoJhAkUjeHDq46RpP0IYbegU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578935464; 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; bh=4rcIFUdxIbLbfwWzzKR+lgQUaCQkZ7rkDFbbI7XS9Ak=; b=ZD4v6nuM4KZwJA+JxHrMDSu478RPCNvoivLyy8G4f24hstU1n6Jx3KgG9K025r/hRIMDtjalkLMi+j/57psquNZv9Uh3puX4neDkPxSXFVo2tZwKrIxCmf3veke0+MbivqnHeAykMnVHLJoT5cQdyby4JfcE9UXo7dV2DBtLtAo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none 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 1578935464517970.6079496573692; Mon, 13 Jan 2020 09:11:04 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ir3DG-0008Sl-MO; Mon, 13 Jan 2020 17:09:14 +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 1ir3DG-0008Rz-18 for xen-devel@lists.xenproject.org; Mon, 13 Jan 2020 17:09:14 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 5df7fffc-3627-11ea-82b0-12813bfff9fa; Mon, 13 Jan 2020 17:08:49 +0000 (UTC) X-Inumbo-ID: 5df7fffc-3627-11ea-82b0-12813bfff9fa 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=OvIA52z5IUr6U/0MlYqRVk6y9bCWkJfezM/BnDo8E60=; b=amwWs5TDJ1dQ5ACWVn0ufITXHC+kXFc1RGpraIAX2eV297Qjb04EyZNI MsStlbeDyt4+uL4vXdvCJfroe+OliN03Qb8LOInpcLUxAc63r+lE3RAtP BCHZHHZNUg3hb+tkj8lBJkt9MDJ5UfO2g7xX9CRenWd4jjw46g5R0JFqt Y=; 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 (zohomail.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 (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: wdiCFU+iqhFfSEd8Qge0nCvmK/k/qHUnxsh8EBGRUY1rCRDPU7+5VOhtVicZL+bjJGWdrL4Xrl UZmiRPPUFAlbE2d9lLZirYjreBxrrIeoAZyYR9hbSIaIK+WKPUEFEGwNjAKQbYGeT6pd/Gf6XM f6lbfg3nB9G38GvKyubVRoBLdl5Cl59SePgIcFA7RdP4RTFa2SGECUR5hUD7l0E2UViyhAyzAI qWP15UvhH5y5K5wpafmKSisSnvLDOs8eaD5Pgfxszp+ezPqm8FqB8VCIz8cMd0IerIV0vmTlce X38= X-SBRS: 2.7 X-MesageID: 11009473 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="11009473" From: Ian Jackson To: Date: Mon, 13 Jan 2020 17:08:39 +0000 Message-ID: <20200113170843.21332-7-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 06/10] libxl: event: Fix hang when mixing blocking and eventy calls 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) If the application calls libxl with ao_how=3D=3D0 and also makes calls like _occurred, libxl will sometimes get stuck. The bug happens as follows (for example): Thread A libxl_do_thing(,ao_how=3D=3D0) libxl_do_thing starts, sets up some callbacks libxl_do_thing exit path calls AO_INPROGRESS libxl__ao_inprogress goes into event loop eventloop_iteration sleeps on: - do_thing's current fd set - sigchld pipe if applicable - its poller Thread B libxl_something_occurred the something is to do with do_thing, above do_thing_next_callback does some more work do_thing_next_callback becomes interested in fd N thread B returns to application Note that nothing wakes up thread A. A is not listening on fd N. So do_thing_* will not spot when fd N signals. do_thing will not make further timely progress. If there is no timeout thread A will never wake up. The problem here occurs because thread A is waiting on an out of date osevent set. There is also the possibility that a thread might block waiting for libxl osevents but outside libxl, eg if the application used libxl_osevent_beforepoll. We will deal with that in a moment. See the big comment in libxl_event.c for a fairly formal correctness argument. This depends on libxl__egc_ao_cleanup_1_baton being called everywhere an egc or ao is disposed of. Firstly egcs: in this patch we rename libxl__egc_cleanup, which means we catch all the disposal sites. Secondly aos: these are disposed of by (i) AO_CREATE_FAIL (ii) ao__inprogress and (iii) an event which completes the ao later. (i) and (ii) we handle by adding the call to _baton. In the case of (iii) any such function must be an event-generating function so it has an egc too, so it will pass on the baton when the egc is disposed. Reported-by: George Dunlap Signed-off-by: Ian Jackson Reviewed-by: George Dunlap Tested-by: George Dunlap --- v2: Call libxl__egc_ao_cleanup_1_baton (renamed from __egc_cleanup) on all exits from ao_inprogress, even requests for async processing. Fixes a remaining instance of this bug (!) This involves disposing of ao->poller somewhat earlier. v2: New correctness arguments in libxl_event.c comment and in commit message. --- tools/libxl/libxl_event.c | 178 +++++++++++++++++++++++++++++++++++++++= +--- tools/libxl/libxl_internal.h | 33 ++++++-- 2 files changed, 194 insertions(+), 17 deletions(-) diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c index 268a5da120..b50d4e5074 100644 --- a/tools/libxl/libxl_event.c +++ b/tools/libxl/libxl_event.c @@ -37,6 +37,140 @@ static void ao__check_destroy(libxl_ctx *ctx, libxl__ao= *ao); =20 =20 /* + * osevent update baton handling + * + * We need the following property (the "unstale liveness property"): + * + * Whenever any thread is blocking in the libxl event loop[1], at + * least one thread must be using an up to date osevent set. It is OK + * for all but one threads to have stale event sets, because so long + * as one waiting thread has the right event set, any actually + * interesting event will, if nothing else, wake that "right" thread + * up. It will then make some progress and/or, if it exits, ensure + * that some other thread becomes the "right" thread. + * + * [1] TODO: Right now we are considering only the libxl event loop. + * We need to consider application event loop outside libxl too. + * + * Argument that our approach is sound: + * + * The issue we are concerned about is libxl sleeping on an out of + * date fd set, or too long a timeout, so that it doesn't make + * progress. If the property above is satisfied, then if any thread + * is waiting in libxl at least one such thread will be waiting on a + * sufficient osevent set, so any relevant osevent will wake up a + * libxl thread which will either handle the event, or arrange that at + * least one other libxl thread has the right set. + * + * There are two calls to poll in libxl: one is the fd recheck, which + * is not blocking. There is only the one blocking call, in + * eventloop_iteration. poll runs with the ctx unlocked, so osevents + * might be added after it unlocks the ctx - that is what we are + * worried about. + * + * To demonstrate that the unstale liveness property is satisfied: + * + * We define a baton holder as follows: a libxl thread is a baton + * holder if + * (a) it has an egc or an ao and holds the ctx lock, or + * (b) it has an active non-app poller and no osevents have been + * added since it released the lock, or + * (c) it has an active non-app poller which has been woken + * (by writing to its pipe), so it will not sleep + * We will maintain the invariant (the "baton invariant") that + * whenever there is any active poller, there is at least + * one baton holder. ("non-app" means simply "not poller_app".) + * + * No thread outside libxl can have an active non-app poller: pollers + * are put on the active list by poller_get which is called in three + * places: libxl_event_wait, which puts it before returning; + * libxl__ao_create but only in the synchronous case, in which case + * the poller is put before returning; and the poller_app, during + * initialisation. + * + * So any time when all libxl threads are blocking (and therefore do + * not have the ctx lock), the non-app active pollers belong to those + * threads. If at least one is a baton holder (the invariant), that + * thread has a good enough event set. + * + * Now we will demonstrate that the "baton invariant" is maintained: + * + * The rule is that any thread which might be the baton holder is + * responsible for checking that there continues to be a baton holder + * as needed. + * + * Firstly, consider the case when the baton holders (b) cease to be + * baton holders because osevents are added. + * + * There are only two kinds of osevents: timeouts and fds. Every + * other internal event source reduces to one of these eventually. + * Both of these cases are handled (in the case of fd events, add and + * modify, separately), calling pollers_note_osevent_added. + * + * This walks the poller_active list, marking the active pollers + * osevents_added=3D1. Such a poller cannot be the baton holder. But + * pollers_note_osevent_added is called only from ev_* functions, + * which are only called from event-chain libxl code: ie, code with an + * ao or an egc. So at this point we are a baton holder, and there is + * still a baton holder. + * + * Secondly, consider the case where baton holders (a) cease to be + * batton holders because they dispose of their egc or ao. We call + * libxl__egc_ao_cleanup_1_baton on every exit path. We arrange that + * everything that disposes of an egc or an ao checks that there is a + * new baton holder by calling libxl__egc_ao_cleanup_1_baton. + * + * This function handles the invariant explicitly: if we have any + * non-app active pollers it looks for one which is up to date (baton + * holder category (b)), and failing that it picks a victim to turn + * into the baton holder category (c) by waking it up. (Correctness + * depends on this function not spotting its own thread as the + * baton-holder, since it is on its way to not being the baton-holder, + * so it must be called after the poller has been put back.) + * + * Thirdly, we must consider the case (c). A thread in category (c) + * will reenter libxl when it gains the lock and necessarily then + * becomes a baton holder in category (a). + * + * So the "baton invariant" is maintained. QED. + */ +static void pollers_note_osevent_added(libxl_ctx *ctx) { + libxl__poller *poller; + LIBXL_LIST_FOREACH(poller, &ctx->pollers_active, active_entry) + poller->osevents_added =3D 1; +} + +void libxl__egc_ao_cleanup_1_baton(libxl__gc *gc) + /* Any poller we had must have been `put' already. */ +{ + libxl__poller *search, *wake=3D0; + + LIBXL_LIST_FOREACH(search, &CTX->pollers_active, active_entry) { + if (search =3D=3D CTX->poller_app) + /* This one is special. We can't give it the baton. */ + continue; + if (!search->osevents_added) + /* This poller is up to date and will wake up as needed. */ + return; + if (!wake) + wake =3D search; + } + + if (!wake) + /* no-one in libxl waiting for any events */ + return; + + libxl__poller_wakeup(gc, wake); + + wake->osevents_added =3D 0; + /* This serves to make _1_baton idempotent. It is OK even though + * that poller may currently be sleeping on only old osevents, + * because it is going to wake up because we've just prodded it, + * and it pick up new osevents on its next iteration (or pass + * on the baton). */ +} + +/* * The counter osevent_in_hook is used to ensure that the application * honours the reentrancy restriction documented in libxl_event.h. * @@ -194,6 +328,7 @@ int libxl__ev_fd_register(libxl__gc *gc, libxl__ev_fd *= ev, ev->func =3D func; =20 LIBXL_LIST_INSERT_HEAD(&CTX->efds, ev, entry); + pollers_note_osevent_added(CTX); =20 rc =3D 0; =20 @@ -214,6 +349,8 @@ int libxl__ev_fd_modify(libxl__gc *gc, libxl__ev_fd *ev= , short events) rc =3D OSEVENT_HOOK(fd,modify, noop, ev->fd, &ev->nexus->for_app_reg, = events); if (rc) goto out; =20 + if ((events & ~ev->events)) + pollers_note_osevent_added(CTX); ev->events =3D events; =20 rc =3D 0; @@ -315,6 +452,7 @@ static int time_register_finite(libxl__gc *gc, libxl__e= v_time *ev, LIBXL_TAILQ_INSERT_SORTED(&CTX->etimes, entry, ev, evsearch, /*empty*/, timercmp(&ev->abs, &evsearch->abs, >)); =20 + pollers_note_osevent_added(CTX); return 0; } =20 @@ -1121,6 +1259,7 @@ static int beforepoll_internal(libxl__gc *gc, libxl__= poller *poller, *nfds_io =3D used; =20 poller->fds_deregistered =3D 0; + poller->osevents_added =3D 0; =20 libxl__ev_time *etime =3D LIBXL_TAILQ_FIRST(&CTX->etimes); if (etime) { @@ -1442,7 +1581,7 @@ static void egc_run_callbacks(libxl__egc *egc) } } =20 -void libxl__egc_cleanup(libxl__egc *egc) +void libxl__egc_cleanup_2_ul_cb_gc(libxl__egc *egc) { EGC_GC; egc_run_callbacks(egc); @@ -1752,13 +1891,15 @@ int libxl_event_wait(libxl_ctx *ctx, libxl_event **= event_r, rc =3D eventloop_iteration(egc, poller); if (rc) goto out; =20 - /* we unlock and cleanup the egc each time we go through this loop, - * so that (a) we don't accumulate garbage and (b) any events - * which are to be dispatched by callback are actually delivered - * in a timely fashion. + /* we unlock and cleanup the egc each time we go through this + * loop, so that (a) we don't accumulate garbage and (b) any + * events which are to be dispatched by callback are actually + * delivered in a timely fashion. _1_baton will be + * called to pass the baton iff we actually leave; otherwise + * we are still carrying it. */ CTX_UNLOCK; - libxl__egc_cleanup(egc); + libxl__egc_cleanup_2_ul_cb_gc(egc); CTX_LOCK; } =20 @@ -2031,14 +2172,24 @@ int libxl__ao_inprogress(libxl__ao *ao, * synchronous cancellation ability. */ } =20 + /* The call to egc..1_baton is below, only if we are leaving. = */ CTX_UNLOCK; - libxl__egc_cleanup(&egc); + libxl__egc_cleanup_2_ul_cb_gc(&egc); CTX_LOCK; } + + /* Dispose of this early so libxl__egc_ao_cleanup_1_baton + * doesn't mistake us for a baton-holder. No-one much is + * going to look at this ao now so setting this to 0 is fine. + * We can't call _baton below _leave because _leave destroys + * our gc, which _baton needs. */ + libxl__poller_put(CTX, ao->poller); + ao->poller =3D 0; } else { rc =3D 0; } =20 + libxl__egc_ao_cleanup_1_baton(gc); ao->in_initiator =3D 0; ao__manip_leave(CTX, ao); =20 @@ -2051,6 +2202,9 @@ int libxl__ao_inprogress(libxl__ao *ao, static int ao__abort(libxl_ctx *ctx, libxl__ao *parent) /* Temporarily unlocks ctx, which must be locked exactly once on entry. */ { + libxl__egc egc; + LIBXL_INIT_EGC(egc,ctx); + int rc; ao__manip_enter(parent); =20 @@ -2071,9 +2225,6 @@ static int ao__abort(libxl_ctx *ctx, libxl__ao *paren= t) =20 /* We keep calling abort hooks until there are none left */ while (!LIBXL_LIST_EMPTY(&parent->abortables)) { - libxl__egc egc; - LIBXL_INIT_EGC(egc,ctx); - assert(!parent->complete); =20 libxl__ao_abortable *abrt =3D LIBXL_LIST_FIRST(&parent->abortables= ); @@ -2086,15 +2237,20 @@ static int ao__abort(libxl_ctx *ctx, libxl__ao *par= ent) "ao %p: abrt=3D%p: aborting", parent, abrt->ao); abrt->callback(&egc, abrt, ERROR_ABORTED); =20 + /* The call to egc..1_baton is in the out block below. */ libxl__ctx_unlock(ctx); - libxl__egc_cleanup(&egc); + libxl__egc_cleanup_2_ul_cb_gc(&egc); libxl__ctx_lock(ctx); } =20 rc =3D 0; =20 out: + libxl__egc_ao_cleanup_1_baton(&egc.gc); ao__manip_leave(ctx, parent); + /* The call to egc..2_ul_cb_gc is above. This is sufficient + * because only code inside the loop adds anything to the egc, and + * we ensures that the egc is clean when we leave the loop. */ return rc; } =20 diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index b68ab218b6..eec4bf767d 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -634,9 +634,23 @@ struct libxl__poller { * event is deregistered, we set the fds_deregistered of all non-idle * pollers. So afterpoll can tell whether any POLLNVAL is * plausibly due to an fd being closed and reopened. + * + * Additionally, we record whether any fd or time event sources + * have been registered. This is necessary because sometimes we + * need to wake up the only libxl thread stuck in + * eventloop_iteration so that it will pick up new fds or earlier + * timeouts. osevents_added is cleared by beforepoll, and set by + * fd or timeout event registration. When we are about to leave + * libxl (strictly, when we are about to give up an egc), we check + * whether there are any pollers. If there are, then at least one + * of them must have osevents_added clear. If not, we wake up the + * first one on the list. Any entry on pollers_active constitutes + * a promise to also make this check, so the baton will never be + * dropped. */ LIBXL_LIST_ENTRY(libxl__poller) active_entry; bool fds_deregistered; + bool osevents_added; }; =20 struct libxl__gc { @@ -2350,7 +2364,10 @@ _hidden libxl_device_model_version libxl__default_de= vice_model(libxl__gc *gc); LIBXL_STAILQ_INIT(&(egc).ev_immediates); \ } while(0) =20 -_hidden void libxl__egc_cleanup(libxl__egc *egc); +_hidden void libxl__egc_ao_cleanup_1_baton(libxl__gc *gc); + /* Passes the baton for added osevents. See comment for + * osevents_added in struct libxl__poller. */ +_hidden void libxl__egc_cleanup_2_ul_cb_gc(libxl__egc *egc); /* Frees memory allocated within this egc's gc, and and report all * occurred events via callback, if applicable. May reenter the * application; see restrictions above. The ctx must be UNLOCKED. */ @@ -2361,9 +2378,11 @@ _hidden void libxl__egc_cleanup(libxl__egc *egc); libxl__egc egc[1]; LIBXL_INIT_EGC(egc[0],ctx); \ EGC_GC =20 -#define EGC_FREE libxl__egc_cleanup(egc) - -#define CTX_UNLOCK_EGC_FREE do{ CTX_UNLOCK; EGC_FREE; }while(0) +#define CTX_UNLOCK_EGC_FREE do{ \ + libxl__egc_ao_cleanup_1_baton(&egc->gc); \ + CTX_UNLOCK; \ + libxl__egc_cleanup_2_ul_cb_gc(egc); \ + }while(0) =20 =20 /* @@ -2468,8 +2487,9 @@ _hidden void libxl__egc_cleanup(libxl__egc *egc); =20 #define AO_INPROGRESS ({ \ libxl_ctx *ao__ctx =3D libxl__gc_owner(&ao->gc); \ + /* __ao_inprogress will do egc..1_baton if needed */ \ CTX_UNLOCK; \ - EGC_FREE; \ + libxl__egc_cleanup_2_ul_cb_gc(egc); \ CTX_LOCK; \ int ao__rc =3D libxl__ao_inprogress(ao, \ __FILE__, __LINE__, __func__); \ @@ -2481,8 +2501,9 @@ _hidden void libxl__egc_cleanup(libxl__egc *egc); libxl_ctx *ao__ctx =3D libxl__gc_owner(&ao->gc); \ assert(rc); \ libxl__ao_create_fail(ao); \ + libxl__egc_ao_cleanup_1_baton(&egc->gc); \ libxl__ctx_unlock(ao__ctx); /* gc is now invalid */ \ - EGC_FREE; \ + libxl__egc_cleanup_2_ul_cb_gc(egc); \ (rc); \ }) =20 --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Fri Apr 26 05:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=eu.citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1578935373; cv=none; d=zohomail.com; s=zohoarc; b=CCPlUDDstX4B9hHMBYUIVjzb20+uZdf88XImWtGNn5DlqEswEaaZInuN2ox04BUlx3Gh7MLqivu2B+WkoYz6yesUQiz8RxXSQ3oKXA5HlYFMkXq/UriwsgK9y5IkUHZteve99Qe3W14NA9T+XLrktGfaYcrPRJZQgUoBJTxro4w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578935373; 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; bh=PQNqt27AWCT//QQcamvOcRHsxjXLhsf974ToZ++l7RU=; b=Lr96f/zaCWdfMzNadHoDXLg/SEhx3FsO4apTzFLdfZhK7c9mtGO4vEVGvbcvbCkIQeeFz7OoS94gzw3dtrt6JIm3PAF0nZLAg8wmLnHiIPUxmH4uKXF3c/0b9G09gSQE84dX/yl7JEDVs4KrUvnc/7Y3S4fS8FBWoSehZ5lNQnE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none 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 15789353735092.9744228088818545; Mon, 13 Jan 2020 09:09:33 -0800 (PST) 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 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) X-Inumbo-ID: 5df7fffd-3627-11ea-82b0-12813bfff9fa 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 (zohomail.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 (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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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 Tested-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, } =20 if (afterpoll_check_fd(poller,fds,nfds, poller->wakeup_pipe[0],POLLIN)= ) { + poller->pipe_nonempty =3D 0; int e =3D 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) =20 void libxl__poller_wakeup(libxl__gc *gc, libxl__poller *p) { + if (p->pipe_nonempty) return; + p->pipe_nonempty =3D 1; int e =3D 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 */ =20 int wakeup_pipe[2]; /* 0 means no fd allocated */ + bool pipe_nonempty; =20 /* * We also use the poller to record whether any fds have been --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Fri Apr 26 05:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=eu.citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1578935378; cv=none; d=zohomail.com; s=zohoarc; b=BAZ8YeZqwEtpDTWdgqiTAYT5uPypoDz/Y7mDiWZuWrL+UI8ScQilhRYYTb9TIu+zCxuh/kpE+FBkyHgC7sdvSMnHT0jyjDTDqjezDNzPi2HUV6CiNHGPkVoj6RSk9Rs+sLmdaN8FFtqDbLjDQG9JXBQtLmZZoueg2PdiB3zJZsc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578935378; 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; bh=o1gfoJblUn2qdME9ed+Udl0ByOLGmu1J4sCHNc7/tuM=; b=d3fZJYZA6gqfFiKDfp4Ac2WfJJM/57WXlQoaxBw9qoSM0SFLX1q/P3g6UO3pYLSrxqCO9qwQxQMoKP4eai48S9x2mw+DgkjWl27aCM9FIVFgUJYnm1mAa+X+SfchrMCRxAv+VAEcE6soLAb/W9z8EedtmhiDkYHZdb6vMPY/t8A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none 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 1578935378330815.5285372969911; Mon, 13 Jan 2020 09:09:38 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ir3DC-0008Oj-TG; Mon, 13 Jan 2020 17:09:10 +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 1ir3DB-0008My-1Q for xen-devel@lists.xenproject.org; Mon, 13 Jan 2020 17:09:09 +0000 Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 5dfbe8a7-3627-11ea-82b0-12813bfff9fa; Mon, 13 Jan 2020 17:08:50 +0000 (UTC) X-Inumbo-ID: 5dfbe8a7-3627-11ea-82b0-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1578935331; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=i/55sdG8xIe88aFcUASAUUGWec9k6tBxqpCiGBrwGIU=; b=N0R5WWzvTedp+Rty+f16ABmZ7ZVgALd0RA5ZfmB9RFe3LU63PnvuBdh5 bqN9693f3+WLsfvIe2FfMnrBUbKoDVDivKJ4qMoFbnqc4tMK59cgl8XMk XNhFN0xEpuVPyCiaORQB097RuVjhe+UvGFfmdbU9TdoE9vP59V7zPsqmq E=; 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 (zohomail.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 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: V7IggCX+hpcQJ1xg5arxneKMdF4QXUncrTwZnqGTFKs3pfd5Geq30vNavlBXdNOXPFX38PpCv+ XFJ9emFmzA7bDrO31udFhffEvkJJ65/U0WDOTQ9df3MKIktKES3w1godrHuUeOSnR5hGtoXqCM vlHS1K2tNUN6X4iYd9YspuJxT2Mpn0BCIZWQ2hRHL7TSuOFmWtWmUu9lwq5qR80A8+lQYPDbVp JpjDqyeu4YleAGn/bX257PtC+7LP1tx8k6wdeNamsLTqF42ilypDMMqc3F75+wlacHhCOpUHN7 188= X-SBRS: 2.7 X-MesageID: 10838969 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,429,1571716800"; d="scan'208";a="10838969" From: Ian Jackson To: Date: Mon, 13 Jan 2020 17:08:41 +0000 Message-ID: <20200113170843.21332-9-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 08/10] libxl: event: Break out baton_wake 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) No functional change. Signed-off-by: Ian Jackson Reviewed-by: George Dunlap Tested-by: George Dunlap --- v2: Now it takes a gc, not an egc. --- tools/libxl/libxl_event.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c index 3e76fa5af5..45cc67942d 100644 --- a/tools/libxl/libxl_event.c +++ b/tools/libxl/libxl_event.c @@ -140,6 +140,18 @@ static void pollers_note_osevent_added(libxl_ctx *ctx)= { poller->osevents_added =3D 1; } =20 +static void baton_wake(libxl__gc *gc, libxl__poller *wake) +{ + libxl__poller_wakeup(gc, wake); + + wake->osevents_added =3D 0; + /* This serves to make _1_baton idempotent. It is OK even though + * that poller may currently be sleeping on only old osevents, + * because it is going to wake up because we've just prodded it, + * and it pick up new osevents on its next iteration (or pass + * on the baton). */ +} + void libxl__egc_ao_cleanup_1_baton(libxl__gc *gc) /* Any poller we had must have been `put' already. */ { @@ -160,14 +172,7 @@ void libxl__egc_ao_cleanup_1_baton(libxl__gc *gc) /* no-one in libxl waiting for any events */ return; =20 - libxl__poller_wakeup(gc, wake); - - wake->osevents_added =3D 0; - /* This serves to make _1_baton idempotent. It is OK even though - * that poller may currently be sleeping on only old osevents, - * because it is going to wake up because we've just prodded it, - * and it pick up new osevents on its next iteration (or pass - * on the baton). */ + baton_wake(gc, wake); } =20 /* --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Fri Apr 26 05:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=eu.citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1578935405; cv=none; d=zohomail.com; s=zohoarc; b=H4BsYFO9paPi4RFtZLT387d5iqVwzLBB3DHa+GfNGHPNFOFR+ZpMjpr36goffaQIzNS+9ztsEOfOlodsv7YRiZEFXZcDBvIXfUgcuWoHWaIev+Z+QfDVOuw/2j/+aALhtYFvSCuByjZjC8N6kwazOTqtZND1KlXUHAUj+P5ygiw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578935405; 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; bh=XKbL2YK8Wkw3fF9BS4rBaUTjpg5buoMHnnXPijBB2qY=; b=eKGP55m+MONffYtq2IZ2WxhKU622pE53ay9UIX746QXNTUqbe94bDwTx1428IGNS0sfSh4Db2E539gMh3gtFPVH0APTftS9QyWcDe5aQGoKvavkhkHiUPVbPT1ymrrYVrPhotLWNvyBzMFwJSB/CkD5CIO0RqKKdMKUt2LuX0CA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none 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 1578935405511864.1438087728116; Mon, 13 Jan 2020 09:10:05 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ir3DM-000079-8w; Mon, 13 Jan 2020 17:09:20 +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 1ir3DL-00005p-2H for xen-devel@lists.xenproject.org; Mon, 13 Jan 2020 17:09:19 +0000 Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 5dfbe8a8-3627-11ea-82b0-12813bfff9fa; Mon, 13 Jan 2020 17:08:50 +0000 (UTC) X-Inumbo-ID: 5dfbe8a8-3627-11ea-82b0-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1578935332; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=ZHk98AbpVsUcxJqYNL9yGHsexHbThfpD0VsQHyjZp/4=; b=H9+FGMK5VOZFKWPuEtpYAPlRKEDaQKEW64nNrKCWnM3lXsrusVwJVMoa y1lOlCXMVOaaLwSQLXSv8n53XwC0Q0szQxwacd69l2y1lMs72eWqkHl3T wVlN8MK5v9Kb0N6awtDf63p0j/41iAXrfbJ4ipkNVq4KvcK5lkZ0OqKon w=; 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 (zohomail.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 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: m14wLfXMm7G5yoD2R7RSLGEFMY93wWcxO7KahnD6qi/o9v73amvspA3Gb/Eln/zbpL+1DSXR2o DxSe/dTW9XMrH0hmhBKIdckuSB4SI95a+LU/fBLYMrQbCpNteE32VU2TEYuxEIeuytq/Rg49lQ ik4Q90CXpT0Y5C03m/Z8kM6t7pgNn8CUGDcaZnbZB+O++gslGIBKgEOIP0a1fNadrUF2A533Ib 1JplpG7CHmO04U1xGydrzwCTuh/8qzjn3lbSMx0TsmRZ6vH/f0iOuaBfuYbUdhLDel8KueGRFR YnA= X-SBRS: 2.7 X-MesageID: 10838972 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,429,1571716800"; d="scan'208";a="10838972" From: Ian Jackson To: Date: Mon, 13 Jan 2020 17:08:42 +0000 Message-ID: <20200113170843.21332-10-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 09/10] libxl: event: Fix possible hang with libxl_osevent_beforepoll 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) If the application uses libxl_osevent_beforepoll, a similar hang is possible to the one described and fixed in libxl: event: Fix hang when mixing blocking and eventy calls Application behaviour would have to be fairly unusual, but it doesn't seem sensible to just leave this latent bug. We fix the latent bug by waking up the "poller_app" pipe every time we add osevents. If the application does not ever call beforepoll, we write one byte to the pipe and set pipe_nonempty and then we ignore it. We only write another byte if beforepoll is called again. Normally in an eventy program there would only be one thread calling libxl_osevent_beforepoll. The effect in such a program is to sometimes needlessly go round the poll loop again if a timeout callback becomes interested in a new osevent. We'll fix that in a moment. Signed-off-by: Ian Jackson Reviewed-by: George Dunlap Tested-by: George Dunlap --- v2: New addition to correctness arguments in libxl_event.c comment. --- tools/libxl/libxl_event.c | 54 +++++++++++++++++++++++++++++++++++++------= ---- 1 file changed, 43 insertions(+), 11 deletions(-) diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c index 45cc67942d..5f6a607d80 100644 --- a/tools/libxl/libxl_event.c +++ b/tools/libxl/libxl_event.c @@ -41,18 +41,25 @@ static void ao__check_destroy(libxl_ctx *ctx, libxl__ao= *ao); * * We need the following property (the "unstale liveness property"): * - * Whenever any thread is blocking in the libxl event loop[1], at - * least one thread must be using an up to date osevent set. It is OK - * for all but one threads to have stale event sets, because so long - * as one waiting thread has the right event set, any actually - * interesting event will, if nothing else, wake that "right" thread - * up. It will then make some progress and/or, if it exits, ensure - * that some other thread becomes the "right" thread. + * Whenever any thread is blocking as a result of being given an fd + * set or timeout by libxl, at least one thread must be using an up to + * date osevent set. It is OK for all but one threads to have stale + * event sets, because so long as one waiting thread has the right + * event set, any actually interesting event will, if nothing else, + * wake that "right" thread up. It will then make some progress + * and/or, if it exits, ensure that some other thread becomes the + * "right" thread. * - * [1] TODO: Right now we are considering only the libxl event loop. - * We need to consider application event loop outside libxl too. + * For threads blocking outside libxl and which are receiving libxl's + * fd and timeout information via the libxl_osevent_hooks callbacks, + * libxl calls this function as soon as it becomes interested. It is + * the responsiblity of a provider of these functions in a + * multithreaded environment to make arrangements to wake up event + * waiting thread(s) with stale event sets. * - * Argument that our approach is sound: + * Waiters outside libxl using _beforepoll are dealt with below. + * + * For the libxl event loop, the argument is as follows: * * The issue we are concerned about is libxl sleeping on an out of * date fd set, or too long a timeout, so that it doesn't make @@ -132,7 +139,29 @@ static void ao__check_destroy(libxl_ctx *ctx, libxl__a= o *ao); * will reenter libxl when it gains the lock and necessarily then * becomes a baton holder in category (a). * - * So the "baton invariant" is maintained. QED. + * So the "baton invariant" is maintained. + * QED (for waiters in libxl). + * + * + * For waiters outside libxl which used libxl_osevent_beforepoll + * to get the fd set: + * + * As above, adding an osevent involves having an egc or an ao. + * It sets poller->osevents_added on all active pollers. Notably + * it sets it on poller_app, which is always active. + * + * The thread which does this will dispose of its egc or ao before + * exiting libxl so it will always wake up the poller_app if the last + * call to _beforepoll was before the osevents were added. So the + * application's fd set contains at least a wakeup in the form of the + * poller_app fd. The application cannot sleep on the libxl fd set + * until it has called _afterpoll which empties the pipe, and it + * is expected to then call _beforepoll again before sleeping. + * + * So all the application's event waiting thread(s) will always have + * an up to date osevent set, and will be woken up if necessary to + * achieve this. (This is in contrast libxl's own event loop where + * only one thread need be up to date, as discussed above.) */ static void pollers_note_osevent_added(libxl_ctx *ctx) { libxl__poller *poller; @@ -157,6 +186,9 @@ void libxl__egc_ao_cleanup_1_baton(libxl__gc *gc) { libxl__poller *search, *wake=3D0; =20 + if (CTX->poller_app->osevents_added) + baton_wake(gc, CTX->poller_app); + LIBXL_LIST_FOREACH(search, &CTX->pollers_active, active_entry) { if (search =3D=3D CTX->poller_app) /* This one is special. We can't give it the baton. */ --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Fri Apr 26 05:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=eu.citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1578935395; cv=none; d=zohomail.com; s=zohoarc; b=NrPFVgi1Pw9inm044NLQMjR1Beq31s/o/pJzVsIm8xHS8Mol3NOT0cj1YTdFqIPS71BxuuNrS2fjGAArAypcTXJ3i2BD4Mm3bxhIH/vob+11xIQKiJPuKK/1tWXNQu+gRlWJbA6aD4oaSyvAoTuxSuv/127uIrmBpflwn49qfYo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578935395; 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; bh=dt4XdJb7MoIakzgEbvtNNcvjoJUiOOn+4QIYOUiGx9k=; b=E/DWYnEk08p/yBpen157NPaaT/dwuzGIgmZmtKY/hPnoC8jMcgc4rN/tdmB6ZdcDsQNQZlmtjygswx+R2pXdyXvTo8HsRdr365pPMoFYARSwdQrX/P2Y2utn3zowdp0oe45MoBi+s5SiCUpsRU3WY0EjNXKC9WaM9tamjRD32ec= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none 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 1578935395977848.4005305089465; Mon, 13 Jan 2020 09:09:55 -0800 (PST) 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 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) X-Inumbo-ID: 6270cbae-3627-11ea-a985-bc764e2007e4 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 (zohomail.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 (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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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 Reviewed-by: George Dunlap Tested-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, libx= l__poller *poller, fd_occurs(egc, efd, revents); } =20 - if (afterpoll_check_fd(poller,fds,nfds, poller->wakeup_pipe[0],POLLIN)= ) { - poller->pipe_nonempty =3D 0; - int e =3D libxl__self_pipe_eatall(poller->wakeup_pipe[0]); - if (e) LIBXL__EVENT_DISASTER(gc, "read wakeup", e, 0); - } - for (;;) { libxl__ev_time *etime =3D LIBXL_TAILQ_FIRST(&CTX->etimes); if (!etime) @@ -1473,6 +1467,12 @@ static void afterpoll_internal(libxl__egc *egc, libx= l__poller *poller, =20 time_occurs(egc, etime, ERROR_TIMEDOUT); } + + if (afterpoll_check_fd(poller,fds,nfds, poller->wakeup_pipe[0],POLLIN)= ) { + poller->pipe_nonempty =3D 0; + int e =3D libxl__self_pipe_eatall(poller->wakeup_pipe[0]); + if (e) LIBXL__EVENT_DISASTER(gc, "read wakeup", e, 0); + } } =20 void libxl_osevent_afterpoll(libxl_ctx *ctx, int nfds, const struct pollfd= *fds, --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel