From patchwork Fri Jan 10 13:28:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Jackson X-Patchwork-Id: 11327389 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 168A1930 for ; Fri, 10 Jan 2020 13:30:10 +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 E5A112077C for ; Fri, 10 Jan 2020 13:30:09 +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="Yvy8iVNh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E5A112077C 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 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 X-Inumbo-ID: 2eb65fa8-33ad-11ea-bf0f-12813bfff9fa 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) 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 (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 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 --- 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")