From patchwork Mon Jan 13 17:08:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Jackson X-Patchwork-Id: 11330623 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 D109F138D for ; Mon, 13 Jan 2020 17:10:00 +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 AD9A12084D for ; Mon, 13 Jan 2020 17:10:00 +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="WPxjf8ce" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AD9A12084D 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 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 X-Inumbo-ID: 5e394bf6-3627-11ea-b89f-bc764e2007e4 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) 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 (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 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 --- 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")