{"id":24103,"url":"https://patchwork.libcamera.org/api/1.1/patches/24103/?format=json","web_url":"https://patchwork.libcamera.org/patch/24103/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20250814130534.1125903-1-kieran.bingham@ideasonboard.com>","date":"2025-08-14T13:05:34","name":"Thread: Add name parameter","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"511808df4954864264007540ace3e14eae37291b","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/1.1/people/4/?format=json","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/24103/mbox/","series":[{"id":5375,"url":"https://patchwork.libcamera.org/api/1.1/series/5375/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5375","date":"2025-08-14T13:05:34","name":"Thread: Add name parameter","version":1,"mbox":"https://patchwork.libcamera.org/series/5375/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/24103/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/24103/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id D1FA1BDCC1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 14 Aug 2025 13:05:40 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D036169257;\n\tThu, 14 Aug 2025 15:05:39 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5A44861444\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 14 Aug 2025 15:05:38 +0200 (CEST)","from Monstersaurus.lan\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id AE0D16DF;\n\tThu, 14 Aug 2025 15:04:43 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"f+0QFIac\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1755176683;\n\tbh=yKLr+NcMjN6zbpcA9UP9b3QPY8rmuED3I64tTcfH2Qs=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=f+0QFIacujwSxJ0fFdnHwZsLJN8Sx/tBGj95cydXxvvyFt6U45mxiAxq/v21E2Mm7\n\tP6kMxUFekANzm5qNZRO8+4gMR6SUXXfngio9/V7J7HPe7hsa3X93cwvkFMh/QB/9yk\n\tjRNUEAOkVJc6eFr9te70UddUeiofyZ2TxT2ZxvFE=","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"libcamera devel <libcamera-devel@lists.libcamera.org>","Cc":"\"Schulz, Andreas\" <andreas.schulz2@karlstorz.com>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>","Subject":"[PATCH] Thread: Add name parameter","Date":"Thu, 14 Aug 2025 14:05:34 +0100","Message-ID":"<20250814130534.1125903-1-kieran.bingham@ideasonboard.com>","X-Mailer":"git-send-email 2.50.1","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"From: \"Schulz, Andreas\" <andreas.schulz2@karlstorz.com>\n\nFor debugging purposes, threads can be assigned a name, which eases\ndistinguishing between them in e.g. htop or gdb. This uses a\nLinux-specific API for now which is limited to 15 characters (+ null\nterminator), so truncation is done and names for existing thread\ninstantiations were chosen to be consise.\n\n[Kieran: Apply checkstyle suggestions]\nSigned-off-by: Schulz, Andreas <andreas.schulz2@karlstorz.com>\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n include/libcamera/base/thread.h                           | 4 +++-\n src/libcamera/base/thread.cpp                             | 8 +++++++-\n src/libcamera/camera_manager.cpp                          | 2 +-\n src/libcamera/software_isp/software_isp.cpp               | 6 +++---\n .../libcamera_templates/module_ipa_proxy.cpp.tmpl         | 2 +-\n 5 files changed, 15 insertions(+), 7 deletions(-)","diff":"diff --git a/include/libcamera/base/thread.h b/include/libcamera/base/thread.h\nindex b9284c2c0556..56055261e920 100644\n--- a/include/libcamera/base/thread.h\n+++ b/include/libcamera/base/thread.h\n@@ -8,6 +8,7 @@\n #pragma once\n \n #include <memory>\n+#include <string>\n #include <sys/types.h>\n #include <thread>\n \n@@ -30,7 +31,7 @@ class ThreadMain;\n class Thread\n {\n public:\n-\tThread();\n+\tThread(std::string name = std::string());\n \tvirtual ~Thread();\n \n \tvoid start();\n@@ -74,6 +75,7 @@ private:\n \tvoid moveObject(Object *object, ThreadData *currentData,\n \t\t\tThreadData *targetData);\n \n+\tstd::string name_;\n \tstd::thread thread_;\n \tThreadData *data_;\n };\ndiff --git a/src/libcamera/base/thread.cpp b/src/libcamera/base/thread.cpp\nindex d8fe0d6971ec..d016f352a783 100644\n--- a/src/libcamera/base/thread.cpp\n+++ b/src/libcamera/base/thread.cpp\n@@ -10,6 +10,7 @@\n #include <atomic>\n #include <list>\n #include <optional>\n+#include <pthread.h>\n #include <sys/syscall.h>\n #include <sys/types.h>\n #include <unistd.h>\n@@ -140,6 +141,7 @@ class ThreadMain : public Thread\n {\n public:\n \tThreadMain()\n+\t\t: Thread(\"libcamera-main\")\n \t{\n \t\tdata_->running_ = true;\n \t}\n@@ -230,7 +232,8 @@ ThreadData *ThreadData::current()\n /**\n  * \\brief Create a thread\n  */\n-Thread::Thread()\n+Thread::Thread(std::string name)\n+\t: name_(std::move(name))\n {\n \tdata_ = new ThreadData;\n \tdata_->thread_ = this;\n@@ -286,6 +289,9 @@ void Thread::startThread()\n \tdata_->tid_ = syscall(SYS_gettid);\n \tcurrentThreadData = data_;\n \n+\tif (!name_.empty())\n+\t\tpthread_setname_np(thread_.native_handle(), name_.substr(0, 15).c_str());\n+\n \trun();\n }\n \ndiff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp\nindex f81794bfd6fe..a42835c18739 100644\n--- a/src/libcamera/camera_manager.cpp\n+++ b/src/libcamera/camera_manager.cpp\n@@ -38,7 +38,7 @@ LOG_DEFINE_CATEGORY(Camera)\n \n #ifndef __DOXYGEN_PUBLIC__\n CameraManager::Private::Private()\n-\t: initialized_(false)\n+\t: Thread(\"CameraManager\"), initialized_(false)\n {\n \tipaManager_ = std::make_unique<IPAManager>();\n }\ndiff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp\nindex 28e2a360e7e6..b2f6cf61b646 100644\n--- a/src/libcamera/software_isp/software_isp.cpp\n+++ b/src/libcamera/software_isp/software_isp.cpp\n@@ -75,9 +75,9 @@ LOG_DEFINE_CATEGORY(SoftwareIsp)\n  */\n SoftwareIsp::SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor,\n \t\t\t ControlInfoMap *ipaControls)\n-\t: dmaHeap_(DmaBufAllocator::DmaBufAllocatorFlag::CmaHeap |\n-\t\t   DmaBufAllocator::DmaBufAllocatorFlag::SystemHeap |\n-\t\t   DmaBufAllocator::DmaBufAllocatorFlag::UDmaBuf)\n+\t: ispWorkerThread_(\"SWIspWorker\"), dmaHeap_(DmaBufAllocator::DmaBufAllocatorFlag::CmaHeap |\n+\t\t\t\t\t\t    DmaBufAllocator::DmaBufAllocatorFlag::SystemHeap |\n+\t\t\t\t\t\t    DmaBufAllocator::DmaBufAllocatorFlag::UDmaBuf)\n {\n \t/*\n \t * debayerParams_ must be initialized because the initial value is used for\ndiff --git a/utils/codegen/ipc/generators/libcamera_templates/module_ipa_proxy.cpp.tmpl b/utils/codegen/ipc/generators/libcamera_templates/module_ipa_proxy.cpp.tmpl\nindex beb646e2d157..7d2d510f5a79 100644\n--- a/utils/codegen/ipc/generators/libcamera_templates/module_ipa_proxy.cpp.tmpl\n+++ b/utils/codegen/ipc/generators/libcamera_templates/module_ipa_proxy.cpp.tmpl\n@@ -46,7 +46,7 @@ namespace {{ns}} {\n {%- endif %}\n \n {{proxy_name}}::{{proxy_name}}(IPAModule *ipam, bool isolate)\n-\t: IPAProxy(ipam), isolate_(isolate),\n+\t: IPAProxy(ipam), thread_(\"{{proxy_name}}\"), isolate_(isolate),\n \t  controlSerializer_(ControlSerializer::Role::Proxy), seq_(0)\n {\n \tLOG(IPAProxy, Debug)\n","prefixes":[]}