From patchwork Tue Jan 28 13:03:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 22657 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 8EACABDB13 for ; Tue, 28 Jan 2025 13:03:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 958C56855D; Tue, 28 Jan 2025 14:03:17 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=protonmail.com header.i=@protonmail.com header.b="QkcKbcmx"; dkim-atps=neutral Received: from mail-4316.protonmail.ch (mail-4316.protonmail.ch [185.70.43.16]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DCF7868546 for ; Tue, 28 Jan 2025 14:03:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1738069395; x=1738328595; bh=tyJv51uYcYf3+b0VTofQMOkVCt1d8dKYlqOV1oiZmjA=; h=Date:To:From:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector: List-Unsubscribe:List-Unsubscribe-Post; b=QkcKbcmxy7DvtnY3zlgoi9cC7bnyBo3jdqJjku8z3mmKDhsZ/9hBNzZgX8DCz1mJ0 22rUPhyMUMs1sD3pweEB2Rs+KB0CRn2KiDS6ODvWIub5uug6mDRO3y4EJT2o43apfi LdtmMjZpZc4LjJM8PVtAd7Spcb0xhomnvpFo10CU2KSHI6dsL0ke1kntdhEX5W/IPn xiOtAMVmFQVz17FfsjSgizfBuGuwuW1YFj9fKX4ZRRytPeRpFefC08BUoKhHpwBxRc HX9nafgJfw6pqpOvgdoBj/tonnxExDPlKWQ7eGEbKPvnxDrfVlBBBTQfi5WRoEYp++ U/wND4sWoQz0g== Date: Tue, 28 Jan 2025 13:03:10 +0000 To: libcamera-devel@lists.libcamera.org From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Subject: [RFC PATCH v1] libcamera: thread: Use `acquire` memo. when reading event dispatcher Message-ID: <20250128130308.509297-1-pobrn@protonmail.com> Feedback-ID: 20568564:user:proton X-Pm-Message-ID: 95df461bf91479b0230bf82ae1c54378ba1438ee MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Use `std::memory_order_acquire` everywhere the dispatcher is loaded to guarantee synchronization with the release-store that places the pointer there. Signed-off-by: Barnabás Pőcze --- src/libcamera/base/thread.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcamera/base/thread.cpp b/src/libcamera/base/thread.cpp index 319bfda9a..de60567f6 100644 --- a/src/libcamera/base/thread.cpp +++ b/src/libcamera/base/thread.cpp @@ -238,7 +238,7 @@ Thread::Thread() Thread::~Thread() { - delete data_->dispatcher_.load(std::memory_order_relaxed); + delete data_->dispatcher_.load(std::memory_order_acquire); delete data_; } @@ -371,7 +371,7 @@ void Thread::exit(int code) data_->exitCode_ = code; data_->exit_.store(true, std::memory_order_release); - EventDispatcher *dispatcher = data_->dispatcher_.load(std::memory_order_relaxed); + EventDispatcher *dispatcher = data_->dispatcher_.load(std::memory_order_acquire); if (!dispatcher) return;