From patchwork Fri Jan 17 14:47:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Jackson X-Patchwork-Id: 11339397 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6C8CF1820 for ; Fri, 17 Jan 2020 14:48:57 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 492C92073A for ; Fri, 17 Jan 2020 14:48:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="JCWWuOcA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 492C92073A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=eu.citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1isSua-0003Wz-Qr; Fri, 17 Jan 2020 14:47:48 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1isSuZ-0003WS-M1 for xen-devel@lists.xenproject.org; Fri, 17 Jan 2020 14:47:47 +0000 X-Inumbo-ID: 4bc8a9bc-3938-11ea-b833-bc764e2007e4 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 4bc8a9bc-3938-11ea-b833-bc764e2007e4; Fri, 17 Jan 2020 14:47:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1579272454; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=X2wy6ysk6E0gl7NDpBEXElfrRoZkazsyRAbql+jxpvI=; b=JCWWuOcA0qdG2GChXpwXn/S+rUcXtZZoLk80nKngrbkDBgNgw31VjWkI yqlW4eoZ6jMS6qUFZjFGNQDwxyldQotKp5CVT3LCDPPApoMYZplxpK5DH TLu10MUjF4EtUpDTePZZ7HdaKwCYDnqyi1rPHvJWxigoAZHtgoBQaC/dS w=; 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 (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: EK7U5nGz7zhdAyd3LNMJXL6tyhUIduNnq00ZEgUJY9Mss/TJ0HcyJVpR/13UreygE9t9Bre9xc Yfwd+Rhj2vTyjxTIQ7ewP691XDbOst3AStgJx2fDs8ucIEPE0L+hONnq4SGnTElYxTxRiCgeej IC0dJZB9fCkK5OCgR4ZOEzhGlOSISPSpROGCJmfzt5JybSekbHvZRnc9QM0mWXNIqaoXrAD99m 6sodRo5MtHyhH5AGqvjLXK4hXsQRTVG/WGs5rGJz5XmBuZ+b6QVmL49sgcwxYaamato0eR61/5 +7U= X-SBRS: 2.7 X-MesageID: 11669886 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.70,330,1574139600"; d="scan'208";a="11669886" From: Ian Jackson To: Date: Fri, 17 Jan 2020 14:47:19 +0000 Message-ID: <20200117144726.582-4-ian.jackson@eu.citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200117144726.582-1-ian.jackson@eu.citrix.com> References: <20200117144726.582-1-ian.jackson@eu.citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 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: Anthony PERARD , Ian Jackson , George Dunlap , Wei Liu Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" 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 *nfds_io, CTX_LOCK; int rc = beforepoll_internal(gc, ctx->poller_app, nfds_io, fds, timeout_upd, now); - CTX_UNLOCK; - EGC_FREE; + CTX_UNLOCK_EGC_FREE; return rc; } @@ -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; } /* @@ -1342,8 +1340,7 @@ void libxl_osevent_occurred_fd(libxl_ctx *ctx, void *for_libxl, fd_occurs(egc, ev, revents_ign); out: - CTX_UNLOCK; - EGC_FREE; + CTX_UNLOCK_EGC_FREE; } void libxl_osevent_occurred_timeout(libxl_ctx *ctx, void *for_libxl) @@ -1365,8 +1362,7 @@ void libxl_osevent_occurred_timeout(libxl_ctx *ctx, void *for_libxl) time_occurs(egc, ev, ERROR_TIMEDOUT); out: - CTX_UNLOCK; - EGC_FREE; + CTX_UNLOCK_EGC_FREE; } 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 **event_r, EGC_INIT(ctx); CTX_LOCK; int rc = event_check_internal(egc, event_r, typemask, pred, pred_user); - CTX_UNLOCK; - EGC_FREE; + CTX_UNLOCK_EGC_FREE; return rc; } @@ -1772,8 +1767,7 @@ int libxl_event_wait(libxl_ctx *ctx, libxl_event **event_r, out: libxl__poller_put(ctx, poller); - CTX_UNLOCK; - EGC_FREE; + CTX_UNLOCK_EGC_FREE; return rc; } 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, int status) assert(CTX->childproc_hooks->chldowner == libxl_sigchld_owner_mainloop); int rc = childproc_reaped(egc, pid, status); - CTX_UNLOCK; - EGC_FREE; + CTX_UNLOCK_EGC_FREE; return rc; } @@ -529,8 +528,7 @@ void libxl_childproc_sigchld_occurred(libxl_ctx *ctx) assert(CTX->childproc_hooks->chldowner == libxl_sigchld_owner_mainloop); childproc_checkall(egc); - CTX_UNLOCK; - EGC_FREE; + CTX_UNLOCK_EGC_FREE; } 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); #define EGC_FREE libxl__egc_cleanup(egc) +#define CTX_UNLOCK_EGC_FREE do{ CTX_UNLOCK; EGC_FREE; }while(0) + /* * Machinery for asynchronous operations ("ao")