Patch Detail
Show a patch.
GET /api/patches/22713/?format=api
{ "id": 22713, "url": "https://patchwork.libcamera.org/api/patches/22713/?format=api", "web_url": "https://patchwork.libcamera.org/patch/22713/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20250130195811.1230581-5-pobrn@protonmail.com>", "date": "2025-01-30T19:58:34", "name": "[RFC,v2,4/9] libcamera: base: log: Make `LogCategory::severity_` atomic", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "28de949ca8682529e1efe225b890d6b47a320335", "submitter": { "id": 133, "url": "https://patchwork.libcamera.org/api/people/133/?format=api", "name": "Pőcze Barnabás", "email": "pobrn@protonmail.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/22713/mbox/", "series": [ { "id": 4982, "url": "https://patchwork.libcamera.org/api/series/4982/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4982", "date": "2025-01-30T19:58:14", "name": "libcamera: base: log: Misc. changes", "version": 2, "mbox": "https://patchwork.libcamera.org/series/4982/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/22713/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/22713/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 58756BD808\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 30 Jan 2025 19:58:42 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 137D06856F;\n\tThu, 30 Jan 2025 20:58:42 +0100 (CET)", "from mail-10629.protonmail.ch (mail-10629.protonmail.ch\n\t[79.135.106.29])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 03F166851B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 30 Jan 2025 20:58:41 +0100 (CET)" ], "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=protonmail.com header.i=@protonmail.com\n\theader.b=\"BgVsQQ2q\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;\n\ts=protonmail3; t=1738267120; x=1738526320;\n\tbh=ogl2WScHcyFWH3L1pUmaSWWgssplSkNDwDid+6wzrdc=;\n\th=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References:\n\tFeedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID:\n\tMessage-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post;\n\tb=BgVsQQ2q/orX/7W1Gkby3a7yPPIcQcrEFXlNrVJ+xTRDgapzKT9Jtbk8hjX07rG6u\n\t67g0XFNNCumbUB/E0KG4r7Sl3MMuB0nRfBlaoeMC1qSnr7InSSMfq2y1ZWsiQWakO+\n\tEP0/ErfvDI31vqfUyacyWXD1Bm20fJOwrxKsxC+T9ZmqD3MSmOFvO++zNOL4Tw+tR/\n\t54MOOM0e/aDo8I/HiLqEdlLIO949s025PZvermAPBoDV6OjGXFjuHCzDdfCtoGTWyn\n\t7j3UdY3F3K72pJwifk8InPi+ABaylmLtZ6KTDNGpiBLriv557uEgdXek+ykeVed2N4\n\t2qLdhzD7ldTZg==", "Date": "Thu, 30 Jan 2025 19:58:34 +0000", "To": "libcamera-devel@lists.libcamera.org", "From": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>", "Cc": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "Subject": "[RFC PATCH v2 4/9] libcamera: base: log: Make\n\t`LogCategory::severity_` atomic", "Message-ID": "<20250130195811.1230581-5-pobrn@protonmail.com>", "In-Reply-To": "<20250130195811.1230581-1-pobrn@protonmail.com>", "References": "<20250130195811.1230581-1-pobrn@protonmail.com>", "Feedback-ID": "20568564:user:proton", "X-Pm-Message-ID": "28b4c3e62c3505b2fd92e5c51468b1bafcc919bd", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=utf-8", "Content-Transfer-Encoding": "quoted-printable", "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": "The severity of a log category may be changed from a different thread,\nso it is important to ensure that the reads and writes happen atomically.\nUsing `std::memory_order_relaxed` should not introduce any synchronization\noverhead, it should only guarantee that the operation itself is atomic.\n\nSecondly, inline `LogCategory::setSeverity()`, as it is merely an\nassignment, so going through a DSO call is a big pessimization.\n`LogCategory` is not part of the public API, so this change has\nno external effects.\n\nThirdly, assert that the atomic variable is lock free so as to ensure\nit won't silently fall back to libatomic (or similar) on any platform.\nIf this assertion fails, this needs to be revisited.\n\nSigned-off-by: Barnabás Pőcze <pobrn@protonmail.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/base/log.h | 9 ++++++---\n src/libcamera/base/log.cpp | 5 +----\n 2 files changed, 7 insertions(+), 7 deletions(-)", "diff": "diff --git a/include/libcamera/base/log.h b/include/libcamera/base/log.h\nindex 6d2c93019..4137d87a4 100644\n--- a/include/libcamera/base/log.h\n+++ b/include/libcamera/base/log.h\n@@ -7,6 +7,7 @@\n \n #pragma once\n \n+#include <atomic>\n #include <sstream>\n \n #include <libcamera/base/private.h>\n@@ -31,8 +32,8 @@ public:\n \tstatic LogCategory *create(const char *name);\n \n \tconst std::string &name() const { return name_; }\n-\tLogSeverity severity() const { return severity_; }\n-\tvoid setSeverity(LogSeverity severity);\n+\tLogSeverity severity() const { return severity_.load(std::memory_order_relaxed); }\n+\tvoid setSeverity(LogSeverity severity) { severity_.store(severity, std::memory_order_relaxed); }\n \n \tstatic const LogCategory &defaultCategory();\n \n@@ -40,7 +41,9 @@ private:\n \texplicit LogCategory(const char *name);\n \n \tconst std::string name_;\n-\tLogSeverity severity_;\n+\n+\tstd::atomic<LogSeverity> severity_;\n+\tstatic_assert(decltype(severity_)::is_always_lock_free);\n };\n \n #define LOG_DECLARE_CATEGORY(name)\t\t\t\t\t\\\ndiff --git a/src/libcamera/base/log.cpp b/src/libcamera/base/log.cpp\nindex 51a5cd470..2abbad478 100644\n--- a/src/libcamera/base/log.cpp\n+++ b/src/libcamera/base/log.cpp\n@@ -824,15 +824,12 @@ LogCategory::LogCategory(const char *name)\n */\n \n /**\n+ * \\fn LogCategory::setSeverity(LogSeverity severity)\n * \\brief Set the severity of the log category\n *\n * Messages of severity higher than or equal to the severity of the log category\n * are printed, other messages are discarded.\n */\n-void LogCategory::setSeverity(LogSeverity severity)\n-{\n-\tseverity_ = severity;\n-}\n \n /**\n * \\brief Retrieve the default log category\n", "prefixes": [ "RFC", "v2", "4/9" ] }