Show a patch.

GET /api/patches/22605/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 22605,
    "url": "https://patchwork.libcamera.org/api/patches/22605/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/22605/",
    "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": "<20250121185554.301901-2-pobrn@protonmail.com>",
    "date": "2025-01-21T18:56:02",
    "name": "[RFC,v1,4/7] 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/22605/mbox/",
    "series": [
        {
            "id": 4960,
            "url": "https://patchwork.libcamera.org/api/series/4960/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4960",
            "date": "2025-01-21T18:50:47",
            "name": "libcamera: base: log: Misc. changes",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/4960/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/22605/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/22605/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 75D21BD160\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 21 Jan 2025 18:56:09 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5647A68558;\n\tTue, 21 Jan 2025 19:56:08 +0100 (CET)",
            "from mail-40133.protonmail.ch (mail-40133.protonmail.ch\n\t[185.70.40.133])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C92EC68558\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 21 Jan 2025 19:56:06 +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=\"YSnCQg9i\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;\n\ts=protonmail3; t=1737485766; x=1737744966;\n\tbh=hzCptBc18jSwK9BKJSVcLKAPe5QgqQtTZu6w4EUwioQ=;\n\th=Date:To:From: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=YSnCQg9igKZedVZ6oyDV4uUECKwj0MN5szgr1L07WvmMX05Xpvfb8xj32hfxWbmcm\n\thh65FWlVFsvmcJejGmcDniLJZwb2dGEHH0jaNhEUbdlEwZGVCD72kqY5nEVEJNZt+H\n\tR0MUPuNLtMMzieJACLfyy3u9GADVTysa+Ocnucb0jl919zsyd4e1OUtqiXoa2WUlGd\n\txFtVLaX63i2/HesdGJW6u5h1DpL3OzEhXRgbB1QNVBOXlRi7bDRPgyDlQ50Ar1ZgHg\n\twdcmTFqWdO5yagsuKk0ulmz5+oyjCW6x/hBrKuw6fPbGX3dYh9CW8OVCUvU985G4qR\n\tNB4gH262gXE9Q==",
        "Date": "Tue, 21 Jan 2025 18:56:02 +0000",
        "To": "libcamera-devel@lists.libcamera.org",
        "From": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>",
        "Subject": "[RFC PATCH v1 4/7] libcamera: base: log: Make\n\t`LogCategory::severity_` atomic",
        "Message-ID": "<20250121185554.301901-2-pobrn@protonmail.com>",
        "In-Reply-To": "<20250121185554.301901-1-pobrn@protonmail.com>",
        "References": "<20250121185554.301901-1-pobrn@protonmail.com>",
        "Feedback-ID": "20568564:user:proton",
        "X-Pm-Message-ID": "93197c02f271ba111e67183bf004394f13cd0377",
        "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>\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 d73aa7913..89f707e54 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 1513e41fb..795260b0a 100644\n--- a/src/libcamera/base/log.cpp\n+++ b/src/libcamera/base/log.cpp\n@@ -825,15 +825,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",
        "v1",
        "4/7"
    ]
}