From patchwork Wed Oct 20 07:47:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Ivanov X-Patchwork-Id: 1543751 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=140.211.166.133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HZ2lt0bDyz9sRR for ; Wed, 20 Oct 2021 18:48:09 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 4621140547; Wed, 20 Oct 2021 07:48:07 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id MZV82mPtwLlJ; Wed, 20 Oct 2021 07:48:06 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp2.osuosl.org (Postfix) with ESMTPS id 37FC4400C4; Wed, 20 Oct 2021 07:48:05 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 0906CC000F; Wed, 20 Oct 2021 07:48:05 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id DB368C000D for ; Wed, 20 Oct 2021 07:48:03 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id B541E40136 for ; Wed, 20 Oct 2021 07:48:03 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UkB0tdcLnAa3 for ; Wed, 20 Oct 2021 07:48:02 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0 Received: from www.kot-begemot.co.uk (ivanoab7.miniserver.com [37.128.132.42]) by smtp2.osuosl.org (Postfix) with ESMTPS id 3994E400C4 for ; Wed, 20 Oct 2021 07:48:01 +0000 (UTC) Received: from tun252.jain.kot-begemot.co.uk ([192.168.18.6] helo=jain.kot-begemot.co.uk) by www.kot-begemot.co.uk with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1md6KL-0008I5-Pc; Wed, 20 Oct 2021 07:47:58 +0000 Received: from jain.kot-begemot.co.uk ([192.168.3.3]) by jain.kot-begemot.co.uk with esmtp (Exim 4.92) (envelope-from ) id 1md6KH-0000YE-Ek; Wed, 20 Oct 2021 08:47:55 +0100 From: anton.ivanov@cambridgegreys.com To: ovs-dev@openvswitch.org Date: Wed, 20 Oct 2021 08:47:50 +0100 Message-Id: <20211020074750.2023-1-anton.ivanov@cambridgegreys.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Clacks-Overhead: GNU Terry Pratchett Cc: wentao.jia@easystack.cn, Anton Ivanov Subject: [ovs-dev] [OVN Patch] libs: Replace weak with strong compare and exchange 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" From: Anton Ivanov Weak may fail for reasons unrelated to the comparison (not on x86, where these are practically equivalent). Thus, it can and should be used only in cases where there will be a repeat of the event which runs the code (in this case semaphore post). On non-x86 architectures using weak may result in a failed comparison without any more sem post events - a hang. Reported for arm, likely for other platforms where weak may fail. Reported-by: wentao.jia@easystack.cn Signed-off-by: Anton Ivanov --- lib/ovn-parallel-hmap.c | 2 +- ovs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ovn-parallel-hmap.c b/lib/ovn-parallel-hmap.c index b8c7ac786..56ceed8e8 100644 --- a/lib/ovn-parallel-hmap.c +++ b/lib/ovn-parallel-hmap.c @@ -267,7 +267,7 @@ ovn_run_pool_callback(struct worker_pool *pool, * (most likely acq_rel) to ensure that the main thread * sees all of the results produced by the worker. */ - if (atomic_compare_exchange_weak( + if (atomic_compare_exchange_strong( &pool->controls[index].finished, &test, false)) {