From patchwork Mon Dec 2 09:04:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cheng-Hao Yang X-Patchwork-Id: 22145 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 212CCBEFBE for ; Mon, 2 Dec 2024 09:05:08 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 324386605C; Mon, 2 Dec 2024 10:05:07 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="NiINeg8e"; dkim-atps=neutral Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8960266010 for ; Mon, 2 Dec 2024 10:05:04 +0100 (CET) Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-21278f3d547so27850065ad.1 for ; Mon, 02 Dec 2024 01:05:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733130303; x=1733735103; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Fa4+Y79PGTprbqZeJm96PuesJyixiLSaHg4DvuyNYnY=; b=NiINeg8eulcgIhsVHmzBeG8UKvHMMlm3pxSQaqjBC+1LybqROHJuoH/kUKALPC0Xis p5+agTGO/zl84k3v2Rj2mqKt0w6VOi/h/XHYTz8NNmfSN8m2u5Bym5wbeY91Caqzmv51 pPJuF2MXlQQXTn9V0HR1aX82bMm6nhs7ss2UM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733130303; x=1733735103; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Fa4+Y79PGTprbqZeJm96PuesJyixiLSaHg4DvuyNYnY=; b=q+81NcHdj1huuyFhVeuHmkFMlt1P2CKWPolgNCwsQunafr0jUS+PejbqdmlBwrib+8 DrWtcLLzObfYbsn/GEK3WX8KxRCQxd7Vlp3BDsE/1E7fFwPOWQaRaStBuf05ax0fUyf1 tyJ/zG3RcpfaiiQgdhEuTwS6QqaAdrvQRBKF1wQHygBKzyZRtV+ncqLyUL4hU2R4EcPa rCw4u3gT7Y3cPC3po0j45YzpgLpbrk3v7chs0LkHPqw2ncyVfXgOqAw3FfEwasOge2v4 Yl+5kzLLX7+LqVgmNTK15Xnn9Te/ZhuDW/F9/XylAuwTsuahMMWueYJeZvk9c5yoVF7s J41w== X-Gm-Message-State: AOJu0Yz+BQBsg5i8pC9ysgqn+DhYW+by4Kml2vahAPSkFXPHEZFUewEN 3L3IiUJkWci+un68EGiARtonHl/B/gIIuOoQ85sNB9CBdgQ88fII311fG51fxJQHRr7usBu8W0m yKg== X-Gm-Gg: ASbGnctbyPL5cRxzH2os4s7b7NoZhauz2TP5wNEzJSAYxOYgR39vS7O3+j/CZkN1NUz M5keVlTkvCBK6TxQxwRmy4x37gtsW7mnoJhkc3YMoK7VUdcG3x/KcbraRMNSnjkXdHe8sbZfkyk KQhWcinLmoadVoTLNjwoFatui8vNF/Nnj1CV15LJQ7E3ZEUQELL6jg3mUYiiNVfjvlY3XWuQYTa PNiaRdbkj+4gzJSaeO/4LT9BMmRqCpWN4+zBN3tD9B5cNqXzCouo1n/gDKIcpF6vARCTUvp+MXy 9ZxjX53efjAzA1VGjp+kACxb+StAY8PP11kWIre8TLrJSayWYfTxYZFU X-Google-Smtp-Source: AGHT+IHxUSd6p3GSKP94M+qwrx0cZK3g9e9YO8Aftv6eMNzuTcuW53W+bzI2Yp8BvD3z5uawL+kigQ== X-Received: by 2002:a17:902:f543:b0:215:9ed9:932f with SMTP id d9443c01a7336-2159ed994c7mr21004855ad.55.1733130302690; Mon, 02 Dec 2024 01:05:02 -0800 (PST) Received: from chenghaoyang-low.c.googlers.com.com (112.212.229.35.bc.googleusercontent.com. [35.229.212.112]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-215219058b1sm72313265ad.74.2024.12.02.01.05.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2024 01:05:02 -0800 (PST) From: Harvey Yang To: libcamera-devel@lists.libcamera.org Cc: Harvey Yang Subject: [PATCH] Thread: Fix setThreadAffinity issue Date: Mon, 2 Dec 2024 09:04:53 +0000 Message-ID: <20241202090457.584020-1-chenghaoyang@chromium.org> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog 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" This fixes commit 4d9db06d669044c0c461a2aed79c85c7fe32a502. Previously we call Thread::setThreadAffinityInternal in Thread::startThread, which seems to lead to a SEGV in pthread_setaffinity_np. This patch moves the call after the construction of std::thread. Signed-off-by: Harvey Yang --- 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 f6322fe31..319bfda9a 100644 --- a/src/libcamera/base/thread.cpp +++ b/src/libcamera/base/thread.cpp @@ -257,6 +257,8 @@ void Thread::start() data_->exit_.store(false, std::memory_order_relaxed); thread_ = std::thread(&Thread::startThread, this); + + setThreadAffinityInternal(); } void Thread::startThread() @@ -284,8 +286,6 @@ void Thread::startThread() data_->tid_ = syscall(SYS_gettid); currentThreadData = data_; - setThreadAffinityInternal(); - run(); }