From nobody Tue Apr 16 04:59:29 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=1578662987; cv=none; d=zohomail.com; s=zohoarc; b=cXLx6r1BQBx6kidAyPAtbhKDbqI96vUefd+DAds6oBeg4eo7xki+bl//I27zr7RSxgh7QBc/i6NGkhES9RYDrqppSafa6bl25QwTLiFJwTTwe/JbJWmBTbmD8FknFWNFKMl/4GrKCMvwCCJm+UOHtjUdV0nD5A5jSVTBBSTCaQs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578662987; 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=Y6AXmNGQ4e05SrEzo2If4Lu+rRivO2OZRb/SNkdQ5q87NRmsv8RoJAF12ZJJh3DxNmJS7ZKrv+LVtYcqPC3bSgz1QEnTqrED8m7gDad1MV288xmMAJi0ri3+TvCEGWIEx54TfxRjpr9qQSleZ4T3nlMH6FX855jrkGC1EWe32yA= 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 1578662987820543.7320758967373; Fri, 10 Jan 2020 05:29:47 -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 1ipuLk-0001yc-B9; Fri, 10 Jan 2020 13:29:16 +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 1ipuLi-0001yV-EB for xen-devel@lists.xenproject.org; Fri, 10 Jan 2020 13:29:14 +0000 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 2de1f9fe-33ad-11ea-bf0f-12813bfff9fa; Fri, 10 Jan 2020 13:29:09 +0000 (UTC) X-Inumbo-ID: 2de1f9fe-33ad-11ea-bf0f-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1578662950; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=QeHPkOUBfk70JdbVTXptof0PmHLZHWYWptt6avVA7Sg=; b=an9QWLM9gP4evbdV0hKk+vrpWNdpE4wsL5JUP8Bpn0Hu4E1Avcfjkvw8 KmTbznnmC8qrV8bn/gwrBs2r0C1yI0iJ8MasVnJ94GSIlXuSGiVg7JCX+ m3QVNXScXELg9pZrp4KHiB9gKAk0L6hbJo40zXj7HdRTfJJvjKEZQJMPT o=; 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: 6CpU5zRGaaHI+VT/w5qCQ3Bt27sYC3t1yoTqNoBW3RBLNJyomcRBsGRbHgnsmJR7cyMBojRaZt a4BNULAAQ5UsAv8Zu27Nfc3h5gzfT0Ap2zClQD3iP5ycj3srgoOCjjFs0+i4ShLM/yKJ9K12MA JDk3rW1TrJLQ/R4RA42QZzmz8lEuLyyPQ46JT+R4I/gqWrmmSobjjvCBdhQl20V9P/3EkzuF4G mOKc+H5lPSqeareMgTfTpVrGZmpsVOvRSqIVKrjsXGXVAbjxfVfRSKYoz+NVazY4rjCZ0HzGLF DWs= X-SBRS: 2.7 X-MesageID: 10756442 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,417,1571716800"; d="scan'208";a="10756442" From: Ian Jackson To: Date: Fri, 10 Jan 2020 13:28:55 +0000 Message-ID: <20200110132902.29295-2-ian.jackson@eu.citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200110132902.29295-1-ian.jackson@eu.citrix.com> References: <20200110132902.29295-1-ian.jackson@eu.citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 1/8] 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: Anthony PERARD , Ian Jackson , George Dunlap , Wei Liu 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 --- 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 Tue Apr 16 04:59:29 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=1578662988; cv=none; d=zohomail.com; s=zohoarc; b=Slsu8rZviOrdste+BjFvsUbnbymKjFagSxkP2dpuDBsce9fIyz0UeCdGtPj8qkNLa2Q2ZWhwaeuS2ReV5kXumyhNg2kzsMm1+PQnpHcaOhp4696NPFt+C/Tvhz3kJEJpqf4A3sttN25M1jlUjKpAwhtLNtqQCTqo1TZq6asqhCM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578662988; 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=dQa/au3TEQNe1tCeo3wM3abMiHvSEJv1Wigjd8/uKkvbHQOAD3wTS25Ra1fDkpZmlBA12x5J5kwB+iSHAx6pw9fUih9JUWl0/xuoIB+Xf3mgZzR6KBi+T13psk7d1RLFAakTsnC6cKoaGsGJ+0fM09jPKVkbiVDS9h8xCkIs39o= 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 1578662988619457.3811794374218; Fri, 10 Jan 2020 05:29:48 -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 1ipuLm-0001zj-Nj; Fri, 10 Jan 2020 13:29:18 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ipuLl-0001zU-U6 for xen-devel@lists.xenproject.org; Fri, 10 Jan 2020 13:29:17 +0000 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 2e49e148-33ad-11ea-a2eb-bc764e2007e4; Fri, 10 Jan 2020 13:29:09 +0000 (UTC) X-Inumbo-ID: 2e49e148-33ad-11ea-a2eb-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1578662949; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=/5wulVWsdwFhm+h/O97CX626cu5GEU2I6i0AP03/ttE=; b=YlMoGHfCWl2o9lCZ9FBlLBZ23mLtrcBFcWfHFuJLMiG8e/hjrKttOr3y +ke6apri8SJq8+LJu9fILO/jtz4rXtmTikfhdxKlULO8XDjZIjHFJwQZh T65dsQBYA4c12nxPOerb/k+PiO5sbsYapcW2XjcQUyWNaOYkuzEKCdOk/ s=; Authentication-Results: esa4.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 (esa4.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=esa4.hc3370-68.iphmx.com; envelope-from="Ian.Jackson@citrix.com"; x-sender="ian.jackson@eu.citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa4.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=esa4.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 (esa4.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=esa4.hc3370-68.iphmx.com; envelope-from="Ian.Jackson@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: IKy6Nyk/8Fx+S2F7zYzFqRDH7h+GE9KehlE3Wvl8ePE41polCiXy6loGRnYu7jsMlk336e+tsO pY1SE6KEU0+tL8CR7gatkSo8ic1RYj7PjKnGzv5IEnwgIRNJVXmTvUuIEoK4OwZt9RS0W4VgEW QjxgefYBTu/6DS0n8aO/nLAljSv2wjyg4F9KsxOtS4MeV5Y1tCnIVO5KZDfJ4KD4pSlOKetWmb gEYD/ubeOwZ9ldp/011w99+lHqQXOilV/jsI0556Fdpy0/ZyhKfT8hKk4BapVf94jVqHMKOl6e ZLs= X-SBRS: 2.7 X-MesageID: 11329924 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.69,417,1571716800"; d="scan'208";a="11329924" From: Ian Jackson To: Date: Fri, 10 Jan 2020 13:28:56 +0000 Message-ID: <20200110132902.29295-3-ian.jackson@eu.citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200110132902.29295-1-ian.jackson@eu.citrix.com> References: <20200110132902.29295-1-ian.jackson@eu.citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 2/8] 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: Anthony PERARD , Ian Jackson , George Dunlap , Wei Liu 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 --- 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 Tue Apr 16 04:59:29 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=1578662991; cv=none; d=zohomail.com; s=zohoarc; b=HRRozOSDplDJNa+AyGrDv+n1+Yp8SElKbQPEu7+4eV0FyBohiba10JlZoHuDSrpmvqT5NQx43qs+22De0XPIYGPK367abjhPyVMkhXQkQptfaUcz7dwoycfBk/7/fokWaJ0JHMN0TGQPs5dCgAGgAOB4eBQBR4Vbte/rMQPIIHM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578662991; 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=ccr62Knatmir5XNhE046i7occ/sWq5xLcb6vK5ZGd+lrXGPABE31kT+/6OF+R7YMZ5FTQuN/domA376ffjYmnJA2BoIcj3AvCRKvu8PFDbgvIeRdmMxSvXAA/pDDT/jqo0BfCGo57ayZU9+Vd005Ubfv5Jd32IhXmdvuUXMQQd4= 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 1578662991417717.625029912213; Fri, 10 Jan 2020 05:29:51 -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 1ipuLp-00020r-12; Fri, 10 Jan 2020 13:29:21 +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 1ipuLn-00020G-Eg for xen-devel@lists.xenproject.org; Fri, 10 Jan 2020 13:29:19 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 2eb65fa8-33ad-11ea-bf0f-12813bfff9fa; Fri, 10 Jan 2020 13:29:10 +0000 (UTC) X-Inumbo-ID: 2eb65fa8-33ad-11ea-bf0f-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1578662950; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=aG8+e2m6AN5IfUjMx9VppTrvS/t/KQQmarqMBDQ8J/I=; b=Yvy8iVNhfdcrlKdUYUlHn6dY4P+QcF9sMviO7MJ5N1jECvQ8O0raA4jb LEYovAvNIt92HLumqHVUx5tyiDL3suLTCj9frf1rjDKbaWZ360Mbaq4cB i+pjd2sqaJhsSpXsCCeU4t3cgkDYCi7PQXRjVlCtMEXHu3pwk6LFRK2vZ 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: 2DYSPbzP+uGeMFalpiQ2L9HghOLyymfQ+owA9CnmFMuj1eVe+HfEx4llJ01kjzJzoVfpfIoJz0 utg7o1fcOtEqUlEa4GjAc4F8OVTrY0Exz056+lyyMJAiRUKiahiVjGDM94eYGec0ri1amV6Edp YtcitGEqxuk7SLMl1M3tDcLx+RV9epRksbuKFjh7jS+bwt/LJsb84BY+Dkg9B+6gSeeNEWXlxS iSlD7bhx+X0eFvz27CUxWpc0/up/0gXStmSmTbB4g1ZbEB4/p9u9gjTXXMc7TWZY6twhL/GG9m qrU= X-SBRS: 2.7 X-MesageID: 10902442 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,417,1571716800"; d="scan'208";a="10902442" From: Ian Jackson To: Date: Fri, 10 Jan 2020 13:28:57 +0000 Message-ID: <20200110132902.29295-4-ian.jackson@eu.citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200110132902.29295-1-ian.jackson@eu.citrix.com> References: <20200110132902.29295-1-ian.jackson@eu.citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 3/8] 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: Anthony PERARD , Ian Jackson , George Dunlap , Wei Liu 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 --- 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 Tue Apr 16 04:59:29 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=1578662998; cv=none; d=zohomail.com; s=zohoarc; b=Wjs2FhMMVWwb7cjOWbnkrBrm8WY64Vv962VZW9fPmXiJR0iogg6FboD6LQvCwUnQcehDbLZSHMfyiYRs+3doXFNkW35JX3+1egdP7D9T1csBH9H3gsa0RQQfO0QL7Zg+XxTDPAXit25O4/y0d/s/f2SXxbablCW/RLruZXKD3Vw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578662998; 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=pHGQmx13ie6Q27vb98nGznu3LYy7PckstfT2025kKzk=; b=cBjytYQHSBExifrX8sdFx4fNAhBwBKDlFp0dl3BpWsoi6RnAk5ktLvrRDHoNJ0lSONn48UIW1b4CLNJz/gwh8a7rIcTttMCirM5IgjOXItFUfh+RJDfSuHnHXbq6TMEpjQTpWt+Tj+aDhysZL3FyEXiXyOrT2+xMoXKRPneTGfE= 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 1578662998348316.8881819426765; Fri, 10 Jan 2020 05:29:58 -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 1ipuLs-00022V-Bn; Fri, 10 Jan 2020 13:29:24 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ipuLq-000220-UE for xen-devel@lists.xenproject.org; Fri, 10 Jan 2020 13:29:22 +0000 Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 2ebce332-33ad-11ea-b89f-bc764e2007e4; Fri, 10 Jan 2020 13:29:10 +0000 (UTC) X-Inumbo-ID: 2ebce332-33ad-11ea-b89f-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1578662950; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=tldUzIpqW259HNlP4sDhwClv5zBMPQrjoeXdLGkijiY=; b=hL8RPhplTbVLIUPN9+yytOTF9KHem8Ev0TFN4mp9N5cE13XOlFREPiaJ bmWmahBA6OZAjEOKmDwpDyi0w6zGnBTnBV/XDQnw7iNtTp37IA6gs2M4n qZIR5JLNDZspmve4eDdC1fX3zR3O9xBZ4bzEsSMNpvZr646YSdiZuNjx/ 8=; 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: f8IU3UlIfR4o62I84iI1o5RbjLKf9uOL+JmrpXc1MHa2QtN/WDB6fYCJXa3Z44Qh6mV0ncvRYT vmkCWzwmFvjL307KSroTTFW5uTTl2y0s33dp/DR6E5Jy5cZ8HnBI3XqEcFlvwS5K8LZWpknGGA wTldvoSnqSsAdTQOw1vs54VOaGDsxkyLMUKMLo/esH4P6lcE7ugHLYdMdBlVdof5Aah50thLu9 5hEmor/ge8n7N865UQi+HAO4D270JEgmBo0Kd+e4HHTWdPTwqtn5p0YsYCnoM0eHas/flidarn 2vk= X-SBRS: 2.7 X-MesageID: 10724855 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.69,417,1571716800"; d="scan'208";a="10724855" From: Ian Jackson To: Date: Fri, 10 Jan 2020 13:28:58 +0000 Message-ID: <20200110132902.29295-5-ian.jackson@eu.citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200110132902.29295-1-ian.jackson@eu.citrix.com> References: <20200110132902.29295-1-ian.jackson@eu.citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 4/8] 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: Anthony PERARD , Ian Jackson , George Dunlap , Wei Liu 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. We need the following property: whenever any thread is blocking in the libxl event loop, 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. 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. Reported-by: George Dunlap Signed-off-by: Ian Jackson --- tools/libxl/libxl_event.c | 72 +++++++++++++++++++++++++++++++++++++---= ---- tools/libxl/libxl_internal.h | 33 ++++++++++++++++---- 2 files changed, 88 insertions(+), 17 deletions(-) diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c index be37e12bb0..18db091a6e 100644 --- a/tools/libxl/libxl_event.c +++ b/tools/libxl/libxl_event.c @@ -36,6 +36,42 @@ static libxl__ao *ao_nested_root(libxl__ao *ao); static void ao__check_destroy(libxl_ctx *ctx, libxl__ao *ao); =20 =20 +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_cleanup_1_baton(libxl__egc *egc) +{ + EGC_GC; + 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(egc, 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 +230,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 +251,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 +354,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 +1161,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) { @@ -1444,7 +1485,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); @@ -1754,13 +1795,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 @@ -2033,10 +2076,12 @@ 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; } + libxl__egc_cleanup_1_baton(&egc); } else { rc =3D 0; } @@ -2053,6 +2098,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 @@ -2073,9 +2121,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= ); @@ -2088,8 +2133,9 @@ static int ao__abort(libxl_ctx *ctx, libxl__ao *paren= t) "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 @@ -2097,6 +2143,10 @@ static int ao__abort(libxl_ctx *ctx, libxl__ao *pare= nt) =20 out: 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. */ + libxl__egc_cleanup_1_baton(&egc); return rc; } =20 diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 983fffac7a..b9c4031863 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_cleanup_1_baton(libxl__egc *egc); + /* 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_cleanup_1_baton(egc); \ + 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_cleanup_1_baton(egc); \ 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 Tue Apr 16 04:59:29 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=1578663003; cv=none; d=zohomail.com; s=zohoarc; b=GvzXDfivI8oFinLQ9HCtR4u9xMSxuD2JhQO8MDj+e8ip/Wm3o+GzpxZUnKnWdV7WX7ljrKF0ecefkIpO94aGilnI/1lsnf1WstkeVWCdZ9i4dt5QSOHQHW+P4t/QieGn8d3BVZ9of19rBw3ZeetlLdd/77qA5+L3VsyYdHVhEBw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578663003; 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=FmzZLD15G6s+2eZyHzn7SAIoG9knej05X5DPzGW8wmE=; b=RtNNUqf504GS6aKaR0H+NaxPfFtgM9bbYA59e/EnjSk0rf4JIdqA7hONcq78zt8tAocBo5YqHhaNfrzs4RH9Snp6G3mESO6kcKjmnHlAptKvnHb9UKWWHijslTczwQ1FEVTDIEzkvEGDC6KSSbmWSKhL2MUAfSOkoKmR7STkE/o= 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 1578663003247988.0622726610236; Fri, 10 Jan 2020 05:30:03 -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 1ipuM7-0002Fr-Tu; Fri, 10 Jan 2020 13:29:39 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ipuM5-0002EJ-Uf for xen-devel@lists.xenproject.org; Fri, 10 Jan 2020 13:29:37 +0000 Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 34809728-33ad-11ea-b89f-bc764e2007e4; Fri, 10 Jan 2020 13:29:19 +0000 (UTC) X-Inumbo-ID: 34809728-33ad-11ea-b89f-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1578662959; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=P6HFqP1Bjv37yEk837tA9BxuNXZT5/Uewndbv9FiUBA=; b=CoOxXmgy3N+GVsjQefNZaru6CckksUWhAqfRpZ9Cm5vIn+7opsZDH5uU EMtkLn/V0xjZOgFX5HxwIjKunLHq84Kwf27Yy4M0ofQ3466rshrrLRrIt baEvLJp7AWf+aPCGzB/6rel2cvdVm/oc9JQYwJMcsBCUrw5ezEOzDzBBQ A=; Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=ian.jackson@eu.citrix.com; spf=Pass smtp.mailfrom=Ian.Jackson@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: none (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: 6yvIYErgDqYk+bCXVG9HVDbE0PX44AWuDemAkyHO3KUcPuPyAF6H1zyDOnoVwV3nmLWcLTQCsR U9YFXIGzjNkl8NykNFZEy9dbOBbEG7XuJgJwdz2ghRHggH6TyQuiem0xcvfILBX1FWd8/py9I5 S1VHybxqy1FauJStlzqwzhpMVcIaIkOCurnoeh4GMWdtAUO/zFx8flk8PhQzPosyE8m2NS0VZ+ Eb3V5YkLHk1PCDeiv8yGcSP0R7qblwXnvA8QwueIKnKtVXn8vWz/FrUJaQH1JqOsQge3tUM743 avo= X-SBRS: 2.7 X-MesageID: 10724856 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.69,417,1571716800"; d="scan'208";a="10724856" From: Ian Jackson To: Date: Fri, 10 Jan 2020 13:28:59 +0000 Message-ID: <20200110132902.29295-6-ian.jackson@eu.citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200110132902.29295-1-ian.jackson@eu.citrix.com> References: <20200110132902.29295-1-ian.jackson@eu.citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 5/8] libxl: event: poller pipe optimisation X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD , Ian Jackson , George Dunlap , Wei Liu 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 --- tools/libxl/libxl_event.c | 2 ++ tools/libxl/libxl_internal.h | 1 + 2 files changed, 3 insertions(+) diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c index 18db091a6e..05559cad9a 100644 --- a/tools/libxl/libxl_event.c +++ b/tools/libxl/libxl_event.c @@ -1319,6 +1319,7 @@ static void afterpoll_internal(libxl__egc *egc, libxl= __poller *poller, } =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(egc, "read wakeup", e, 0); } @@ -1713,6 +1714,7 @@ void libxl__poller_put(libxl_ctx *ctx, libxl__poller = *p) =20 void libxl__poller_wakeup(libxl__egc *egc, libxl__poller *p) { + if (p->pipe_nonempty++) return; int e =3D libxl__self_pipe_wakeup(p->wakeup_pipe[1]); if (e) LIBXL__EVENT_DISASTER(egc, "cannot poke watch pipe", e, 0); } diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index b9c4031863..baf7509b1e 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -625,6 +625,7 @@ struct libxl__poller { int (*fd_rindices)[3]; /* see libxl_event.c:beforepoll_internal */ =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 Tue Apr 16 04:59:29 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=1578662995; cv=none; d=zohomail.com; s=zohoarc; b=jL0fK31K+GSMAEUcDgNuaIM3JPUtpv+mIaenmxGc3wyQOXLJ2wHpEKk/fL+J1Rop/cTQiVv044TxLyVd0AHBlHKiDe3Xj+yZ0pvgVKmxSDz9TBQtiCWUbCuRqoJhugguIb+gADKnBoY1oXgQ5IRYQHbYyl1JJHSZqs6x2RP2QLQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578662995; 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=xgpk+vkce9FwwXk9IKG9P4IpMAYOwLWlApblXimQN5Y=; b=keo2/BJvsw2FKad0klela1HmDQgbBrCy5+bq+ybtUhnk2M8mfaTPcCmLO0FQjHSxmyI+MP/0LEDt3/52KDt9CPY2kd1iSKifwSXErUdYzbBvmYVcUjABpn1ok4j2QW7sdHRCvAgwhkt7cSi96qyYHjCjl7RJPvrUJrmbVWGRu3U= 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 1578662995702597.5981609103276; Fri, 10 Jan 2020 05:29: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 1ipuLx-000272-7R; Fri, 10 Jan 2020 13:29:29 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ipuLv-00025v-UT for xen-devel@lists.xenproject.org; Fri, 10 Jan 2020 13:29:27 +0000 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 2f09957e-33ad-11ea-a2eb-bc764e2007e4; Fri, 10 Jan 2020 13:29:10 +0000 (UTC) X-Inumbo-ID: 2f09957e-33ad-11ea-a2eb-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1578662950; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=R+ahEkQ1I1GbKB9qZnY8vh7yoapgPhho9ac7tgVZHug=; b=GKB0YyhVYHARyY4x6cUmgXgqtd5MgFr7vZm1bHlHe+RE31tRtiZcu1Sd gSfktxSN55dxNSI3WNQZ0m5tDuZ9J0wnaVOk/lklTvCd0ShNF2izNJL3I 6kcYOIUXl4u9wSpUIFlkxOKgzmPW0mF5TyeUldqQMasyz14fPGZjasIyE I=; Authentication-Results: esa5.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 (esa5.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=esa5.hc3370-68.iphmx.com; envelope-from="Ian.Jackson@citrix.com"; x-sender="ian.jackson@eu.citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa5.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=esa5.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 (esa5.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=esa5.hc3370-68.iphmx.com; envelope-from="Ian.Jackson@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: k9saOMO7//+BGCMb86+oq7LEyP8HwhR0owqwqpg/rgeX7+TA8C2ubTbj3d7Lq72vk8OXllkhgj nhmmHvtmZYWmlYmc31ZQbm/AvQtQYhBTvvce7E1W+G9mqsHXlyeCSWs5gyZEEooCMgL1gSA3b8 bz7/QduUX+mN1Ccgi+sSkJo9kcc5olQAsGp61i8LQwc4mZ+l1Los9AmPHP7lnxydAt1D2zAHnQ LLf5IJGdJPa6ebZSUZG2EBgaLp06gHsOW+Akl/jybOEI1Zv7ZcGrLir9lnvd/QpKOBSLOJqKOM Mhs= X-SBRS: 2.7 X-MesageID: 11113830 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.69,417,1571716800"; d="scan'208";a="11113830" From: Ian Jackson To: Date: Fri, 10 Jan 2020 13:29:00 +0000 Message-ID: <20200110132902.29295-7-ian.jackson@eu.citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200110132902.29295-1-ian.jackson@eu.citrix.com> References: <20200110132902.29295-1-ian.jackson@eu.citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 6/8] 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: Anthony PERARD , Ian Jackson , George Dunlap , Wei Liu 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 --- 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 05559cad9a..4d57843cce 100644 --- a/tools/libxl/libxl_event.c +++ b/tools/libxl/libxl_event.c @@ -42,6 +42,18 @@ static void pollers_note_osevent_added(libxl_ctx *ctx) { poller->osevents_added =3D 1; } =20 +static void baton_wake(libxl__egc *egc, libxl__poller *wake) +{ + libxl__poller_wakeup(egc, 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_cleanup_1_baton(libxl__egc *egc) { EGC_GC; @@ -62,14 +74,7 @@ void libxl__egc_cleanup_1_baton(libxl__egc *egc) /* no-one in libxl waiting for any events */ return; =20 - libxl__poller_wakeup(egc, 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(egc, 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 Tue Apr 16 04:59:29 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=1578662990; cv=none; d=zohomail.com; s=zohoarc; b=KvT2mF5EL1qXJ2Ou9YwFEXd8CmLXcvK3gih2ih+f6U7XQ8I+rLf29z7Sy9l0JheDk4Q4RS/9uLKfhBZz/ivMurqU1M2F63Th+A43nKhZSgHaab1fMetgeJbwqhVK8grVF2IlKG8ptmrdojfELbvixYID0YgPDEfiS0vp8EmYHQI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578662990; 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=d0EcR/95fhM2WFPfeNpcR9OKTD2IHlAvKLCXHtreKb0=; b=V6KWHHrYD/qtcBt/gclVxeL7ztrx5y0jmbc6zdQoPcFSUDLpeacCiYOELvcVHYmx1S3R0XK5IEBAFeU8SuSMBH5uIPUue9eyZVa8QnFp3STVaZrz+9ey56r4rf5DyiKKu384tPOdJ9XLiu/2wu/pIVq4nN7vPdDuszcfV9ssgzk= 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 1578662990430579.7051907682464; Fri, 10 Jan 2020 05:29:50 -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 1ipuLt-00024G-U4; Fri, 10 Jan 2020 13:29:25 +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 1ipuLs-00022a-EZ for xen-devel@lists.xenproject.org; Fri, 10 Jan 2020 13:29:24 +0000 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 2f2a09d1-33ad-11ea-bf0f-12813bfff9fa; Fri, 10 Jan 2020 13:29:10 +0000 (UTC) X-Inumbo-ID: 2f2a09d1-33ad-11ea-bf0f-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1578662951; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=EQKJVYRxuGecgkUPMzOczs+XFPoxrOfmNieB9m2Ck6c=; b=f7pT50aU3vDRJKUOyxgDj0V+DRcF54KAnqrMAgJ/NFU8XbAoZeTokHu0 qU+HlW9HA2yYukeyRdEbnvdwCHloJRM+7x1NpnUOiJ21DlMvc8tfOgOHi QxVawo0xwgDIOZopRl6spR0s0vAJlvTRbI9u6xvVcWmxhw2C1MqVxKtRd A=; 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: /3Y4gLvuy/92Dv4CGu/0cx1Ik2zFrx69pbn95ugEw5OTYP/7WKyqVo+XFYI4efRG3J9xzvpLh7 vhvgDArV4WQ3UqsyQnKKF5PZK3bI5A5kKZuiur0MMfC8KDmh0pgvyPSw/7MuPi+mrW29F+yuj6 g6ZFNce3XbidnvL96GPs1YBk5lYyOyYwTfaEZaRk+cwD7JUq1FGB3v+o6FVYZwmVkBKS8ixM7I i376A+XKAwmMty8hXVGlxf+JlVB1uGf+spGbEfBdhwy4NoDHxqCIJMblSyFYl+uqbJqdwG7Txy XOI= X-SBRS: 2.7 X-MesageID: 10756446 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,417,1571716800"; d="scan'208";a="10756446" From: Ian Jackson To: Date: Fri, 10 Jan 2020 13:29:01 +0000 Message-ID: <20200110132902.29295-8-ian.jackson@eu.citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200110132902.29295-1-ian.jackson@eu.citrix.com> References: <20200110132902.29295-1-ian.jackson@eu.citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 7/8] 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: Anthony PERARD , Ian Jackson , George Dunlap , Wei Liu 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 --- tools/libxl/libxl_event.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c index 4d57843cce..4314191c3b 100644 --- a/tools/libxl/libxl_event.c +++ b/tools/libxl/libxl_event.c @@ -59,6 +59,9 @@ void libxl__egc_cleanup_1_baton(libxl__egc *egc) EGC_GC; libxl__poller *search, *wake=3D0; =20 + if (CTX->poller_app->osevents_added) + baton_wake(egc, 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 Tue Apr 16 04:59:29 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=1578662999; cv=none; d=zohomail.com; s=zohoarc; b=E8uvqMgXW4s0nu3Afj7vTb5q3qwS/eXPy6KLOzpud4unoskoLiUM4s9s24v0Lh7DV9dSAEm841T82+sN6UXts6d/4cw1hYTwCagSxOn9fRjfoRqKwdmThNwMo4Z8hIWd8nJmzcQdhPVzFAv5MN1NC9zvDqT4XOhZni4LnJ3gc9o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578662999; 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=KYan6by9R1IT1MLBFEr/wx56/c+gYey8nUePc3AVFAg=; b=T0y0ysCOVflD4fEHeWSdWB2bFEnszysc4DHKPRFug24LguV9qRUBxWu4D2uofJG4/9lNcdw0z6pLbFbwZ1KofBg2c7rFC/JwU6Epe2lk1w36AF2Nn4JJBfPFGkFcm40ihaLmN9tpLMEEjRNUPjf34ozabgZw8FGIKta5gTUnkjg= 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 1578662999736111.46300738276818; Fri, 10 Jan 2020 05:29:59 -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 1ipuM2-0002BL-I6; Fri, 10 Jan 2020 13:29:34 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ipuM0-0002A7-US for xen-devel@lists.xenproject.org; Fri, 10 Jan 2020 13:29:32 +0000 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 2f87359c-33ad-11ea-a2eb-bc764e2007e4; Fri, 10 Jan 2020 13:29:11 +0000 (UTC) X-Inumbo-ID: 2f87359c-33ad-11ea-a2eb-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1578662951; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=HAh5Gp+uESpDijBcjwZlp5s66xVVTo2w8VLzP3EQSvI=; b=Eb8TosCmhIlqSikYvLDP4YyfMis5BF0dmd05lpq/Bz3bmRww16xeYroo XsBXVcPf92uj9V171B7MQwZrOeJWFD0AjRuxdp0DueUm6ajp4o6wDmkWt vYPBcrS0hEKrOjtdiyONkzE5Hihg5q2sgcCc9ZhI70G0KOvZ5+e5TuhSW 8=; Authentication-Results: esa4.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 (esa4.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=esa4.hc3370-68.iphmx.com; envelope-from="Ian.Jackson@citrix.com"; x-sender="ian.jackson@eu.citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa4.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=esa4.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 (esa4.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=esa4.hc3370-68.iphmx.com; envelope-from="Ian.Jackson@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: 1Xz9hfuyzm6jtUOsKxdDbQyUQawiHrB917HX1uS1QSgOrZ6JJIZ96UWcBitMdGi0ZJR/Rw0t7J zT/7DNe6VHG6YeFlT/wBvn622fYnoCcWYYDhOfnDjx7dNPjcbxY1QVejIaqSSpMDLUuangrCHD 8jYCK/HzYxABkKl7iqPgEw/sVOPUY53bR7eXEkOzDESFwva53rSengqRc8sbw9Q5t81HkjPGqF +NIOkIBkGW1oNwrSmD4kQM3dyDmY3A7y2gwPp1+NGcEWCXPWJHyPeStcfOz9346jpt+2MsSxFV ZlU= X-SBRS: 2.7 X-MesageID: 11329930 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.69,417,1571716800"; d="scan'208";a="11329930" From: Ian Jackson To: Date: Fri, 10 Jan 2020 13:29:02 +0000 Message-ID: <20200110132902.29295-9-ian.jackson@eu.citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200110132902.29295-1-ian.jackson@eu.citrix.com> References: <20200110132902.29295-1-ian.jackson@eu.citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 8/8] 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: Anthony PERARD , Ian Jackson , George Dunlap , Wei Liu 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 --- 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 4314191c3b..f59fbc719e 100644 --- a/tools/libxl/libxl_event.c +++ b/tools/libxl/libxl_event.c @@ -1326,12 +1326,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(egc, "read wakeup", e, 0); - } - for (;;) { libxl__ev_time *etime =3D LIBXL_TAILQ_FIRST(&CTX->etimes); if (!etime) @@ -1346,6 +1340,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(egc, "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