From patchwork Thu May 20 13:35:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gaetan Rivet X-Patchwork-Id: 1481627 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=u256.net header.i=@u256.net header.a=rsa-sha256 header.s=fm1 header.b=myMMOV1m; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm2 header.b=K/uH6nWG; dkim-atps=neutral Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Fm9kH4KkDz9sWW for ; Thu, 20 May 2021 23:36:23 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id BB39C83DF8; Thu, 20 May 2021 13:36:16 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8kLb4IfayqLq; Thu, 20 May 2021 13:36:15 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp1.osuosl.org (Postfix) with ESMTP id A97FC83D59; Thu, 20 May 2021 13:36:12 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 9E7B9C002F; Thu, 20 May 2021 13:36:09 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 36605C0001 for ; Thu, 20 May 2021 13:36:05 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 351F083B07 for ; Thu, 20 May 2021 13:36:04 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qLpeu1I3uGeQ for ; Thu, 20 May 2021 13:36:03 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0 Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by smtp1.osuosl.org (Postfix) with ESMTPS id A731083B0D for ; Thu, 20 May 2021 13:36:03 +0000 (UTC) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 241C75C010E for ; Thu, 20 May 2021 09:36:01 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Thu, 20 May 2021 09:36:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=u256.net; h=from :to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=fm1; bh=ENEjZXBBD2TeNNamaGEHXFnPpK cjacPUN4bgCWy6Ytg=; b=myMMOV1mqAZiZDnbpGyrjwsP/gM/dgWirb5SDmGMJF 3WkfwQ6PjHF0ZOK/oJSY4j3PEwEAkgoA/OLVcJs8Mk/N2rNXQzJAqjxZ9vvMPND7 L7CkHR1EvxWP1JvjDRWAo1QFiriQauMIKeoNpznWWXnWEL8SMC3pOvde1QeXXzGa wo02a/XQGm7z2vFbEHBXfmb/Mc2r4JrxlEED+EarN4/MMDgZBRapDr1tQWgdcvii Z8bBO/I1plUm0E2llnM2KY1SbNNKHvd3h3IALrRCpa0v0um2ZteQS0D5EIYSkl/K 5tEInwY6PShswFuqfez3o1zvPvejJL3jsZ97MPspyg3A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=ENEjZXBBD2TeNNamaGEHXFnPpKcjacPUN4bgCWy6Ytg=; b=K/uH6nWG IGzKgE47kFco4pWcFkxJGqFfCWi4grcmwLvHCmVGopBlWwqDg4KHOm2C0iR0EC/I 9/29LQxh2a+CBVUlAOBlS+2UuFjr6qVd2NqatQF+LC7qqkTeimpxJy4mZBA9DLAt +w3lhhcWb6jLOW9igdiyVK44fW4rpINmSiYpm5FqxoKycykxG7QujMh0kiQlmAQ0 Jkwr3ac4XMva/LLDAhx84G4XLnkNJ7fsv+wfIfr6GOuLW0leV5Pt/5HT3iiz2C2J Tn8BiLHFB2jROVDEo8ORGU/NYKSKFMOEWekdj99KOEjHDL2NPTG8rb0x+jFH+iT8 l3q+OLX+fGSokQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvdejuddgieejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepifgrvghtrghnucftihhvvghtuceoghhrihhvvgesuhdvheei rdhnvghtqeenucggtffrrghtthgvrhhnpeehgfevffekteehteefieefvdehleefjeefhe evudetjefhkeeutdekieeuvdetheenucfkphepkeeirddvheegrddvgeefrddugeeinecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepghhrihhvvg esuhdvheeirdhnvght X-ME-Proxy: Received: from inocybe.home (lfbn-poi-1-930-146.w86-254.abo.wanadoo.fr [86.254.243.146]) by mail.messagingengine.com (Postfix) with ESMTPA for ; Thu, 20 May 2021 09:36:00 -0400 (EDT) From: Gaetan Rivet To: ovs-dev@openvswitch.org Date: Thu, 20 May 2021 15:35:50 +0200 Message-Id: <08ee1d5d77b710a12bdd236a54a3621e85914791.1621517561.git.grive@u256.net> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [ovs-dev] [PATCH v2 6/8] ovs-thread: Quiesce when joining pthreads X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Joining pthreads makes the caller quiescent. It should register as such, as joined threads may wait on an RCU callback executing before quitting, deadlocking the caller. Signed-off-by: Gaetan Rivet --- lib/ovs-thread.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/ovs-thread.c b/lib/ovs-thread.c index 805cba622..bf58923f8 100644 --- a/lib/ovs-thread.c +++ b/lib/ovs-thread.c @@ -180,8 +180,6 @@ XPTHREAD_FUNC1(pthread_cond_destroy, pthread_cond_t *); XPTHREAD_FUNC1(pthread_cond_signal, pthread_cond_t *); XPTHREAD_FUNC1(pthread_cond_broadcast, pthread_cond_t *); -XPTHREAD_FUNC2(pthread_join, pthread_t, void **); - typedef void destructor_func(void *); XPTHREAD_FUNC2(pthread_key_create, pthread_key_t *, destructor_func *); XPTHREAD_FUNC1(pthread_key_delete, pthread_key_t); @@ -191,6 +189,20 @@ XPTHREAD_FUNC2(pthread_setspecific, pthread_key_t, const void *); XPTHREAD_FUNC3(pthread_sigmask, int, const sigset_t *, sigset_t *); #endif +void +xpthread_join(pthread_t thread, void **retval) +{ + int error; + + ovsrcu_quiesce_start(); + error = pthread_join(thread, retval); + ovsrcu_quiesce_end(); + + if (OVS_UNLIKELY(error)) { + ovs_abort(error, "%s failed", __func__); + } +} + static void ovs_mutex_init__(const struct ovs_mutex *l_, int type) {